Simplify gSchedulePowerSave logic

There was quite convoluted logic there, and what I believe, was a bug.

Rationale:

Both,
- gBatterySaveCountdown_10ms = battery_save_count_10ms;, and
- gSchedulePowerSave = false
are always executed inside FUNCTION_Select().

So the code is equivalent to:

if (any of those OR'd) {
	gBatterySaveCountdown_10ms = battery_save_count_10ms;
	gSchedulePowerSave = false; (but only if we have NOAA disabled)
} else {
	[other stuff from FUNCTION_Select()]
	gBatterySaveCountdown_10ms = battery_save_count_10ms;
	gSchedulePowerSave = false; (regarless of having NOAA or not)
}

So:
- OR is true, have NOAA-> don't clear gSchedulePowerSave
	-> implies we will enter here, again, until the OR is false, but only if we have NOAA.
- OR is False -> clear gSchedulePowerSave.

Moreover, checking with DualTachyon code at
6f8afac886/app/app.c (L747)
gSchedulePowerSave is always set to false if it was true.
This commit is contained in:
Juan Antonio
2023-12-22 21:06:57 +01:00
committed by egzumer
parent a08420a0b7
commit 6f1cabc807

View File

@@ -926,46 +926,35 @@ void APP_Update(void)
#endif #endif
if (gSchedulePowerSave) { if (gSchedulePowerSave) {
if (gPttIsPressed || if (gPttIsPressed
gKeyBeingHeld || || gKeyBeingHeld
gEeprom.BATTERY_SAVE == 0 || || gEeprom.BATTERY_SAVE == 0
gScanStateDir != SCAN_OFF || || gScanStateDir != SCAN_OFF
gCssBackgroundScan || || gCssBackgroundScan
gScreenToDisplay != DISPLAY_MAIN || gScreenToDisplay != DISPLAY_MAIN
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
|| gFmRadioMode || gFmRadioMode
#endif #endif
#ifdef ENABLE_DTMF_CALLING #ifdef ENABLE_DTMF_CALLING
|| gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_CallState != DTMF_CALL_STATE_NONE
#endif #endif
){
gBatterySaveCountdown_10ms = battery_save_count_10ms;
}
else
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if ((!IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && !IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode) || (gIsNoaaMode && (IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) || IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1])))
#endif #endif
{ ) {
//if (gCurrentFunction != FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_POWER_SAVE);
}
#ifdef ENABLE_NOAA
else
{
gBatterySaveCountdown_10ms = battery_save_count_10ms; gBatterySaveCountdown_10ms = battery_save_count_10ms;
} else {
FUNCTION_Select(FUNCTION_POWER_SAVE);
} }
#else
gSchedulePowerSave = false;
#endif
}
gSchedulePowerSave = false;
}
if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
&& gVoiceWriteIndex == 0 && gVoiceWriteIndex == 0
#endif #endif
) ) {
{
static bool goToSleep; static bool goToSleep;
// wake up, enable RX then go back to sleep // wake up, enable RX then go back to sleep
if (gRxIdleMode) if (gRxIdleMode)