From 85f1bfdb7f2bf384c7ef321f21b88f3b091114aa Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Sun, 8 Feb 2026 03:24:25 +0100 Subject: [PATCH] Fix SCAN_SAVE_CHANNEL and UI_GenerateChannelStringEx --- App/app/app.c | 2 +- App/app/menu.c | 7 ++++--- App/app/scanner.c | 21 ++++++++++++++------- App/app/scanner.h | 2 +- App/ui/helper.c | 4 ++-- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/App/app/app.c b/App/app/app.c index 6820ca57..271a9696 100644 --- a/App/app/app.c +++ b/App/app/app.c @@ -2192,7 +2192,7 @@ Skip: } if (gRequestSaveChannel > 0) { // TODO: remove the gRequestSaveChannel, why use global variable for that?? - if ((!bKeyHeld && !bKeyPressed) || (UI_MENU_GetCurrentMenuId() != 0 && gScreenToDisplay == DISPLAY_MENU)) + if ((!bKeyHeld && !bKeyPressed) || (UI_MENU_GetCurrentMenuId() != 0 && gScreenToDisplay == DISPLAY_MENU) || gScreenToDisplay == DISPLAY_SCANNER) { SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_VFO, gTxVfo, gRequestSaveChannel); diff --git a/App/app/menu.c b/App/app/menu.c index c5bad9e4..5f421c4c 100644 --- a/App/app/menu.c +++ b/App/app/menu.c @@ -1553,9 +1553,9 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) UI_MENU_GetCurrentMenuId() == MENU_S_PRI_CH_1 || UI_MENU_GetCurrentMenuId() == MENU_S_PRI_CH_2 || UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME) - { // enter 3-digit channel number + { // enter 4-digit channel number - if (gInputBoxIndex < 3) + if (gInputBoxIndex < 4) { #ifdef ENABLE_VOICE gAnotherVoiceID = (VOICE_ID_t)Key; @@ -1566,7 +1566,8 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gInputBoxIndex = 0; - Value = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1; + //Value = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1; + Value = ((gInputBox[0] * 1000) + (gInputBox[1] * 100) + (gInputBox[2] * 10) + gInputBox[3]) - 1; if (IS_MR_CHANNEL(Value)) { diff --git a/App/app/scanner.c b/App/app/scanner.c index f7a0b7be..85fdb434 100644 --- a/App/app/scanner.c +++ b/App/app/scanner.c @@ -32,7 +32,7 @@ DCS_CodeType_t gScanCssResultType; uint8_t gScanCssResultCode; bool gScanSingleFrequency; // scan CTCSS/DCS codes for current frequency SCAN_SaveState_t gScannerSaveState; -uint8_t gScanChannel; +uint16_t gScanChannel; uint32_t gScanFrequency; SCAN_CssState_t gScanCssState; uint8_t gScanProgressIndicator; @@ -52,7 +52,7 @@ static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gRequestDisplayScreen = DISPLAY_SCANNER; - if (gInputBoxIndex < 3) { + if (gInputBoxIndex < 4) { #ifdef ENABLE_VOICE gAnotherVoiceID = (VOICE_ID_t)Key; #endif @@ -61,13 +61,14 @@ static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gInputBoxIndex = 0; - uint16_t chan = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1; + // uint16_t chan = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1; + uint16_t chan = ((gInputBox[0] * 1000) + (gInputBox[1] * 100) + (gInputBox[2] * 10) + gInputBox[3]) - 1; if (IS_MR_CHANNEL(chan)) { #ifdef ENABLE_VOICE gAnotherVoiceID = (VOICE_ID_t)Key; #endif gShowChPrefix = RADIO_CheckValidChannel(chan, false, 0); - gScanChannel = (uint8_t)chan; + gScanChannel = chan; return; } } @@ -207,7 +208,7 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld) gTxVfo->freq_config_TX.Code = gScanCssResultCode; } - uint8_t chan; + uint16_t chan; if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) { chan = gScanChannel; gEeprom.MrChannel[gEeprom.TX_VFO] = chan; @@ -275,10 +276,16 @@ void SCANNER_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) SCANNER_Key_MENU(bKeyPressed, bKeyHeld); break; case KEY_UP: - SCANNER_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1); + if(gEeprom.SET_NAV == 0) + SCANNER_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1); + else + SCANNER_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1); break; case KEY_DOWN: - SCANNER_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1); + if(gEeprom.SET_NAV == 0) + SCANNER_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1); + else + SCANNER_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1); break; case KEY_EXIT: SCANNER_Key_EXIT(bKeyPressed, bKeyHeld); diff --git a/App/app/scanner.h b/App/app/scanner.h index 6217ef59..be409a78 100644 --- a/App/app/scanner.h +++ b/App/app/scanner.h @@ -40,7 +40,7 @@ extern DCS_CodeType_t gScanCssResultType; extern uint8_t gScanCssResultCode; extern bool gScanSingleFrequency; extern SCAN_SaveState_t gScannerSaveState; -extern uint8_t gScanChannel; +extern uint16_t gScanChannel; extern uint32_t gScanFrequency; extern SCAN_CssState_t gScanCssState; extern uint8_t gScanProgressIndicator; diff --git a/App/ui/helper.c b/App/ui/helper.c index 408673cd..f49492c0 100644 --- a/App/ui/helper.c +++ b/App/ui/helper.c @@ -44,11 +44,11 @@ void UI_GenerateChannelString(char *pString, const uint16_t Channel) void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint16_t ChannelNumber) { if (gInputBoxIndex > 0) { - for (unsigned int i = 0; i < 3; i++) { + for (unsigned int i = 0; i < 4; i++) { pString[i] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0'; } - pString[3] = 0; + pString[4] = 0; return; }