Correct timebase_ms after deep sleep

During deep sleep, the millisecond counter is stopped. To ensure correct delay
times, we add the sleep duration to the counter after wakeup.
This commit is contained in:
Thomas Kolb 2023-06-18 16:18:44 +02:00
parent bd08440584
commit e8dff1f017

View file

@ -379,6 +379,9 @@ int main(void)
if((timebase_ms - charge_control_idle_since) > FLASH_CONFIG_DEEPSLEEP_DELAY) { if((timebase_ms - charge_control_idle_since) > FLASH_CONFIG_DEEPSLEEP_DELAY) {
low_power_mode(FLASH_CONFIG_DEEPSLEEP_DURATION); low_power_mode(FLASH_CONFIG_DEEPSLEEP_DURATION);
charge_control_was_idle = false; charge_control_was_idle = false;
// correct the time base after deep sleep
timebase_ms += FLASH_CONFIG_DEEPSLEEP_DURATION * 1000;
} }
} }
} else { } else {