diff --git a/app/app.c b/app/app.c index 1548d18..d0611cc 100644 --- a/app/app.c +++ b/app/app.c @@ -882,9 +882,9 @@ void APP_TimeSlice10ms(void) } } } - if (gFmRadioMode && g_2000038E) { - g_2000038E--; - if (g_2000038E == 0) { + if (gFmRadioMode && gFM_RestoreCountdown) { + gFM_RestoreCountdown--; + if (gFM_RestoreCountdown == 0) { FM_Start(); GUI_SelectNextDisplay(DISPLAY_FM); } diff --git a/app/fm.c b/app/fm.c index f671297..31204e6 100644 --- a/app/fm.c +++ b/app/fm.c @@ -39,6 +39,7 @@ uint8_t gFM_ChannelPosition; bool gFM_FoundFrequency; bool gFM_AutoScan; uint8_t gFM_ResumeCountdown; +uint16_t gFM_RestoreCountdown; bool FM_CheckValidChannel(uint8_t Channel) { @@ -86,7 +87,7 @@ void FM_TurnOff(void) { gFmRadioMode = false; gFM_ScanState = FM_SCAN_OFF; - g_2000038E = 0; + gFM_RestoreCountdown = 0; GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); gEnableSpeaker = false; BK1080_Init(0, false); @@ -530,7 +531,7 @@ void FM_Start(void) { gFmRadioMode = true; gFM_ScanState = FM_SCAN_OFF; - g_2000038E = 0; + gFM_RestoreCountdown = 0; BK1080_Init(gEeprom.FM_FrequencyPlaying, true); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); gEnableSpeaker = true; diff --git a/app/fm.h b/app/fm.h index 5450efc..1c0b9e8 100644 --- a/app/fm.h +++ b/app/fm.h @@ -38,6 +38,7 @@ extern uint16_t gFM_FrequencyDeviation; extern bool gFM_FoundFrequency; extern bool gFM_AutoScan; extern uint8_t gFM_ResumeCountdown; +extern uint16_t gFM_RestoreCountdown; bool FM_CheckValidChannel(uint8_t Channel); uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction); diff --git a/functions.c b/functions.c index 0bbe1b1..3c23afd 100644 --- a/functions.c +++ b/functions.c @@ -69,6 +69,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function) { FUNCTION_Type_t PreviousFunction; bool bWasPowerSave; + uint16_t Countdown = 0; PreviousFunction = gCurrentFunction; bWasPowerSave = (PreviousFunction == FUNCTION_POWER_SAVE); @@ -92,22 +93,17 @@ void FUNCTION_Select(FUNCTION_Type_t Function) gVFO_RSSI_Level[1] = 0; } else if (PreviousFunction == FUNCTION_RECEIVE) { if (gFmRadioMode) { - g_2000038E = 500; + Countdown = 500; } if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED) { gDTMF_AUTO_RESET_TIME = 1 + (gEeprom.DTMF_AUTO_RESET_TIME * 2); } } - gBatterySaveCountdown = 1000; - gSchedulePowerSave = false; - break; + return; case FUNCTION_MONITOR: case FUNCTION_INCOMING: case FUNCTION_RECEIVE: - gBatterySaveCountdown = 1000; - gSchedulePowerSave = false; - g_2000038E = 0; break; case FUNCTION_POWER_SAVE: @@ -119,7 +115,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function) gBatterySaveCountdownExpired = false; gUpdateStatus = true; GUI_SelectNextDisplay(DISPLAY_MAIN); - break; + return; case FUNCTION_TRANSMIT: if (gFmRadioMode) { @@ -137,9 +133,6 @@ void FUNCTION_Select(FUNCTION_Type_t Function) gEnableSpeaker = true; SYSTEM_DelayMs(60); BK4819_ExitTxMute(); - gBatterySaveCountdown = 1000; - gSchedulePowerSave = false; - g_2000038E = 0; gAlarmToneCounter = 0; break; } @@ -159,24 +152,18 @@ void FUNCTION_Select(FUNCTION_Type_t Function) SYSTEM_DelayMs(2); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); gAlarmToneCounter = 0; - g_2000038E = 0; gEnableSpeaker = true; - gSchedulePowerSave = false; - gBatterySaveCountdown = 1000; - return; + break; } if (gCurrentVfo->SCRAMBLING_TYPE && gSetting_ScrambleEnable) { BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1U); - gBatterySaveCountdown = 1000; - gSchedulePowerSave = false; - g_2000038E = 0; - return; + } else { + BK4819_DisableScramble(); } - BK4819_DisableScramble(); - gBatterySaveCountdown = 1000; - gSchedulePowerSave = false; - g_2000038E = 0; + break; } + gBatterySaveCountdown = 1000; + gSchedulePowerSave = false; + gFM_RestoreCountdown = Countdown; } - diff --git a/misc.c b/misc.c index 0623d05..0b6d516 100644 --- a/misc.c +++ b/misc.c @@ -72,7 +72,6 @@ uint8_t gBatteryVoltageIndex; CssScanMode_t gCssScanMode; bool gUpdateRSSI; AlarmState_t gAlarmState; -uint16_t g_2000038E; uint8_t g_20000393; bool gPttWasReleased; bool gPttWasPressed; diff --git a/misc.h b/misc.h index 2d512eb..0b01d44 100644 --- a/misc.h +++ b/misc.h @@ -123,7 +123,6 @@ extern uint8_t gBatteryVoltageIndex; extern CssScanMode_t gCssScanMode; extern bool gUpdateRSSI; extern AlarmState_t gAlarmState; -extern uint16_t g_2000038E; extern uint8_t g_20000393; extern bool gPttWasReleased; extern bool gPttWasPressed;