From e77b87f1f271cbcb862f998e5594d61788d7437b Mon Sep 17 00:00:00 2001 From: mrkusypl Date: Fri, 24 Apr 2026 00:09:38 +0200 Subject: [PATCH] Another code refactoring (40 B) --- App/app/app.c | 40 ++++++++++++++++++++-------------------- App/app/app.h | 1 + App/app/generic.c | 14 +------------- 3 files changed, 22 insertions(+), 33 deletions(-) diff --git a/App/app/app.c b/App/app/app.c index edd3695c..7cfa3ca3 100644 --- a/App/app/app.c +++ b/App/app/app.c @@ -812,6 +812,22 @@ void APP_EndTransmission(void) } } +void APP_HandleEndTransmission(void) { + if (gFlagEndTransmission) { + FUNCTION_Select(FUNCTION_FOREGROUND); + } + else { + APP_EndTransmission(); + + if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) + FUNCTION_Select(FUNCTION_FOREGROUND); + else + gRTTECountdown_10ms = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; + } + + gFlagEndTransmission = false; +} + #ifdef ENABLE_VOX static void HandleVox(void) { @@ -847,24 +863,10 @@ static void HandleVox(void) gVOX_NoiseDetected = false; if (gCurrentFunction == FUNCTION_TRANSMIT && !gPttIsPressed && !gVOX_NoiseDetected) { - if (gFlagEndTransmission) { - //if (gCurrentFunction != FUNCTION_FOREGROUND) - FUNCTION_Select(FUNCTION_FOREGROUND); - } - else { - APP_EndTransmission(); - - if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) { - //if (gCurrentFunction != FUNCTION_FOREGROUND) - FUNCTION_Select(FUNCTION_FOREGROUND); - } - else - gRTTECountdown_10ms = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; - } + APP_HandleEndTransmission(); gUpdateStatus = true; gUpdateDisplay = true; - gFlagEndTransmission = false; } return; } @@ -1942,12 +1944,10 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) bool lowBatPopup = gLowBattery && !gLowBatteryConfirmed && gScreenToDisplay == DISPLAY_MAIN; #ifdef ENABLE_FEAT_F4HWN // Disable PTT if KEY_LOCK - bool lck_condition = false; + bool lck_condition = (gEeprom.KEY_LOCK || lowBatPopup) && gCurrentFunction != FUNCTION_TRANSMIT; - if(gSetting_set_lck) - lck_condition = (gEeprom.KEY_LOCK || lowBatPopup) && gCurrentFunction != FUNCTION_TRANSMIT; - else - lck_condition = (gEeprom.KEY_LOCK || lowBatPopup) && gCurrentFunction != FUNCTION_TRANSMIT && Key != KEY_PTT; + if(!gSetting_set_lck) + lck_condition = lck_condition && Key != KEY_PTT; if (lck_condition) #else diff --git a/App/app/app.h b/App/app/app.h index 20b7c857..2beb26e1 100644 --- a/App/app/app.h +++ b/App/app/app.h @@ -24,6 +24,7 @@ #include "radio.h" void APP_EndTransmission(void); +void APP_HandleEndTransmission(void); void APP_StartListening(FUNCTION_Type_t function); uint32_t APP_SetFreqByStepAndLimits(VFO_Info_t *pInfo, int8_t direction, uint32_t lower, uint32_t upper); uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t direction); diff --git a/App/app/generic.c b/App/app/generic.c index de42899d..f6c907a2 100644 --- a/App/app/generic.c +++ b/App/app/generic.c @@ -103,20 +103,8 @@ void GENERIC_Key_PTT(bool bKeyPressed) if (!bKeyPressed || SerialConfigInProgress()) { // PTT released if (gCurrentFunction == FUNCTION_TRANSMIT) { - // we are transmitting .. stop - if (gFlagEndTransmission) { - FUNCTION_Select(FUNCTION_FOREGROUND); - } - else { - APP_EndTransmission(); + APP_HandleEndTransmission(); - if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) - FUNCTION_Select(FUNCTION_FOREGROUND); - else - gRTTECountdown_10ms = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; - } - - gFlagEndTransmission = false; #ifdef ENABLE_VOX gVOX_NoiseDetected = false; #endif