From eb88e6a37c6dc2e8df8d1238e882c31fbb68ceef Mon Sep 17 00:00:00 2001 From: Michel Pastor Date: Sat, 28 Nov 2020 21:45:25 +0100 Subject: [PATCH] AP_OSD: Fix vertical speed varying length --- libraries/AP_OSD/AP_OSD_Screen.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libraries/AP_OSD/AP_OSD_Screen.cpp b/libraries/AP_OSD/AP_OSD_Screen.cpp index 547d2098ab..f4211eeedf 100644 --- a/libraries/AP_OSD/AP_OSD_Screen.cpp +++ b/libraries/AP_OSD/AP_OSD_Screen.cpp @@ -1457,10 +1457,11 @@ void AP_OSD_Screen::draw_vspeed(uint8_t x, uint8_t y) sym = SYM_DOWN_DOWN; } vs_scaled = u_scale(VSPEED, fabsf(vspd)); - if (vs_scaled < 10.0f) { - backend->write(x, y, false, "%c%2.1f%c", sym, (float)vs_scaled, u_icon(VSPEED)); + if ((osd->units != AP_OSD::UNITS_AVIATION) && (vs_scaled < 9.95f)) { + backend->write(x, y, false, "%c%.1f%c", sym, (float)vs_scaled, u_icon(VSPEED)); } else { - backend->write(x, y, false, "%c%3d%c", sym, (int)vs_scaled, u_icon(VSPEED)); + const char *fmt = osd->units == AP_OSD::UNITS_AVIATION ? "%c%4d%c" : "%c%2d%c"; + backend->write(x, y, false, fmt, sym, (int)roundf(vs_scaled), u_icon(VSPEED)); } }