From e845d6f06fec385618601c627e8bee5672034dfa Mon Sep 17 00:00:00 2001 From: "user@node5.net" Date: Sun, 15 Feb 2026 20:38:14 +0100 Subject: Only update on output change, for more stability Some sporadic error would flip the order of lines, and print chars in the clear spaces. Print more infrequently to mitigate the issue --- src/main.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 4809d0f..bb43886 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,6 +13,7 @@ HTTPClient http; unsigned long aPIPreviousMillis = 0; const long aPIInterval = 600000; // call API every 10 minutes String weatherText = ""; +String previousOutputText = ""; String weatherDescription(int code, bool isDay) { switch(code) { @@ -188,10 +189,12 @@ void setup() { } void loop() { + String outputText = ""; if (millis() - aPIPreviousMillis >= aPIInterval) { aPIPreviousMillis = millis(); callAPI(); } + outputText = weatherText + "\n\r"; // Get Unix epoch timestamp /*char buffer [3]; @@ -201,14 +204,16 @@ void loop() { Serial.print(truncatedEpoch); Serial.print(" ");*/ - Serial.print(weatherText); - Serial.println(); - - delay(50); // https://github.com/ropg/ezTime#getting-date-and-time // 16:36:15 Sat 16 Aug - String time_formatted = CopenhagenTime.dateTime("H:i:s D d M"); - Serial.println(time_formatted); + String time_formatted = CopenhagenTime.dateTime("H:i:s D d M"); + outputText += time_formatted; + + if (outputText != previousOutputText) + { + Serial.println(outputText); + previousOutputText = outputText; + } events(); // Run NTP } -- cgit v1.2.3