diff --git a/src/main/osd/osd_elements.c b/src/main/osd/osd_elements.c index 5bc1aa2b38..23e5fa5036 100644 --- a/src/main/osd/osd_elements.c +++ b/src/main/osd/osd_elements.c @@ -846,8 +846,14 @@ static void osdElementMainBatteryUsage(osdElementParms_t *element) static void osdElementMainBatteryVoltage(osdElementParms_t *element) { + const int batteryVoltage = (getBatteryVoltage() + 5) / 10; + element->buff[0] = osdGetBatterySymbol(getBatteryAverageCellVoltage()); - tfp_sprintf(element->buff + 1, "%2d.%02d%c", getBatteryVoltage() / 100, getBatteryVoltage() % 100, SYM_VOLT); + if (batteryVoltage >= 100) { + tfp_sprintf(element->buff + 1, "%d.%d%c", batteryVoltage / 10, batteryVoltage % 10, SYM_VOLT); + } else { + tfp_sprintf(element->buff + 1, "%d.%d0%c", batteryVoltage / 10, batteryVoltage % 10, SYM_VOLT); + } } static void osdElementMotorDiagnostics(osdElementParms_t *element) @@ -1440,7 +1446,7 @@ void osdAnalyzeActiveElements(void) osdAddActiveElement(OSD_FLIGHT_DIST); } #endif // GPS -#ifdef USE_ESC_SENSOR +#ifdef USE_ESC_SENSOR if (featureIsEnabled(FEATURE_ESC_SENSOR)) { osdAddActiveElement(OSD_ESC_TMP); } diff --git a/src/test/unit/osd_unittest.cc b/src/test/unit/osd_unittest.cc index 01dda9eb92..45acd778d4 100644 --- a/src/test/unit/osd_unittest.cc +++ b/src/test/unit/osd_unittest.cc @@ -517,7 +517,7 @@ TEST(OsdTest, TestAlarms) printf("%d\n", i); #endif displayPortTestBufferSubstring(8, 1, "%c99", SYM_RSSI); - displayPortTestBufferSubstring(12, 1, "%c16.80%c", SYM_BATT_FULL, SYM_VOLT); + displayPortTestBufferSubstring(12, 1, "%c16.8%c", SYM_BATT_FULL, SYM_VOLT); displayPortTestBufferSubstring(1, 1, "%c00:", SYM_FLY_M); // only test the minute part of the timer displayPortTestBufferSubstring(20, 1, "%c01:", SYM_ON_M); // only test the minute part of the timer displayPortTestBufferSubstring(23, 7, " .0%c", SYM_M); @@ -546,7 +546,7 @@ TEST(OsdTest, TestAlarms) #endif if (i % 2 == 0) { displayPortTestBufferSubstring(8, 1, "%c12", SYM_RSSI); - displayPortTestBufferSubstring(12, 1, "%c13.50%c", SYM_MAIN_BATT, SYM_VOLT); + displayPortTestBufferSubstring(12, 1, "%c13.5%c", SYM_MAIN_BATT, SYM_VOLT); displayPortTestBufferSubstring(1, 1, "%c01:", SYM_FLY_M); // only test the minute part of the timer displayPortTestBufferSubstring(20, 1, "%c02:", SYM_ON_M); // only test the minute part of the timer displayPortTestBufferSubstring(23, 7, " 120.0%c", SYM_M);