diff --git a/esp_clock.ino b/esp_clock.ino index 0b30d8a..d7db4d9 100644 --- a/esp_clock.ino +++ b/esp_clock.ino @@ -16,7 +16,7 @@ #define TIME_24_HOUR #define DISPLAY_ADDRESS 0x70 -#define BRIGHTNESS 7 +#define BRIGHTNESS 1 //########################################################################## // Globals @@ -46,7 +46,6 @@ NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", tzOffset*3600); void setup() { Serial.begin(9600); // Start the serial console - Serial.println("Clock starting!"); // Start the clock message. wifiMulti.addAP("vulturul", "***REMOVED***"); wifiMulti.addAP("Miracle", "***REMOVED***"); @@ -69,7 +68,7 @@ void setup() { void loop() { ArduinoOTA.handle(); - if (shouldUpdate && timeClient.forceUpdate()) { + if (shouldUpdate && WiFi.status() == WL_CONNECTED && timeClient.forceUpdate()) { shouldUpdate = false; hours = timeClient.getHours(); minutes = timeClient.getMinutes(); @@ -83,16 +82,14 @@ void loop() { } void incrementTime() { - seconds++; - if (seconds == 60) { + if (++seconds == 60) { seconds = 0; - minutes++; - if (((minutes % 5) == 0)) shouldUpdate = true; - if (minutes == 60) { + if (++minutes == 60) { minutes = 0; Serial.println("Minutes set to zero - should query NTP on next loop()"); - hours = ++hours % 24; + if (++hours == 24) hours = 0; } + if (((minutes % 5) == 0)) shouldUpdate = true; } }