cumulate uptime after deep sleep

This commit is contained in:
cyberman54 2020-12-18 19:07:12 +01:00
parent 85f9645599
commit 889e88d671
3 changed files with 9 additions and 1 deletions

View File

@ -15,6 +15,7 @@ extern Ticker cyclicTimer;
void setCyclicIRQ(void); void setCyclicIRQ(void);
void doHousekeeping(void); void doHousekeeping(void);
uint64_t _uptime(uint64_t diff);
uint64_t uptime(void); uint64_t uptime(void);
void reset_counters(void); void reset_counters(void);
uint32_t getFreeRAM(); uint32_t getFreeRAM();

View File

@ -136,7 +136,13 @@ void doHousekeeping() {
} // doHousekeeping() } // doHousekeeping()
uint64_t uptime() { return millis(); } uint64_t _uptime(uint64_t diff) {
static uint64_t offset = 0;
offset += diff;
return millis() + offset;
}
uint64_t uptime(void){return _uptime(0);};
uint32_t getFreeRAM() { uint32_t getFreeRAM() {
#ifndef BOARD_HAS_PSRAM #ifndef BOARD_HAS_PSRAM

View File

@ -49,6 +49,7 @@ void do_after_reset(void) {
(sleep_stop_time.tv_sec - RTC_sleep_start_time.tv_sec) * 1000 + (sleep_stop_time.tv_sec - RTC_sleep_start_time.tv_sec) * 1000 +
(sleep_stop_time.tv_usec - RTC_sleep_start_time.tv_usec) / 1000; (sleep_stop_time.tv_usec - RTC_sleep_start_time.tv_usec) / 1000;
ESP_LOGI(TAG, "Time spent in deep sleep: %d ms", sleep_time_ms); ESP_LOGI(TAG, "Time spent in deep sleep: %d ms", sleep_time_ms);
_uptime(sleep_time_ms); // increment uptime
RTC_runmode = RUNMODE_WAKEUP; RTC_runmode = RUNMODE_WAKEUP;
break; break;