From e5659ad6abc93cafb63517e37342c607fd7a40b6 Mon Sep 17 00:00:00 2001 From: Krzysiek Egzmont Date: Wed, 6 Dec 2023 20:36:15 +0100 Subject: [PATCH] Fix battery save broken in last commits --- app/app.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/app.c b/app/app.c index e5378ec..1886c32 100644 --- a/app/app.c +++ b/app/app.c @@ -945,13 +945,15 @@ void APP_Update(void) #endif } -#ifdef ENABLE_VOICE - if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE && gVoiceWriteIndex == 0) -#else - if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE) -#endif - { // wake up, enable RX then go back to sleep + if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE +#ifdef ENABLE_VOICE + && gVoiceWriteIndex == 0 +#endif + ) + { + static bool goToSleep; + // wake up, enable RX then go back to sleep if (gRxIdleMode) { BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable(); @@ -966,6 +968,7 @@ void APP_Update(void) !gCssBackgroundScan) { // dual watch mode, toggle between the two VFO's DualwatchAlternate(); + goToSleep = false; } FUNCTION_Init(); @@ -973,13 +976,13 @@ void APP_Update(void) gPowerSave_10ms = power_save1_10ms; // come back here in a bit gRxIdleMode = false; // RX is awake } - else - if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF || gScanStateDir != SCAN_OFF || gCssBackgroundScan) + else if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF || gScanStateDir != SCAN_OFF || gCssBackgroundScan || goToSleep) { // dual watch mode off or scanning or rssi update request // go back to sleep gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10; gRxIdleMode = true; + goToSleep = false; BK4819_DisableVox(); BK4819_Sleep(); @@ -992,6 +995,7 @@ void APP_Update(void) // toggle between the two VFO's DualwatchAlternate(); gPowerSave_10ms = power_save1_10ms; + goToSleep = true; } gPowerSaveCountdownExpired = false;