From cc6618e6505e3f5ab4f0780ee946d1c97eb02202 Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Fri, 2 Aug 2024 21:14:23 +0200 Subject: [PATCH] Use actual time in plots --- src/main.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6db08b1..77d96b9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,7 +25,7 @@ static bool wiFiConnectedToStation; static WiFiUDP ntpUDP; -NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", 3600, 60000); +NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", 0, 60000); #define REF_ALTITUDE 320 // meters #define REF_CO2_PPM 425 // clean air according to DWD at 2024-06-17 @@ -89,9 +89,9 @@ void wifi_setup(void) void initSCD30(void) { - timeseries_init(&ts_scd30_co2, 0, 15, "ppm", "%.1f"); - timeseries_init(&ts_scd30_temperature, 0, 15, "°C", "%.1f"); - timeseries_init(&ts_scd30_humidity, 0, 15, "%", "%.1f"); + timeseries_init(&ts_scd30_co2, timeClient.getEpochTime(), 15, "ppm", "%.1f"); + timeseries_init(&ts_scd30_temperature, timeClient.getEpochTime(), 15, "°C", "%.1f"); + timeseries_init(&ts_scd30_humidity, timeClient.getEpochTime(), 15, "%", "%.1f"); // Try to initialize! if (!scd30.begin()) { @@ -280,8 +280,6 @@ static void draw_epaper_callback(GxEPD2_DISPLAY_CLASSsetCursor(0, y); - display->setCursor(0, y); - display->setFont(&FreeSans12pt7b); display->print("Feuchte: "); @@ -295,6 +293,21 @@ static void draw_epaper_callback(GxEPD2_DISPLAY_CLASSprint(" %rH"); epaper_plot(150, 155, 150, 65, &ts_scd30_humidity, 900); + + y = 225 + FreeSans12pt7b.yAdvance*3/4; + display->setCursor(0, y); + + display->setFont(&FreeSans12pt7b); + display->print("Aktualisiert: "); + + y += FreeSans12pt7b.yAdvance; + display->setCursor(0, y); + + display->setFont(&FreeSansBold12pt7b); + display->print(timeClient.getFormattedTime()); + + display->setFont(&FreeSans12pt7b); + display->print(" UTC"); } void loop(void)