From 85dae05ad390b90c66b0c994b8ded0a8e79db968 Mon Sep 17 00:00:00 2001 From: mrkusypl Date: Sat, 21 Mar 2026 19:13:51 +0100 Subject: [PATCH] Minor code refactoring (24 B) --- App/ui/fmradio.c | 4 +--- App/ui/helper.c | 18 ++++++++++++++++++ App/ui/helper.h | 1 + App/ui/main.c | 45 +++++++-------------------------------------- 4 files changed, 27 insertions(+), 41 deletions(-) diff --git a/App/ui/fmradio.c b/App/ui/fmradio.c index 02dd5920..0e46f41e 100644 --- a/App/ui/fmradio.c +++ b/App/ui/fmradio.c @@ -36,9 +36,7 @@ void UI_DisplayFM(void) UI_DisplayClear(); #ifdef ENABLE_FEAT_F4HWN - if (gEeprom.KEY_LOCK && gKeypadLocked > 0) { - UI_PrintStringSmallBold("UNLOCK KEYBOARD", 12, 0, 5); - } + UI_DisplayUnlockKeyboard(5); #endif UI_PrintString("FM", 2, 0, 0, 8); diff --git a/App/ui/helper.c b/App/ui/helper.c index 764de28f..a0edd501 100644 --- a/App/ui/helper.c +++ b/App/ui/helper.c @@ -22,6 +22,7 @@ #include "ui/helper.h" #include "ui/inputbox.h" #include "misc.h" +#include "settings.h" void UI_GenerateChannelString(char *pString, const uint16_t Channel) @@ -322,6 +323,23 @@ static void sort(int16_t *a, int16_t *b) } } + void UI_DisplayUnlockKeyboard(uint8_t shift) { + if (gEeprom.KEY_LOCK && gKeypadLocked > 0) + { // tell user how to unlock the keyboard + + //memcpy(gFrameBuffer[shift] + 2, gFontKeyLock, sizeof(gFontKeyLock)); + UI_PrintStringSmallBold("UNLOCK KEYBOARD", 12, 0, shift); + //memcpy(gFrameBuffer[shift] + 120, gFontKeyLock, sizeof(gFontKeyLock)); + + /* + for (uint8_t i = 12; i < 116; i++) + { + gFrameBuffer[shift][i] ^= 0xFF; + } + */ + } + } + bool IsEmptyName(const char *name, uint8_t len) { if (name[0] == '\0' || name[0] == '\xff') return true; diff --git a/App/ui/helper.h b/App/ui/helper.h index 267a158e..0002f2cb 100644 --- a/App/ui/helper.h +++ b/App/ui/helper.h @@ -38,6 +38,7 @@ void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black void PutPixel(uint8_t x, uint8_t y, bool fill); void PutPixelStatus(uint8_t x, uint8_t y, bool fill); void GUI_DisplaySmallest(const char *pString, uint8_t x, uint8_t y, bool statusbar, bool fill); + void UI_DisplayUnlockKeyboard(uint8_t shift); bool IsEmptyName(const char *name, uint8_t len); #endif void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black); diff --git a/App/ui/main.c b/App/ui/main.c index 58e43330..153303b2 100644 --- a/App/ui/main.c +++ b/App/ui/main.c @@ -77,19 +77,13 @@ static void DrawSmallPowerBars(uint8_t *p, unsigned int level) if(level>6) level = 6; - if(gSetting_set_gui) - { - for(uint8_t i = 0; i <= level; i++) { - char bar = (0xff << (6-i)) & 0x7F; - memset(p + 2 + i*3, bar, 2); - } - } - else - { - for(uint8_t i = 0; i <= level; i++) { - char bar = 0b00111110; - memset(p + 2 + i*3, bar, 2); + char bar = 0b00111110; + + for(uint8_t i = 0; i <= level; i++) { + if(gSetting_set_gui) { + bar = (0xff << (6-i)) & 0x7F; } + memset(p + 2 + i*3, bar, 2); } } #if defined ENABLE_AUDIO_BAR || defined ENABLE_RSSI_BAR @@ -563,32 +557,7 @@ void UI_DisplayMain(void) return; } #else - if (gEeprom.KEY_LOCK && gKeypadLocked > 0) - { // tell user how to unlock the keyboard - uint8_t shift = 3; - - /* - BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, true); - SYSTEM_DelayMs(50); - BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, false); - SYSTEM_DelayMs(50); - */ - - if(isMainOnly()) - { - shift = 5; - } - //memcpy(gFrameBuffer[shift] + 2, gFontKeyLock, sizeof(gFontKeyLock)); - UI_PrintStringSmallBold("UNLOCK KEYBOARD", 12, 0, shift); - //memcpy(gFrameBuffer[shift] + 120, gFontKeyLock, sizeof(gFontKeyLock)); - - /* - for (uint8_t i = 12; i < 116; i++) - { - gFrameBuffer[shift][i] ^= 0xFF; - } - */ - } + UI_DisplayUnlockKeyboard(isMainOnly() ? 5 : 3); #endif unsigned int activeTxVFO = gRxVfoIsActive ? gEeprom.RX_VFO : gEeprom.TX_VFO;