aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoruser@node5.net <user@node5.net>2026-02-15 20:38:14 +0100
committeruser@node5.net <user@node5.net>2026-02-15 20:38:14 +0100
commite845d6f06fec385618601c627e8bee5672034dfa (patch)
treea00820cb35d53c5a6a3abae6bc30601320b0432e /src
parent93914417e61a886debd2923e025af2d9536bab26 (diff)
Only update on output change, for more stabilityHEADmaster
Some sporadic error would flip the order of lines, and print chars in the clear spaces. Print more infrequently to mitigate the issue
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp17
1 files changed, 11 insertions, 6 deletions
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
}