Skip to content

Commit

Permalink
Fix battery osd precision
Browse files Browse the repository at this point in the history
with voltage <10V
  • Loading branch information
fgiudice98 committed Jan 2, 2020
1 parent 6433aaa commit 09a91aa
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/osd/osd_elements.c
Expand Up @@ -988,13 +988,14 @@ static void osdElementMainBatteryUsage(osdElementParms_t *element)

static void osdElementMainBatteryVoltage(osdElementParms_t *element)
{
const int batteryVoltage = (getBatteryVoltage() + 5) / 10;
int batteryVoltage = getBatteryVoltage();

element->buff[0] = osdGetBatterySymbol(getBatteryAverageCellVoltage());
if (batteryVoltage >= 100) {
if (batteryVoltage >= 1000) {
batteryVoltage = (batteryVoltage + 5) / 10;
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);
tfp_sprintf(element->buff + 1, "%d.%d%c", batteryVoltage / 100, batteryVoltage % 100, SYM_VOLT);
}
}

Expand Down

0 comments on commit 09a91aa

Please sign in to comment.