From 7e6a78ab6ccc5ca96aea1062d489e0c3192032e0 Mon Sep 17 00:00:00 2001 From: Krzysiek Egzmont Date: Thu, 12 Oct 2023 00:44:52 +0200 Subject: [PATCH] FIX #26: vfo state (TX DISABLE label) update issue when FM radio disabled in Makefile --- app/app.c | 30 +++++++++++++++--------------- app/fm.c | 1 - app/fm.h | 1 - misc.c | 5 ++++- misc.h | 4 +++- radio.c | 9 ++------- ui/main.c | 3 +-- 7 files changed, 25 insertions(+), 28 deletions(-) diff --git a/app/app.c b/app/app.c index 04d8c2a..dc958f8 100644 --- a/app/app.c +++ b/app/app.c @@ -1895,24 +1895,24 @@ void APP_TimeSlice500ms(void) if (gCurrentFunction != FUNCTION_POWER_SAVE && gCurrentFunction != FUNCTION_TRANSMIT) updateRSSI(gEeprom.RX_VFO); - #ifdef ENABLE_FMRADIO - if (!gPttIsPressed && gFM_ResumeCountdown_500ms > 0) + if (!gPttIsPressed && gVFOStateResumeCountdown_500ms > 0) + { + if (--gVFOStateResumeCountdown_500ms == 0) { - if (--gFM_ResumeCountdown_500ms == 0) - { - RADIO_SetVfoState(VFO_STATE_NORMAL); - - if (gCurrentFunction != FUNCTION_RECEIVE && - gCurrentFunction != FUNCTION_TRANSMIT && - gCurrentFunction != FUNCTION_MONITOR && - gFmRadioMode) - { // switch back to FM radio mode - FM_Start(); - GUI_SelectNextDisplay(DISPLAY_FM); - } + RADIO_SetVfoState(VFO_STATE_NORMAL); +#ifdef ENABLE_FMRADIO + if (gCurrentFunction != FUNCTION_RECEIVE && + gCurrentFunction != FUNCTION_TRANSMIT && + gCurrentFunction != FUNCTION_MONITOR && + gFmRadioMode) + { // switch back to FM radio mode + FM_Start(); + GUI_SelectNextDisplay(DISPLAY_FM); } +#endif } - #endif + } + if (gLowBattery) { diff --git a/app/fm.c b/app/fm.c index d91259c..2da0da0 100644 --- a/app/fm.c +++ b/app/fm.c @@ -45,7 +45,6 @@ bool gFM_AutoScan; uint8_t gFM_ChannelPosition; bool gFM_FoundFrequency; bool gFM_AutoScan; -uint8_t gFM_ResumeCountdown_500ms; uint16_t gFM_RestoreCountdown_10ms; bool FM_CheckValidChannel(uint8_t Channel) diff --git a/app/fm.h b/app/fm.h index 012119a..1e19348 100644 --- a/app/fm.h +++ b/app/fm.h @@ -39,7 +39,6 @@ extern uint8_t gFM_ChannelPosition; extern uint16_t gFM_FrequencyDeviation; extern bool gFM_FoundFrequency; extern bool gFM_AutoScan; -extern uint8_t gFM_ResumeCountdown_500ms; extern uint16_t gFM_RestoreCountdown_10ms; bool FM_CheckValidChannel(uint8_t Channel); diff --git a/misc.c b/misc.c index d4ec9f2..0f4d51a 100644 --- a/misc.c +++ b/misc.c @@ -19,12 +19,13 @@ #include "misc.h" #include "settings.h" -const uint8_t fm_resume_countdown_500ms = 2500 / 500; // 2.5 seconds const uint8_t fm_radio_countdown_500ms = 2000 / 500; // 2 seconds const uint16_t fm_play_countdown_scan_10ms = 100 / 10; // 100ms const uint16_t fm_play_countdown_noscan_10ms = 1200 / 10; // 1.2 seconds const uint16_t fm_restore_countdown_10ms = 5000 / 10; // 5 seconds +const uint8_t vfo_state_resume_countdown_500ms = 2500 / 500; // 2.5 seconds + const uint8_t menu_timeout_500ms = 20000 / 500; // 20 seconds const uint16_t menu_timeout_long_500ms = 120000 / 500; // 2 minutes @@ -141,6 +142,8 @@ volatile bool gTxTimeoutReached; volatile uint16_t gTailNoteEliminationCountdown_10ms; +volatile uint8_t gVFOStateResumeCountdown_500ms; + #ifdef ENABLE_NOAA volatile uint16_t gNOAA_Countdown_10ms; #endif diff --git a/misc.h b/misc.h index 61c42c4..df4d91a 100644 --- a/misc.h +++ b/misc.h @@ -93,12 +93,13 @@ enum scan_next_chan_t { }; typedef enum scan_next_chan_t scan_next_chan_t; -extern const uint8_t fm_resume_countdown_500ms; extern const uint8_t fm_radio_countdown_500ms; extern const uint16_t fm_play_countdown_scan_10ms; extern const uint16_t fm_play_countdown_noscan_10ms; extern const uint16_t fm_restore_countdown_10ms; +extern const uint8_t vfo_state_resume_countdown_500ms; + extern const uint8_t menu_timeout_500ms; extern const uint16_t menu_timeout_long_500ms; @@ -319,6 +320,7 @@ extern volatile bool gNextTimeslice40ms; extern volatile bool gScheduleNOAA; #endif extern volatile bool gFlagTailNoteEliminationComplete; +extern volatile uint8_t gVFOStateResumeCountdown_500ms; #ifdef ENABLE_FMRADIO extern volatile bool gScheduleFM; #endif diff --git a/radio.c b/radio.c index d344742..4ec19fc 100644 --- a/radio.c +++ b/radio.c @@ -898,10 +898,7 @@ void RADIO_SetVfoState(VfoState_t State) { VfoState[0] = VFO_STATE_NORMAL; VfoState[1] = VFO_STATE_NORMAL; - - #ifdef ENABLE_FMRADIO - gFM_ResumeCountdown_500ms = 0; - #endif + gVFOStateResumeCountdown_500ms = 0; } else { @@ -916,9 +913,7 @@ void RADIO_SetVfoState(VfoState_t State) VfoState[vfo] = State; } - #ifdef ENABLE_FMRADIO - gFM_ResumeCountdown_500ms = fm_resume_countdown_500ms; - #endif + gVFOStateResumeCountdown_500ms = vfo_state_resume_countdown_500ms; } gUpdateDisplay = true; diff --git a/ui/main.c b/ui/main.c index fa0ef7d..376e852 100644 --- a/ui/main.c +++ b/ui/main.c @@ -323,7 +323,6 @@ void UI_DisplayMain(void) uint8_t *p_line0 = gFrameBuffer[line + 0]; uint8_t *p_line1 = gFrameBuffer[line + 1]; unsigned int mode = 0; - unsigned int state; if (single_vfo) { // we're in single VFO mode - screen is dedicated to just one VFO @@ -472,7 +471,7 @@ void UI_DisplayMain(void) // ************ - state = VfoState[vfo_num]; + unsigned int state = VfoState[vfo_num]; #ifdef ENABLE_ALARM if (gCurrentFunction == FUNCTION_TRANSMIT && gAlarmState == ALARM_STATE_ALARM)