From 858d983935a1ecd06b71ff5106763ad7c6883200 Mon Sep 17 00:00:00 2001 From: Dual Tachyon Date: Thu, 28 Sep 2023 10:27:04 +0100 Subject: [PATCH] Fixed scanlist behaviour. --- app/app.c | 30 ++++++++++++++++-------------- app/scanner.c | 2 +- app/scanner.h | 2 +- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/app/app.c b/app/app.c index 0e6ed6c..13f5859 100644 --- a/app/app.c +++ b/app/app.c @@ -45,7 +45,6 @@ #include "driver/st7565.h" #include "driver/system.h" #include "dtmf.h" -#include "external/printf/printf.h" #include "frequencies.h" #include "functions.h" #include "helper/battery.h" @@ -404,8 +403,8 @@ static void FREQ_NextChannel(void) static void MR_NextChannel(void) { - uint8_t Ch1 = gEeprom.SCANLIST_PRIORITY_CH1[gEeprom.SCAN_LIST_DEFAULT]; - uint8_t Ch2 = gEeprom.SCANLIST_PRIORITY_CH2[gEeprom.SCAN_LIST_DEFAULT]; + const uint8_t Ch1 = gEeprom.SCANLIST_PRIORITY_CH1[gEeprom.SCAN_LIST_DEFAULT]; + const uint8_t Ch2 = gEeprom.SCANLIST_PRIORITY_CH2[gEeprom.SCAN_LIST_DEFAULT]; uint8_t PreviousCh, Ch; bool bEnabled; @@ -429,19 +428,22 @@ static void MR_NextChannel(void) } if (gCurrentScanList == 2) { gNextMrChannel = gPreviousMrChannel; - } else { - goto Skip; + Ch = RADIO_FindNextChannel(gNextMrChannel + gScanState, gScanState, true, gEeprom.SCAN_LIST_DEFAULT); + if (Ch == 0xFF) { + return; + } + + gNextMrChannel = Ch; } + } else { + Ch = RADIO_FindNextChannel(gNextMrChannel + gScanState, gScanState, true, gEeprom.SCAN_LIST_DEFAULT); + if (Ch == 0xFF) { + return; + } + + gNextMrChannel = Ch; } - Ch = RADIO_FindNextChannel(gNextMrChannel + gScanState, gScanState, true, gEeprom.SCAN_LIST_DEFAULT); - if (Ch == 0xFF) { - return; - } - - gNextMrChannel = Ch; - -Skip: if (PreviousCh != gNextMrChannel) { gEeprom.MrChannel[gEeprom.RX_CHANNEL] = gNextMrChannel; gEeprom.ScreenChannel[gEeprom.RX_CHANNEL] = gNextMrChannel; @@ -453,7 +455,7 @@ Skip: bScanKeepFrequency = false; if (bEnabled) { gCurrentScanList++; - if (gCurrentScanList >= 2) { + if (gCurrentScanList > 2) { gCurrentScanList = 0; } } diff --git a/app/scanner.c b/app/scanner.c index c91ad29..c5355fb 100644 --- a/app/scanner.c +++ b/app/scanner.c @@ -40,7 +40,7 @@ volatile uint16_t ScanPauseDelayIn10msec; uint8_t gScanProgressIndicator; uint8_t gScanHitCount; bool gScanUseCssResult; -uint8_t gScanState; +int8_t gScanState; bool bScanKeepFrequency; static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) diff --git a/app/scanner.h b/app/scanner.h index c5f5086..2ee9d76 100644 --- a/app/scanner.h +++ b/app/scanner.h @@ -48,7 +48,7 @@ extern volatile uint16_t ScanPauseDelayIn10msec; extern uint8_t gScanProgressIndicator; extern uint8_t gScanHitCount; extern bool gScanUseCssResult; -extern uint8_t gScanState; +extern int8_t gScanState; extern bool bScanKeepFrequency; void SCANNER_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);