1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-25 01:05:27 +03:00

Show only 3 significant digits in vbat OSD element

This commit is contained in:
jirif 2019-04-14 15:41:44 +02:00
parent 9d027275e2
commit 5d30b3f437
2 changed files with 10 additions and 4 deletions

View file

@ -846,8 +846,14 @@ static void osdElementMainBatteryUsage(osdElementParms_t *element)
static void osdElementMainBatteryVoltage(osdElementParms_t *element) static void osdElementMainBatteryVoltage(osdElementParms_t *element)
{ {
const int batteryVoltage = (getBatteryVoltage() + 5) / 10;
element->buff[0] = osdGetBatterySymbol(getBatteryAverageCellVoltage()); 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) static void osdElementMotorDiagnostics(osdElementParms_t *element)
@ -1440,7 +1446,7 @@ void osdAnalyzeActiveElements(void)
osdAddActiveElement(OSD_FLIGHT_DIST); osdAddActiveElement(OSD_FLIGHT_DIST);
} }
#endif // GPS #endif // GPS
#ifdef USE_ESC_SENSOR #ifdef USE_ESC_SENSOR
if (featureIsEnabled(FEATURE_ESC_SENSOR)) { if (featureIsEnabled(FEATURE_ESC_SENSOR)) {
osdAddActiveElement(OSD_ESC_TMP); osdAddActiveElement(OSD_ESC_TMP);
} }

View file

@ -517,7 +517,7 @@ TEST(OsdTest, TestAlarms)
printf("%d\n", i); printf("%d\n", i);
#endif #endif
displayPortTestBufferSubstring(8, 1, "%c99", SYM_RSSI); 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(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(20, 1, "%c01:", SYM_ON_M); // only test the minute part of the timer
displayPortTestBufferSubstring(23, 7, " .0%c", SYM_M); displayPortTestBufferSubstring(23, 7, " .0%c", SYM_M);
@ -546,7 +546,7 @@ TEST(OsdTest, TestAlarms)
#endif #endif
if (i % 2 == 0) { if (i % 2 == 0) {
displayPortTestBufferSubstring(8, 1, "%c12", SYM_RSSI); 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(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(20, 1, "%c02:", SYM_ON_M); // only test the minute part of the timer
displayPortTestBufferSubstring(23, 7, " 120.0%c", SYM_M); displayPortTestBufferSubstring(23, 7, " 120.0%c", SYM_M);