From e8dff1f0175ad24dbdaae8c68d40614f3caa6bbe Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Sun, 18 Jun 2023 16:18:44 +0200 Subject: [PATCH] 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. --- src/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.c b/src/main.c index 8211bc6..3311f4e 100644 --- a/src/main.c +++ b/src/main.c @@ -379,6 +379,9 @@ int main(void) if((timebase_ms - charge_control_idle_since) > FLASH_CONFIG_DEEPSLEEP_DELAY) { low_power_mode(FLASH_CONFIG_DEEPSLEEP_DURATION); charge_control_was_idle = false; + + // correct the time base after deep sleep + timebase_ms += FLASH_CONFIG_DEEPSLEEP_DURATION * 1000; } } } else {