From 24d3e5283f5fa990efbf0f993b1b336ac0512980 Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Tue, 25 Aug 2026 15:25:24 +0200 Subject: [PATCH] Optimize Broadcast FM display and remove dead channel formatter --- App/ui/fmradio.c | 26 ++++++++++++++++++-------- App/ui/helper.c | 19 ------------------- App/ui/helper.h | 1 - 3 files changed, 18 insertions(+), 28 deletions(-) diff --git a/App/ui/fmradio.c b/App/ui/fmradio.c index 38d9da06..684a182f 100644 --- a/App/ui/fmradio.c +++ b/App/ui/fmradio.c @@ -31,6 +31,13 @@ void UI_DisplayFM(void) { + // Keep these labels in sync with the limits in driver/bk1080.c. + static const char BandNames[][10] = { + "87.5-108M", + "76-108M", + "76-90M", + "64-76M", + }; char String[16]; char *pPrintStr = String; UI_DisplayClear(); @@ -41,13 +48,7 @@ void UI_DisplayFM(void) UI_PrintString("FM", 2, 0, 0, 8); - sprintf(String, "%d%s-%dM", - BK1080_GetFreqLoLimit(gEeprom.FM_Band)/10, - gEeprom.FM_Band == 0 ? ".5" : "", - BK1080_GetFreqHiLimit(gEeprom.FM_Band)/10 - ); - - UI_PrintStringSmallNormal(String, 1, 0, 6); + UI_PrintStringSmallNormal(BandNames[gEeprom.FM_Band], 1, 0, 6); //uint8_t spacings[] = {20,10,5}; //sprintf(String, "%d0k", spacings[gEeprom.FM_Space % 3]); @@ -81,7 +82,16 @@ void UI_DisplayFM(void) UI_PrintString(pPrintStr, 0, 127, 3, 10); // memory, vfo, scan if (gAskToSave || (gEeprom.FM_IsMrMode && gInputBoxIndex > 0)) { - UI_GenerateChannelString(String, gFM_ChannelPosition); + if (gInputBoxIndex == 0) { + sprintf(String, "CH-%02u", gFM_ChannelPosition + 1); + } else { + String[0] = 'C'; + String[1] = 'H'; + String[2] = '-'; + for (unsigned int i = 0; i < 2; i++) + String[i + 3] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0'; + String[5] = '\0'; + } } else if (gAskToDelete) { sprintf(String, "CH-%02u", gEeprom.FM_SelectedChannel + 1); } else { diff --git a/App/ui/helper.c b/App/ui/helper.c index 1de0067b..f25f9622 100644 --- a/App/ui/helper.c +++ b/App/ui/helper.c @@ -25,25 +25,6 @@ #include "settings.h" -void UI_GenerateChannelString(char *pString, const uint16_t Channel) -{ - unsigned int i; - - if (gInputBoxIndex == 0) - { - sprintf(pString, "CH-%02u", Channel + 1); - return; - } - - pString[0] = 'C'; - pString[1] = 'H'; - pString[2] = '-'; - for (i = 0; i < 2; i++) - pString[i + 3] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0'; - - pString[5] = 0; -} - void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint16_t ChannelNumber) { if (gInputBoxIndex > 0) { diff --git a/App/ui/helper.h b/App/ui/helper.h index 0b62abb6..1d2a32a7 100644 --- a/App/ui/helper.h +++ b/App/ui/helper.h @@ -20,7 +20,6 @@ #include #include -void UI_GenerateChannelString(char *pString, const uint16_t Channel); void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint16_t ChannelNumber); void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width); void UI_PrintStringSmallNormal(const char *pString, uint8_t Start, uint8_t End, uint8_t Line);