AP_OSD: fix format of RF panel and check for out of range

This commit is contained in:
Henry Wurzburg 2023-05-02 21:56:58 -05:00 committed by Andrew Tridgell
parent bea98fa909
commit 5e54d26ac5
1 changed files with 3 additions and 4 deletions

View File

@ -2201,12 +2201,11 @@ void AP_OSD_Screen::draw_rngf(uint8_t x, uint8_t y)
if (rangefinder == nullptr) {
return;
}
if (rangefinder->status_orient(ROTATION_PITCH_270) <= RangeFinder::Status::NoData) {
backend->write(x, y, false, "%c----%c", SYMBOL(SYM_RNGFD), u_icon(DISTANCE));
if (rangefinder->status_orient(ROTATION_PITCH_270) < RangeFinder::Status::Good) {
backend->write(x, y, false, "%c---%c", SYMBOL(SYM_RNGFD), u_icon(DISTANCE));
} else {
const float distance = rangefinder->distance_orient(ROTATION_PITCH_270);
const char *format = distance < 9.995 ? "%c %1.2f%c" : "%c%2.2f%c";
backend->write(x, y, false, format, SYMBOL(SYM_RNGFD), u_scale(DISTANCE, distance), u_icon(DISTANCE));
backend->write(x, y, false, "%c%4.1f%c", SYMBOL(SYM_RNGFD), u_scale(DISTANCE, distance), u_icon(DISTANCE));
}
}