diff --git a/App/app/main.c b/App/app/main.c index 7a3c36dd..e735d8ef 100644 --- a/App/app/main.c +++ b/App/app/main.c @@ -468,10 +468,13 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (Value > 0 && Value <= MR_CHANNELS_LIST) { - gEeprom.SCAN_LIST_DEFAULT = Value; - #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE - SETTINGS_WriteCurrentState(); - #endif + if(RADIO_CheckValidList(Value)) + { + gEeprom.SCAN_LIST_DEFAULT = Value; + #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE + SETTINGS_WriteCurrentState(); + #endif + } return; } @@ -493,10 +496,13 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) } else if (Value > 0 && Value <= MR_CHANNELS_LIST) { - gEeprom.SCAN_LIST_DEFAULT = Value; - #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE - SETTINGS_WriteCurrentState(); - #endif + if(RADIO_CheckValidList(Value)) + { + gEeprom.SCAN_LIST_DEFAULT = Value; + #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE + SETTINGS_WriteCurrentState(); + #endif + } return; } break; diff --git a/App/radio.c b/App/radio.c index a0d0d9dc..68a94789 100644 --- a/App/radio.c +++ b/App/radio.c @@ -53,6 +53,18 @@ const char gModulationStr[MODULATION_UKNOWN][4] = { #endif }; +bool RADIO_CheckValidList(uint8_t scanList) +{ + for (uint16_t i = 0; IS_MR_CHANNEL(i); i++) { + const ChannelAttributes_t att = gMR_ChannelAttributes[i]; + if(att.scanlist == scanList && att.exclude == false) + { + return true; + } + } + return false; +} + bool RADIO_CheckValidChannel(uint16_t channel, bool checkScanList, uint8_t scanList) { const ChannelAttributes_t att = gMR_ChannelAttributes[channel]; diff --git a/App/radio.h b/App/radio.h index 00088428..87899c0e 100644 --- a/App/radio.h +++ b/App/radio.h @@ -148,6 +148,7 @@ extern DCS_CodeType_t gCurrentCodeType; extern VfoState_t VfoState[2]; +bool RADIO_CheckValidList(uint8_t scanList); bool RADIO_CheckValidChannel(uint16_t channel, bool checkScanList, uint8_t scanList); uint16_t RADIO_FindNextChannel(uint16_t ChNum, int8_t Direction, bool bCheckScanList, uint8_t RadioNum); void RADIO_InitInfo(VFO_Info_t *pInfo, const uint16_t ChannelSave, const uint32_t Frequency);