From 25ced9401ed963831ac9fac39d6503e311df303e Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Tue, 26 Mar 2024 00:34:04 +0100 Subject: [PATCH] Add exclude memory channel --- app/chFrScanner.c | 16 +++++++++++++++- app/chFrScanner.h | 5 +++++ app/main.c | 24 ++++++++++++++++++++++++ app/scanner.c | 12 +----------- misc.c | 1 + misc.h | 2 +- settings.c | 8 ++++++++ 7 files changed, 55 insertions(+), 13 deletions(-) diff --git a/app/chFrScanner.c b/app/chFrScanner.c index 4d7f844..6aba97c 100644 --- a/app/chFrScanner.c +++ b/app/chFrScanner.c @@ -25,7 +25,13 @@ typedef enum { scan_next_chan_t currentScanList; uint32_t initialFrqOrChan; uint8_t initialCROSS_BAND_RX_TX; -uint32_t lastFoundFrqOrChan; + +#ifndef ENABLE_FEAT_F4HWN + uint32_t lastFoundFrqOrChan; +#else + uint32_t lastFoundFrqOrChan; + uint32_t lastFoundFrqOrChanOld; +#endif static void NextFreqChannel(void); static void NextMemChannel(void); @@ -61,6 +67,10 @@ void CHFRSCANNER_Start(const bool storeBackupSettings, const int8_t scan_directi NextFreqChannel(); } +#ifdef ENABLE_FEAT_F4HWN + lastFoundFrqOrChanOld = lastFoundFrqOrChan; +#endif + gScanPauseDelayIn_10ms = scan_pause_delay_in_2_10ms; gScheduleScanListen = false; gRxReceptionMode = RX_MODE_NONE; @@ -109,6 +119,10 @@ void CHFRSCANNER_Found(void) break; } +#ifdef ENABLE_FEAT_F4HWN + lastFoundFrqOrChanOld = lastFoundFrqOrChan; +#endif + if (IS_MR_CHANNEL(gRxVfo->CHANNEL_SAVE)) { //memory scan lastFoundFrqOrChan = gRxVfo->CHANNEL_SAVE; } diff --git a/app/chFrScanner.h b/app/chFrScanner.h index 4038461..484b726 100644 --- a/app/chFrScanner.h +++ b/app/chFrScanner.h @@ -20,4 +20,9 @@ void CHFRSCANNER_Stop(void); void CHFRSCANNER_Start(const bool storeBackupSettings, const int8_t scan_direction); void CHFRSCANNER_ContinueScanning(void); +#ifdef ENABLE_FEAT_F4HWN + extern uint32_t lastFoundFrqOrChan; + extern uint32_t lastFoundFrqOrChanOld; +#endif + #endif \ No newline at end of file diff --git a/app/main.c b/app/main.c index b4301ae..e7d84e1 100644 --- a/app/main.c +++ b/app/main.c @@ -540,6 +540,30 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; if (bKeyHeld) { // menu key held down (long press) + + #ifdef ENABLE_FEAT_F4HWN + if(gScanStateDir != SCAN_OFF) + { + gTxVfo->SCANLIST1_PARTICIPATION = 0; + gTxVfo->SCANLIST2_PARTICIPATION = 0; + + gWriteChannel = false; + SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true); + gWriteChannel = true; + + gVfoConfigureMode = VFO_CONFIGURE; + gFlagResetVfos = true; + + //gDebug = (uint8_t)lastFoundFrqOrChanOld; + + lastFoundFrqOrChan = lastFoundFrqOrChanOld; + + CHFRSCANNER_ContinueScanning(); + + return; + } + #endif + if (bKeyPressed) { // long press MENU key gWasFKeyPressed = false; diff --git a/app/scanner.c b/app/scanner.c index 1bd0d55..6ef6108 100644 --- a/app/scanner.c +++ b/app/scanner.c @@ -41,7 +41,6 @@ bool gScanUseCssResult; STEP_Setting_t stepSetting; uint8_t scanHitCount; - static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { if (!bKeyHeld && bKeyPressed) @@ -259,16 +258,7 @@ static void SCANNER_Key_UP_DOWN(bool bKeyPressed, bool pKeyHeld, int8_t Directio void SCANNER_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { switch (Key) { - case KEY_0: - case KEY_1: - case KEY_2: - case KEY_3: - case KEY_4: - case KEY_5: - case KEY_6: - case KEY_7: - case KEY_8: - case KEY_9: + case KEY_0...KEY_9: SCANNER_Key_DIGITS(Key, bKeyPressed, bKeyHeld); break; case KEY_MENU: diff --git a/misc.c b/misc.c index c6fc797..42e904e 100644 --- a/misc.c +++ b/misc.c @@ -116,6 +116,7 @@ enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx; bool gSetting_set_gui = 0; bool gSetting_set_ptt_session; uint8_t gDebug; + bool gWriteChannel = true; #endif #ifdef ENABLE_AUDIO_BAR diff --git a/misc.h b/misc.h index f3828d7..28595b4 100644 --- a/misc.h +++ b/misc.h @@ -350,7 +350,7 @@ extern volatile uint8_t boot_counter_10ms; extern uint8_t gPttOnePushCounter; extern uint32_t gBlinkCounter; extern uint8_t gDebug; - + extern bool gWriteChannel; #endif int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit); diff --git a/settings.c b/settings.c index 2481cb5..04301b3 100644 --- a/settings.c +++ b/settings.c @@ -776,7 +776,15 @@ void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep) } state[channel & 7u] = att.__val; + +#ifdef ENABLE_FEAT_F4HWN + if(gWriteChannel) + { + EEPROM_WriteBuffer(offset, state); + } +#else EEPROM_WriteBuffer(offset, state); +#endif gMR_ChannelAttributes[channel] = att;