Scanlist refactoring

This commit is contained in:
Armel FAUVEAU
2024-06-28 22:06:19 +02:00
parent 0110f89cdb
commit 3a61d18ac7
2 changed files with 14 additions and 19 deletions

View File

@@ -558,7 +558,7 @@ static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld)
#ifdef ENABLE_FEAT_F4HWN #ifdef ENABLE_FEAT_F4HWN
// Exclude work with list 1, 2, 3 or all list // Exclude work with list 1, 2, 3 or all list
if(gScanStateDir != SCAN_OFF && (gEeprom.SCAN_LIST_DEFAULT > 0 || gEeprom.SCAN_LIST_DEFAULT < 5)) if(gScanStateDir != SCAN_OFF && (gEeprom.SCAN_LIST_DEFAULT > 0 && gEeprom.SCAN_LIST_DEFAULT < 5))
{ {
if(FUNCTION_IsRx()) if(FUNCTION_IsRx())
{ {

31
radio.c
View File

@@ -36,7 +36,6 @@
#include "radio.h" #include "radio.h"
#include "settings.h" #include "settings.h"
#include "ui/menu.h" #include "ui/menu.h"
#include "debugging.h"
VFO_Info_t *gTxVfo; VFO_Info_t *gTxVfo;
VFO_Info_t *gRxVfo; VFO_Info_t *gRxVfo;
@@ -59,11 +58,6 @@ const char gModulationStr[MODULATION_UKNOWN][4] = {
bool RADIO_CheckValidChannel(uint16_t channel, bool checkScanList, uint8_t scanList) bool RADIO_CheckValidChannel(uint16_t channel, bool checkScanList, uint8_t scanList)
{ {
//char str[64] = "";
//sprintf(str, "RADIO_CheckValidChannel channel %d / checkScanList %d / scanList %d\n", channel, checkScanList, scanList);
//LogUart(str);
// return true if the channel appears valid // return true if the channel appears valid
if (!IS_MR_CHANNEL(channel)) if (!IS_MR_CHANNEL(channel))
return false; return false;
@@ -76,10 +70,7 @@ bool RADIO_CheckValidChannel(uint16_t channel, bool checkScanList, uint8_t scanL
if (!checkScanList || scanList > 4) if (!checkScanList || scanList > 4)
return true; return true;
//sprintf(str, "scanList %d / att.scanlist1 %d / att.scanlist2 %d / att.scanlist3 %d\n", scanList, att.scanlist1, att.scanlist2, att.scanlist3); /*
//LogUart(str);
if(scanList == 0 && (att.scanlist1 == 1 || att.scanlist2 == 1 || att.scanlist3 == 1)) if(scanList == 0 && (att.scanlist1 == 1 || att.scanlist2 == 1 || att.scanlist3 == 1))
{ {
return false; return false;
@@ -100,24 +91,30 @@ bool RADIO_CheckValidChannel(uint16_t channel, bool checkScanList, uint8_t scanL
{ {
return false; return false;
} }
*/
//sprintf(str, ">>> %d\n", scanList); if ((scanList == 0 && (att.scanlist1 == 1 || att.scanlist2 == 1 || att.scanlist3 == 1)) ||
//LogUart(str); (scanList == 1 && att.scanlist1 != 1) ||
(scanList == 2 && att.scanlist2 != 1) ||
(scanList == 3 && att.scanlist3 != 1) ||
(scanList == 4 && (att.scanlist1 == 0 && att.scanlist2 == 0 && att.scanlist3 == 0))) {
return false;
}
return true; return true;
/*
// I don't understand what this code is for...
const uint8_t PriorityCh1 = gEeprom.SCANLIST_PRIORITY_CH1[scanList]; const uint8_t PriorityCh1 = gEeprom.SCANLIST_PRIORITY_CH1[scanList];
const uint8_t PriorityCh2 = gEeprom.SCANLIST_PRIORITY_CH2[scanList]; const uint8_t PriorityCh2 = gEeprom.SCANLIST_PRIORITY_CH2[scanList];
return PriorityCh1 != channel && PriorityCh2 != channel; return PriorityCh1 != channel && PriorityCh2 != channel;
*/
} }
uint8_t RADIO_FindNextChannel(uint8_t Channel, int8_t Direction, bool bCheckScanList, uint8_t VFO) uint8_t RADIO_FindNextChannel(uint8_t Channel, int8_t Direction, bool bCheckScanList, uint8_t VFO)
{ {
//char str[64] = "";
//sprintf(str, "RADIO_FindNextChannel Channel %d / VFO %d\n", Channel, VFO);
//LogUart(str);
for (unsigned int i = 0; IS_MR_CHANNEL(i); i++, Channel += Direction) { for (unsigned int i = 0; IS_MR_CHANNEL(i); i++, Channel += Direction) {
if (Channel == 0xFF) { if (Channel == 0xFF) {
Channel = MR_CHANNEL_LAST; Channel = MR_CHANNEL_LAST;
@@ -128,8 +125,6 @@ uint8_t RADIO_FindNextChannel(uint8_t Channel, int8_t Direction, bool bCheckScan
if (RADIO_CheckValidChannel(Channel, bCheckScanList, VFO)) { if (RADIO_CheckValidChannel(Channel, bCheckScanList, VFO)) {
return Channel; return Channel;
} }
//sprintf(str, "VFO %d...\n", VFO);
//LogUart(str);
} }
return 0xFF; return 0xFF;