Use actual time in plots

This commit is contained in:
Thomas Kolb 2024-08-02 21:14:23 +02:00
parent 1045e85cfb
commit cc6618e650

View file

@ -25,7 +25,7 @@ static bool wiFiConnectedToStation;
static WiFiUDP ntpUDP; 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_ALTITUDE 320 // meters
#define REF_CO2_PPM 425 // clean air according to DWD at 2024-06-17 #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) void initSCD30(void)
{ {
timeseries_init(&ts_scd30_co2, 0, 15, "ppm", "%.1f"); timeseries_init(&ts_scd30_co2, timeClient.getEpochTime(), 15, "ppm", "%.1f");
timeseries_init(&ts_scd30_temperature, 0, 15, "°C", "%.1f"); timeseries_init(&ts_scd30_temperature, timeClient.getEpochTime(), 15, "°C", "%.1f");
timeseries_init(&ts_scd30_humidity, 0, 15, "%", "%.1f"); timeseries_init(&ts_scd30_humidity, timeClient.getEpochTime(), 15, "%", "%.1f");
// Try to initialize! // Try to initialize!
if (!scd30.begin()) { if (!scd30.begin()) {
@ -280,8 +280,6 @@ static void draw_epaper_callback(GxEPD2_DISPLAY_CLASS<GxEPD2_DRIVER_CLASS, MAX_H
y = 150 + FreeSans12pt7b.yAdvance*3/4; y = 150 + FreeSans12pt7b.yAdvance*3/4;
display->setCursor(0, y); display->setCursor(0, y);
display->setCursor(0, y);
display->setFont(&FreeSans12pt7b); display->setFont(&FreeSans12pt7b);
display->print("Feuchte: "); display->print("Feuchte: ");
@ -295,6 +293,21 @@ static void draw_epaper_callback(GxEPD2_DISPLAY_CLASS<GxEPD2_DRIVER_CLASS, MAX_H
display->print(" %rH"); display->print(" %rH");
epaper_plot(150, 155, 150, 65, &ts_scd30_humidity, 900); 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) void loop(void)