update time daily at 4 AM
This commit is contained in:
parent
b02c731e95
commit
8f706fe32f
@ -82,6 +82,9 @@ namespace Display {
|
|||||||
static int currentHour = -1;
|
static int currentHour = -1;
|
||||||
if (currentHour != hour()) {
|
if (currentHour != hour()) {
|
||||||
currentHour = hour();
|
currentHour = hour();
|
||||||
|
if (currentHour == 4) {
|
||||||
|
Ntp::updateTime();
|
||||||
|
}
|
||||||
if (currentHour == 8) {
|
if (currentHour == 8) {
|
||||||
Brightness::set(BRIGHTNESS_DAY);
|
Brightness::set(BRIGHTNESS_DAY);
|
||||||
Wifi::reconnect();
|
Wifi::reconnect();
|
||||||
|
|||||||
@ -14,13 +14,11 @@ namespace Ntp {
|
|||||||
TimeChangeRule CET = { "CET ", Last, Sun, Oct, 3, 60 }; // Central European Standard Time
|
TimeChangeRule CET = { "CET ", Last, Sun, Oct, 3, 60 }; // Central European Standard Time
|
||||||
Timezone CE(CEST, CET);
|
Timezone CE(CEST, CET);
|
||||||
|
|
||||||
time_t updateTime() {
|
void updateTime() {
|
||||||
if (timeClient.forceUpdate()) {
|
if (timeClient.forceUpdate()) {
|
||||||
time_t newTime = CE.toLocal(timeClient.getEpochTime());
|
time_t newTime = CE.toLocal(timeClient.getEpochTime());
|
||||||
setTime(newTime);
|
setTime(newTime);
|
||||||
return newTime;
|
Serial.println(asctime(localtime(&newTime)));
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -84,9 +84,7 @@ void onWifiConnected() {
|
|||||||
Wifi::printStatus();
|
Wifi::printStatus();
|
||||||
Ota::tLoop.enable();
|
Ota::tLoop.enable();
|
||||||
Mqtt::tReConnect.enable();
|
Mqtt::tReConnect.enable();
|
||||||
if (time_t newTime = Ntp::updateTime()) {
|
Ntp::updateTime();
|
||||||
Serial.println(asctime(localtime(&newTime)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkWifiCallback() {
|
void checkWifiCallback() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user