From 65ec12bb0d8afa7f9e14a675a90d43f82a754145 Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Wed, 22 Jul 2026 04:05:07 +0200 Subject: [PATCH] Show active scan list name when it changes during scan (discussion #462) --- App/app/action.c | 2 +- App/app/chFrScanner.c | 8 +++-- App/app/main.c | 6 ++-- App/ui/main.c | 69 ++++++++++++++++++++++++++++++++++++++----- App/ui/main.h | 2 ++ 5 files changed, 74 insertions(+), 13 deletions(-) diff --git a/App/app/action.c b/App/app/action.c index 97da7c59..d4468e32 100644 --- a/App/app/action.c +++ b/App/app/action.c @@ -243,7 +243,7 @@ void ACTION_Scan(bool bRestart) // channel mode. Keep scanning but toggle between scan lists RADIO_NextValidList(1); - UI_MAIN_NotifyScanProgressDataChanged(); + UI_MAIN_NotifyScanListChanged(); #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE SETTINGS_WriteCurrentState(); diff --git a/App/app/chFrScanner.c b/App/app/chFrScanner.c index 0d6a2758..862370b6 100644 --- a/App/app/chFrScanner.c +++ b/App/app/chFrScanner.c @@ -771,13 +771,17 @@ void CHFRSCANNER_Start(const bool storeBackupSettings, const int8_t scan_directi #endif if (IS_MR_CHANNEL(gNextMrChannel)) - { + { + bool scanListChanged = false; if(!RADIO_CheckValidList(gEeprom.SCAN_LIST_DEFAULT)) { RADIO_NextValidList(1); - UI_MAIN_NotifyScanProgressDataChanged(); + scanListChanged = true; } + if (storeBackupSettings || scanListChanged) + UI_MAIN_NotifyScanListChanged(); + // channel mode if (storeBackupSettings) { initialFrqOrChan = gRxVfo->CHANNEL_SAVE; diff --git a/App/app/main.c b/App/app/main.c index 4d8938db..a3a45362 100644 --- a/App/app/main.c +++ b/App/app/main.c @@ -317,7 +317,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) if (gScanStateDir != SCAN_OFF) { RADIO_NextValidList(isKeyUp ? 1 : -1); - UI_MAIN_NotifyScanProgressDataChanged(); + UI_MAIN_NotifyScanListChanged(); } else { // Adjust squelch: UP increments, DOWN decrements if (gSquelchLevelOriginal == 10) @@ -500,7 +500,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (value == 0) { gEeprom.SCAN_LIST_DEFAULT = MR_CHANNELS_LIST + 1; - UI_MAIN_NotifyScanProgressDataChanged(); + UI_MAIN_NotifyScanListChanged(); #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE SETTINGS_WriteCurrentState(); #endif @@ -519,7 +519,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; RADIO_NextValidList(1); } - UI_MAIN_NotifyScanProgressDataChanged(); + UI_MAIN_NotifyScanListChanged(); #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE SETTINGS_WriteCurrentState(); diff --git a/App/ui/main.c b/App/ui/main.c index b5c860ac..3946966d 100644 --- a/App/ui/main.c +++ b/App/ui/main.c @@ -68,6 +68,7 @@ center_line_t center_line = CENTER_LINE_NONE; #ifdef ENABLE_FEAT_F4HWN_SCAN_PROGRESS #define SCAN_PROGRESS_MR_CHANNEL_BYTES ((MR_CHANNELS_MAX + 7u) / 8u) +#define SCAN_LIST_NAME_HOLD_500MS (2000u / 500u) static bool gScanProgressSessionActive; static bool gScanProgressSessionIsMemory; @@ -82,6 +83,7 @@ static bool gScanProgressPrevResetVfosFlag; static bool gScanProgressForceRebuild; static uint16_t gScanProgressLastMemoryIndex; static uint8_t gScanProgressPriorityState; +static uint8_t gScanListNameCountdown_500ms; #define SCAN_PROGRESS_PRIORITY_LABEL_MASK 0x03u #define SCAN_PROGRESS_PRIORITY_SEEN_SHIFT 2 #define SCAN_PROGRESS_PRIORITY_SEEN_MASK 0x1cu @@ -90,15 +92,24 @@ static uint8_t gScanProgressPriorityState; #define SCAN_PROGRESS_PRIORITY_HOLD_FRAMES 6 #endif +#if defined(ENABLE_FEAT_F4HWN_BEAM) || defined(ENABLE_FEAT_F4HWN_SCAN_PROGRESS) +// Shared center-line renderer: clear the line and print bold text on it. +static void UI_MAIN_DrawCenterBoldLine(const char *text, uint8_t start) +{ +#ifdef ENABLE_FEAT_F4HWN + const uint8_t line = isMainOnly() ? 5 : 3; +#else + const uint8_t line = 3; +#endif + memset(gFrameBuffer[line], 0, LCD_WIDTH); + UI_PrintStringSmallBold(text, start, LCD_WIDTH - 1, line); +} +#endif + #ifdef ENABLE_FEAT_F4HWN_BEAM static void UI_MAIN_DrawBeamLine(void) { const char *text; -#ifdef ENABLE_FEAT_F4HWN - const unsigned int line = isMainOnly() ? 5 : 3; -#else - const unsigned int line = 3; -#endif switch (gBeamStatus) { case BEAM_STATUS_TX_WAIT: @@ -125,8 +136,7 @@ static void UI_MAIN_DrawBeamLine(void) break; } - memset(gFrameBuffer[line], 0, LCD_WIDTH); - UI_PrintStringSmallBold(text, 2, 127, line); + UI_MAIN_DrawCenterBoldLine(text, 2); } #endif @@ -214,6 +224,7 @@ static void ScanProgress_ResetSession(void) gScanProgressForceRebuild = false; gScanProgressLastMemoryIndex = 0; gScanProgressPriorityState = 0; + gScanListNameCountdown_500ms = 0; } void UI_MAIN_NotifyScanProgressDataChanged(void) @@ -222,6 +233,13 @@ void UI_MAIN_NotifyScanProgressDataChanged(void) gUpdateStatus = true; } +void UI_MAIN_NotifyScanListChanged(void) +{ + UI_MAIN_NotifyScanProgressDataChanged(); + gScanListNameCountdown_500ms = SCAN_LIST_NAME_HOLD_500MS; + gUpdateDisplay = true; +} + static inline void ScanProgress_SetBit(uint8_t *map, uint16_t ch) { map[ch >> 3] |= (uint8_t)(1u << (ch & 7)); @@ -243,6 +261,33 @@ static uint8_t ScanProgress_GetActiveScanList(void) return scan_list; } +static void UI_MAIN_DrawScanListName(void) +{ + const uint8_t scan_list = ScanProgress_GetActiveScanList(); + char text[16]; + + // Manual formatting instead of snprintf: much smaller on a divide-less M0 core + strcpy(text, "SCAN LIST "); + char *p = text + 10; // sizeof("SCAN LIST ") - 1 + + if (scan_list > MR_CHANNELS_LIST) { + *p++ = 'A'; *p++ = 'L'; *p++ = 'L'; + } else { + const char *name = gListName[scan_list - 1]; + + if (IsEmptyName(name, sizeof(gListName[0]))) { + *p++ = (char)('0' + scan_list / 10); + *p++ = (char)('0' + scan_list % 10); + } else { + for (uint8_t i = 0; i < 3 && name[i]; i++) + *p++ = name[i]; + } + } + *p = '\0'; + + UI_MAIN_DrawCenterBoldLine(text, 0); +} + static bool ScanProgress_ChannelBelongsToList(uint16_t channel, const ChannelAttributes_t *att, uint8_t scan_list) { if (!IS_MR_CHANNEL(channel)) @@ -490,6 +535,12 @@ static bool UI_DrawScanProgress(void) return false; } + // Right after a scan-list change, briefly show its name instead of the progress bar + if (show_memory && gScanListNameCountdown_500ms > 0) { + UI_MAIN_DrawScanListName(); + return true; + } + if (show_memory) { const uint8_t scan_list = ScanProgress_GetActiveScanList(); const bool reset_vfos_edge = gFlagResetVfos && !gScanProgressPrevResetVfosFlag; @@ -1167,6 +1218,10 @@ void UI_MAIN_PrintAGC(bool now) void UI_MAIN_TimeSlice500ms(void) { if(gScreenToDisplay==DISPLAY_MAIN) { +#ifdef ENABLE_FEAT_F4HWN_SCAN_PROGRESS + if (gScanListNameCountdown_500ms > 0 && --gScanListNameCountdown_500ms == 0) + gUpdateDisplay = true; +#endif #ifdef ENABLE_AGC_SHOW_DATA UI_MAIN_PrintAGC(true); return; diff --git a/App/ui/main.h b/App/ui/main.h index 43abb3aa..777b26f1 100644 --- a/App/ui/main.h +++ b/App/ui/main.h @@ -55,8 +55,10 @@ void UI_DisplayMain(void); #ifdef ENABLE_FEAT_F4HWN_SCAN_PROGRESS void UI_MAIN_NotifyScanProgressDataChanged(void); +void UI_MAIN_NotifyScanListChanged(void); #else static inline void UI_MAIN_NotifyScanProgressDataChanged(void) {} +static inline void UI_MAIN_NotifyScanListChanged(void) {} #endif #ifdef ENABLE_AGC_SHOW_DATA