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