From 8d17f5922cdaca7e69fb187d16df6ef79ffb543b Mon Sep 17 00:00:00 2001 From: Krzysiek Egzmont Date: Tue, 10 Oct 2023 01:37:29 +0200 Subject: [PATCH] FIX #21: Battery symbol fix of a fix --- Makefile | 2 +- ui/battery.c | 43 +++++++++++++++++++++---------------------- ui/status.c | 2 +- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 6ad18ba..3a4b722 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ ENABLE_F_CAL_MENU := 0 ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1 ENABLE_BOOT_BEEPS := 0 ENABLE_SHOW_CHARGE_LEVEL := 1 -ENABLE_REVERSE_BAT_SYMBOL := 1 +ENABLE_REVERSE_BAT_SYMBOL := 0 ENABLE_CODE_SCAN_TIMEOUT := 0 ENABLE_AM_FIX := 1 ENABLE_AM_FIX_SHOW_DATA := 0 diff --git a/ui/battery.c b/ui/battery.c index 9a2957c..c45fcfe 100644 --- a/ui/battery.c +++ b/ui/battery.c @@ -24,34 +24,33 @@ void UI_DrawBattery(uint8_t* bitmap, uint8_t level, uint8_t blink) { - memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1)); - - if (level >= 1) + if (level < 2 && blink == 1) { + memset(bitmap, 0, sizeof(BITMAP_BatteryLevel1)); + } + else { - unsigned int i; - uint8_t bars = level > 0 ? level - 1 : 0; - if(bars>4) bars = 4; - for (i = 0; i < bars; i++) + memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1)); + if (level > 1) { - #ifndef ENABLE_REVERSE_BAT_SYMBOL - memcpy(bitmap + sizeof(bitmap) - 4 - (i * 3), BITMAP_BatteryLevel, 2); - #else - memcpy(bitmap + 3 + (i * 3) + 0, BITMAP_BatteryLevel, 2); - #endif + unsigned int i; + uint8_t bars = level - 1; + if (bars > 4) + bars = 4; + for (i = 0; i < bars; i++) + { + #ifndef ENABLE_REVERSE_BAT_SYMBOL + memcpy(bitmap + sizeof(BITMAP_BatteryLevel1) - 4 - (i * 3), BITMAP_BatteryLevel, 2); + #else + memcpy(bitmap + 3 + (i * 3) + 0, BITMAP_BatteryLevel, 2); + #endif + } } } - else - if (blink == 0) - memset(bitmap, 0, sizeof(bitmap)); } void UI_DisplayBattery(uint8_t level, uint8_t blink) { - if (gCurrentFunction != FUNCTION_TRANSMIT) { - uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)]; - - UI_DrawBattery(bitmap, level, blink); - memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1)); - ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, sizeof(bitmap), bitmap); - } + uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)]; + UI_DrawBattery(bitmap, level, blink); + ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, sizeof(bitmap), bitmap); } diff --git a/ui/status.c b/ui/status.c index 6004acf..ef03a88 100644 --- a/ui/status.c +++ b/ui/status.c @@ -218,7 +218,7 @@ void UI_DisplayStatus(const bool test_display) x += sizeof(BITMAP_USB_C); // BATTERY LEVEL indicator - UI_DrawBattery(line + x, gBatteryDisplayLevel, gLowBattery); + UI_DrawBattery(line + x, gBatteryDisplayLevel, gLowBatteryBlink); // **************