Battery percentage based on real measurements

This commit is contained in:
Krzysiek Egzmont
2023-09-27 00:09:20 +02:00
parent 99ef859a52
commit 634fe4b883
8 changed files with 53 additions and 20 deletions

View File

@@ -169,9 +169,7 @@ void UI_DisplayStatus(const bool test_display)
case 2: // percentage
{
const uint16_t voltage = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v : gBatteryVoltageAverage;
const uint16_t percent = (100 * (voltage - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v);
// const uint16_t percent = gBatteryDisplayLevel;
const uint16_t percent = BATTERY_VoltsToPercent(gBatteryVoltageAverage);
sprintf(s, "%u%%", percent);
space_needed = (7 * strlen(s));
if (x2 >= (x1 + space_needed))