From 8ad2f66131da6dd57d510561f214e15703dce01a Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Fri, 9 Aug 2019 17:42:39 +0200 Subject: [PATCH] make lastUpdate absolute --- src/main.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index bd29c1d..c97cab7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -88,7 +88,7 @@ struct __attribute__((packed)) sensor_readings_t { float temperature_min = NAN; // °C int battery = 0; int8_t rssi = 0; - uint32_t lastUpdate = 0; + time_t lastUpdate = 0; } sensor_readings; sensor_readings_t sensors_a4cf1211c3e4, sensors_246f28d1fa5c, sensors_246f28d1a080, sensors_246f28d1eff4; @@ -345,7 +345,7 @@ void getSensorMeasurements() { ESP_LOGI(TAG, "Battery : %5d ", sensor_readings.battery); ESP_LOGI(TAG, "Heap : %5lu", ESP.getFreeHeap()); - sensor_readings.lastUpdate = millis(); + sensor_readings.lastUpdate = getTimestamp(); } @@ -386,7 +386,7 @@ void receiveMqtt(const char* topic, const char* data) { } else if (strcmp("/voc", topic_last) == 0) { sensor->voc = atof(data); } - sensor->lastUpdate = millis(); + sensor->lastUpdate = getTimestamp(); // ToDo } } @@ -562,16 +562,16 @@ void displayValues() { // other nodes display.setFont(NULL); display.setCursor(0, y_offset+70); - if (!ota.getMAC().equals("246f28d1fa5c") && millis() - sensors_246f28d1fa5c.lastUpdate < 15*60*1000) { + if (!ota.getMAC().equals("246f28d1fa5c") && getTimestamp() - sensors_246f28d1fa5c.lastUpdate < 15*60) { display.printf("246f28d1fa5c: %4.1f %4.1f %6.1f\n", sensors_246f28d1fa5c.temperature, sensors_246f28d1fa5c.humidity, sensors_246f28d1fa5c.pressure); } - if (!ota.getMAC().equals("a4cf1211c3e4") && millis() - sensors_a4cf1211c3e4.lastUpdate < 15*60*1000) { + if (!ota.getMAC().equals("a4cf1211c3e4") && getTimestamp() - sensors_a4cf1211c3e4.lastUpdate < 15*60) { display.printf("a4cf1211c3e4: %4.1f %4.1f %6.1f\n", sensors_a4cf1211c3e4.temperature, sensors_a4cf1211c3e4.humidity, sensors_a4cf1211c3e4.pressure); } - if (!ota.getMAC().equals("246f28d1a080") && millis() - sensors_246f28d1a080.lastUpdate < 15*60*1000) { + if (!ota.getMAC().equals("246f28d1a080") && getTimestamp() - sensors_246f28d1a080.lastUpdate < 15*60) { display.printf("246f28d1a080: %4.1f %4.1f %6.1f\n", sensors_246f28d1a080.temperature, sensors_246f28d1a080.humidity, sensors_246f28d1a080.pressure); } - if (!ota.getMAC().equals("246f28d1eff4") && millis() - sensors_246f28d1eff4.lastUpdate < 15*60*1000) { + if (!ota.getMAC().equals("246f28d1eff4") && getTimestamp() - sensors_246f28d1eff4.lastUpdate < 15*60) { display.printf("246f28d1eff4: %4.1f %4.1f %6.1f\n", sensors_246f28d1eff4.temperature, sensors_246f28d1eff4.humidity, sensors_246f28d1eff4.pressure); }