Reduce nesting

This commit is contained in:
Juan Antonio
2023-12-25 01:33:55 +01:00
committed by Krzysiek Egzmont
parent 8f6e1be5e0
commit 36ecde86e9

102
app/app.c
View File

@@ -203,13 +203,14 @@ static void HandleIncoming(void)
return; return;
#ifdef ENABLE_DTMF_CALLING #ifdef ENABLE_DTMF_CALLING
if (gScanStateDir == SCAN_OFF) { // not scanning if (gScanStateDir == SCAN_OFF && (gRxVfo->DTMF_DECODING_ENABLE || gSetting_KILLED)) {
if (gRxVfo->DTMF_DECODING_ENABLE || gSetting_KILLED) { // DTMF DCD is enabled
// DTMF DCD is enabled
DTMF_HandleRequest(); DTMF_HandleRequest();
if (gDTMF_CallState == DTMF_CALL_STATE_NONE) { if (gDTMF_CallState == DTMF_CALL_STATE_NONE) {
if (gRxReceptionMode == RX_MODE_DETECTED) { if (gRxReceptionMode != RX_MODE_DETECTED) {
return;
}
gDualWatchCountdown_10ms = dual_watch_count_after_1_10ms; gDualWatchCountdown_10ms = dual_watch_count_after_1_10ms;
gScheduleDualWatch = false; gScheduleDualWatch = false;
@@ -220,11 +221,9 @@ static void HandleIncoming(void)
gUpdateStatus = true; gUpdateStatus = true;
gUpdateDisplay = true; gUpdateDisplay = true;
}
return; return;
} }
} }
}
#endif #endif
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE); APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE);
@@ -727,6 +726,8 @@ void APP_EndTransmission(void)
// back to RX mode // back to RX mode
RADIO_SendEndOfTransmission(); RADIO_SendEndOfTransmission();
gFlagEndTransmission = true;
if (gMonitor) { if (gMonitor) {
//turn the monitor back on //turn the monitor back on
gFlagReconfigureVfos = true; gFlagReconfigureVfos = true;
@@ -829,7 +830,6 @@ void APP_Update(void)
{ // transmitter timed out or must de-key { // transmitter timed out or must de-key
gTxTimeoutReached = false; gTxTimeoutReached = false;
gFlagEndTransmission = true;
APP_EndTransmission(); APP_EndTransmission();
AUDIO_PlayBeep(BEEP_880HZ_60MS_TRIPLE_BEEP); AUDIO_PlayBeep(BEEP_880HZ_60MS_TRIPLE_BEEP);
@@ -1356,17 +1356,14 @@ void APP_TimeSlice500ms(void)
} }
#endif #endif
if (gBacklightCountdown_500ms > 0 && !gAskToSave && !gCssBackgroundScan && if (gBacklightCountdown_500ms > 0 && !gAskToSave && !gCssBackgroundScan
// don't turn off backlight if user is in backlight menu option // don't turn off backlight if user is in backlight menu option
!(gScreenToDisplay == DISPLAY_MENU && (UI_MENU_GetCurrentMenuId() == MENU_ABR || UI_MENU_GetCurrentMenuId() == MENU_ABR_MAX))) && !(gScreenToDisplay == DISPLAY_MENU && (UI_MENU_GetCurrentMenuId() == MENU_ABR || UI_MENU_GetCurrentMenuId() == MENU_ABR_MAX))
{ && --gBacklightCountdown_500ms == 0
if (--gBacklightCountdown_500ms == 0) { && gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1)
if (gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1)) { ) {
// backlight is not set to be always on
BACKLIGHT_TurnOff(); BACKLIGHT_TurnOff();
} }
}
}
if (gReducedService) if (gReducedService)
{ {
@@ -1411,38 +1408,33 @@ void APP_TimeSlice500ms(void)
#endif #endif
} }
if (!gCssBackgroundScan if (!gCssBackgroundScan && gScanStateDir == SCAN_OFF && !SCANNER_IsScanning()
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
&& (gFM_ScanState == FM_SCAN_OFF || gAskToSave) && (gFM_ScanState == FM_SCAN_OFF || gAskToSave)
#endif #endif
) {
if (gScanStateDir == SCAN_OFF && !SCANNER_IsScanning()
#ifdef ENABLE_AIRCOPY #ifdef ENABLE_AIRCOPY
&& gScreenToDisplay != DISPLAY_AIRCOPY && gScreenToDisplay != DISPLAY_AIRCOPY
#endif #endif
) { ) {
if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode && gScreenToDisplay != DISPLAY_MENU) { if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode
if (--gKeyLockCountdown == 0) { && gScreenToDisplay != DISPLAY_MENU && --gKeyLockCountdown == 0)
{
gEeprom.KEY_LOCK = true; // lock the keyboard gEeprom.KEY_LOCK = true; // lock the keyboard
gUpdateStatus = true; // lock symbol needs showing gUpdateStatus = true; // lock symbol needs showing
} }
} if (exit_menu) {
if (exit_menu)
{
gMenuCountdown = 0; gMenuCountdown = 0;
if (gEeprom.BACKLIGHT_TIME == 0) // backlight always off if (gEeprom.BACKLIGHT_TIME == 0) {
{ BACKLIGHT_TurnOff();
BACKLIGHT_TurnOff(); // turn the backlight OFF
} }
if (gInputBoxIndex > 0 || gDTMF_InputMode) if (gInputBoxIndex > 0 || gDTMF_InputMode) {
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
}
/* /*
if (SCANNER_IsScanning()) if (SCANNER_IsScanning()) {
{
BK4819_StopScan(); BK4819_StopScan();
RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD); RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD);
@@ -1470,26 +1462,21 @@ void APP_TimeSlice500ms(void)
} }
#endif #endif
if (disp == DISPLAY_INVALID) { if (disp == DISPLAY_INVALID
#ifndef ENABLE_NO_CODE_SCAN_TIMEOUT #ifndef ENABLE_NO_CODE_SCAN_TIMEOUT
if (!SCANNER_IsScanning()) && !SCANNER_IsScanning()
#endif #endif
{ ) {
disp = DISPLAY_MAIN; disp = DISPLAY_MAIN;
} }
}
if (disp != DISPLAY_INVALID) { if (disp != DISPLAY_INVALID) {
GUI_SelectNextDisplay(disp); GUI_SelectNextDisplay(disp);
} }
} }
} }
}
if (!gPttIsPressed && gVFOStateResumeCountdown_500ms > 0) if (!gPttIsPressed && gVFOStateResumeCountdown_500ms > 0 && --gVFOStateResumeCountdown_500ms == 0) {
{
if (--gVFOStateResumeCountdown_500ms == 0)
{
RADIO_SetVfoState(VFO_STATE_NORMAL); RADIO_SetVfoState(VFO_STATE_NORMAL);
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gFmRadioMode && !FUNCTION_IsRx()) { if (gFmRadioMode && !FUNCTION_IsRx()) {
@@ -1499,49 +1486,38 @@ void APP_TimeSlice500ms(void)
} }
#endif #endif
} }
}
BATTERY_TimeSlice500ms(); BATTERY_TimeSlice500ms();
SCANNER_TimeSlice500ms(); SCANNER_TimeSlice500ms();
UI_MAIN_TimeSlice500ms(); UI_MAIN_TimeSlice500ms();
#ifdef ENABLE_DTMF_CALLING #ifdef ENABLE_DTMF_CALLING
if (gCurrentFunction != FUNCTION_TRANSMIT) if (gCurrentFunction != FUNCTION_TRANSMIT) {
{ if (gDTMF_DecodeRingCountdown_500ms > 0) {
if (gDTMF_DecodeRingCountdown_500ms > 0) // make "ring-ring" sound
{ // make "ring-ring" sound
gDTMF_DecodeRingCountdown_500ms--; gDTMF_DecodeRingCountdown_500ms--;
AUDIO_PlayBeep(BEEP_880HZ_200MS); AUDIO_PlayBeep(BEEP_880HZ_200MS);
} }
} } else {
else
gDTMF_DecodeRingCountdown_500ms = 0; gDTMF_DecodeRingCountdown_500ms = 0;
}
if (gDTMF_CallState != DTMF_CALL_STATE_NONE && if (gDTMF_CallState != DTMF_CALL_STATE_NONE && gCurrentFunction != FUNCTION_TRANSMIT
gCurrentFunction != FUNCTION_TRANSMIT && && gCurrentFunction != FUNCTION_RECEIVE && gDTMF_auto_reset_time_500ms > 0
gCurrentFunction != FUNCTION_RECEIVE) && --gDTMF_auto_reset_time_500ms == 0)
{ {
if (gDTMF_auto_reset_time_500ms > 0)
{
if (--gDTMF_auto_reset_time_500ms == 0)
{
if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED && gEeprom.DTMF_auto_reset_time >= DTMF_HOLD_MAX)
gDTMF_CallState = DTMF_CALL_STATE_RECEIVED_STAY; // keep message on-screen till a key is pressed
else
gDTMF_CallState = DTMF_CALL_STATE_NONE;
gUpdateDisplay = true; gUpdateDisplay = true;
} if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED && gEeprom.DTMF_auto_reset_time >= DTMF_HOLD_MAX) {
gDTMF_CallState = DTMF_CALL_STATE_RECEIVED_STAY; // keep message on-screen till a key is pressed
} else {
gDTMF_CallState = DTMF_CALL_STATE_NONE;
} }
} }
if (gDTMF_IsTx && gDTMF_TxStopCountdown_500ms > 0) if (gDTMF_IsTx && gDTMF_TxStopCountdown_500ms > 0 && --gDTMF_TxStopCountdown_500ms == 0) {
{
if (--gDTMF_TxStopCountdown_500ms == 0)
{
gDTMF_IsTx = false; gDTMF_IsTx = false;
gUpdateDisplay = true; gUpdateDisplay = true;
} }
}
#endif #endif
} }