From e614904ff87e5d08451b986e03a35071ec6d74bb Mon Sep 17 00:00:00 2001 From: D44rkM00n <45374121+D44rkM00n@users.noreply.github.com> Date: Sat, 2 Sep 2023 00:15:47 +0200 Subject: [PATCH] Update monitor.cpp If the timeClient.update() function does not make a real update don't change mTriggerUpdate, this ensure that the time shown on screen at power up is correct when wifi is connected --- src/monitor.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/monitor.cpp b/src/monitor.cpp index 02f3033..fb91793 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -193,8 +193,7 @@ String getTime(void){ //Check if need an NTP call to check current time if((mTriggerUpdate == 0) || (millis() - mTriggerUpdate > UPDATE_PERIOD_h * 60 * 60 * 1000)){ //60 sec. * 60 min * 1000ms if(WiFi.status() == WL_CONNECTED) { - timeClient.update(); //NTP call to get current time - mTriggerUpdate = millis(); + if(timeClient.update()) mTriggerUpdate = millis(); initialTime = timeClient.getEpochTime(); // Guarda la hora inicial (en segundos desde 1970) Serial.print("TimeClient NTPupdateTime "); } @@ -446,4 +445,4 @@ void doLedStuff(int ledPin){ } break; } -} \ No newline at end of file +}