From b67cd033d251746212dfef12a6222689cad8ddf6 Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 30 Aug 2022 15:49:33 +0200 Subject: [PATCH] fix #209 --- tools/esp8266/app.cpp | 18 ++++++++---------- tools/esp8266/app.h | 1 + 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index f97a6b9d..be78d6a5 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -53,14 +53,11 @@ void app::loop(void) { mWebInst->loop(); if(checkTicker(&mUptimeTicker, mUptimeInterval)) { - mUptimeSecs++; - if(0 != mTimestamp) - mTimestamp++; - else { - if(!apActive) { - mTimestamp = mWifi->getNtpTime(); - DPRINTLN(DBG_INFO, "[NTP]: " + getDateTimeStr(mTimestamp)); - } + if(millis() - mPrevMillis >= 1000) { + mPrevMillis += 1000; + mUptimeSecs++; + if(0 != mTimestamp) + mTimestamp++; } } @@ -662,9 +659,10 @@ const char* app::getFieldStateClass(uint8_t fieldId) { void app::resetSystem(void) { mUptimeSecs = 0; mUptimeTicker = 0xffffffff; - mUptimeInterval = 1000; // [ms] + mUptimeInterval = 500; // [ms] + mPrevMillis = 0; - mNtpRefreshTicker = 0xffffffff; + mNtpRefreshTicker = 0; mNtpRefreshInterval = NTP_REFRESH_INTERVAL; // [ms] #ifdef AP_ONLY diff --git a/tools/esp8266/app.h b/tools/esp8266/app.h index 48dbc1ed..b7fd462b 100644 --- a/tools/esp8266/app.h +++ b/tools/esp8266/app.h @@ -224,6 +224,7 @@ class app { uint32_t mUptimeTicker; uint16_t mUptimeInterval; uint32_t mUptimeSecs; + uint32_t mPrevMillis; uint8_t mHeapStatCnt; uint32_t mNtpRefreshTicker; uint32_t mNtpRefreshInterval;