From 7a8580d9ab9f10ac5104dce99d822d5b93fabde7 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Mon, 16 Nov 2020 13:34:11 +0100 Subject: [PATCH] Added check_datetime(). --- WLAN_Thermometer.ino | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/WLAN_Thermometer.ino b/WLAN_Thermometer.ino index 3533b02..e231ecc 100644 --- a/WLAN_Thermometer.ino +++ b/WLAN_Thermometer.ino @@ -24,6 +24,7 @@ #define KRATE_TEMP 5000 #define KRATE_TIME 500 #define KRATE_RESET_AP_DATA 5000 +#define KRATE_CHECK_DATETIME 250000 #define ONBOARD_LED 2 #define NTP_TIMEOUT 15000 #define WIFI_CONNECT_TIMEOUT 30 @@ -157,6 +158,7 @@ void setup() sched.addJob(show_temperature, KRATE_TEMP); sched.addJob(show_time, KRATE_TIME); sched.addJob(check_reset_ap_data, KRATE_RESET_AP_DATA); + sched.addJob(check_datetime, KRATE_CHECK_DATETIME); get_sensor_data(); temp[MIN] = temp[ACT]; @@ -377,7 +379,6 @@ void show_time(void) { strcpy(date_string, "--:--:----"); strcpy(time_string, "--:--:--"); - DateTime.forceUpdate(); } if (strcmp(date_string, date_string_old)) @@ -576,3 +577,14 @@ void ap_data_reset(void) delay(1000); ESP.restart(); } + +void check_datetime(void) +{ + if (!DateTime.isTimeValid()) + { + lcd.setCursor(0, 0); + lcd.print(" Time update "); + DateTime.forceUpdate(); + show_time(); + } +}