From 9777b5df8b57bd349117daf2e285ce6a9fad0a78 Mon Sep 17 00:00:00 2001 From: Krzysiek Egzmont Date: Thu, 2 Nov 2023 02:44:05 +0100 Subject: [PATCH] Modified battery icon levels --- helper/battery.c | 6 +++--- radio.c | 2 +- ui/battery.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/helper/battery.c b/helper/battery.c index dfa978d..b7468d2 100644 --- a/helper/battery.c +++ b/helper/battery.c @@ -104,14 +104,14 @@ void BATTERY_GetReadings(const bool bDisplayBatteryLevel) gBatteryVoltageAverage = (Voltage * 760) / gBatteryCalibration[3]; if(gBatteryVoltageAverage > 840) - gBatteryDisplayLevel = 6; // battery overvoltage + gBatteryDisplayLevel = 7; // battery overvoltage else if(gBatteryVoltageAverage < 630) gBatteryDisplayLevel = 0; // battery critical else { gBatteryDisplayLevel = 1; - const uint8_t levels[] = {5,25,50,75}; + const uint8_t levels[] = {5,17,41,65,88}; uint8_t perc = BATTERY_VoltsToPercent(gBatteryVoltageAverage); - for(uint8_t i = 5; i >= 1; i--){ + for(uint8_t i = 6; i >= 1; i--){ if (perc > levels[i-2]) { gBatteryDisplayLevel = i; break; diff --git a/radio.c b/radio.c index 11b3012..1e89983 100644 --- a/radio.c +++ b/radio.c @@ -983,7 +983,7 @@ void RADIO_PrepareTX(void) if (gBatteryDisplayLevel == 0) State = VFO_STATE_BAT_LOW; // charge your battery ! else - if (gBatteryDisplayLevel >= 6) + if (gBatteryDisplayLevel > 6) State = VFO_STATE_VOLTAGE_HIGH; // over voltage .. this is being a pain } else diff --git a/ui/battery.c b/ui/battery.c index c45fcfe..0441994 100644 --- a/ui/battery.c +++ b/ui/battery.c @@ -30,10 +30,10 @@ void UI_DrawBattery(uint8_t* bitmap, uint8_t level, uint8_t blink) else { memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1)); - if (level > 1) + if (level > 2) { unsigned int i; - uint8_t bars = level - 1; + uint8_t bars = level - 2; if (bars > 4) bars = 4; for (i = 0; i < bars; i++)