aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-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
}