cleanup
This commit is contained in:
parent
d2b0bc4fd6
commit
611124d166
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#define TIME_24_HOUR
|
#define TIME_24_HOUR
|
||||||
#define DISPLAY_ADDRESS 0x70
|
#define DISPLAY_ADDRESS 0x70
|
||||||
#define BRIGHTNESS 7
|
#define BRIGHTNESS 1
|
||||||
|
|
||||||
//##########################################################################
|
//##########################################################################
|
||||||
// Globals
|
// Globals
|
||||||
@ -46,7 +46,6 @@ NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", tzOffset*3600);
|
|||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600); // Start the serial console
|
Serial.begin(9600); // Start the serial console
|
||||||
Serial.println("Clock starting!"); // Start the clock message.
|
|
||||||
|
|
||||||
wifiMulti.addAP("vulturul", "***REMOVED***");
|
wifiMulti.addAP("vulturul", "***REMOVED***");
|
||||||
wifiMulti.addAP("Miracle", "***REMOVED***");
|
wifiMulti.addAP("Miracle", "***REMOVED***");
|
||||||
@ -69,7 +68,7 @@ void setup() {
|
|||||||
void loop() {
|
void loop() {
|
||||||
ArduinoOTA.handle();
|
ArduinoOTA.handle();
|
||||||
|
|
||||||
if (shouldUpdate && timeClient.forceUpdate()) {
|
if (shouldUpdate && WiFi.status() == WL_CONNECTED && timeClient.forceUpdate()) {
|
||||||
shouldUpdate = false;
|
shouldUpdate = false;
|
||||||
hours = timeClient.getHours();
|
hours = timeClient.getHours();
|
||||||
minutes = timeClient.getMinutes();
|
minutes = timeClient.getMinutes();
|
||||||
@ -83,16 +82,14 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void incrementTime() {
|
void incrementTime() {
|
||||||
seconds++;
|
if (++seconds == 60) {
|
||||||
if (seconds == 60) {
|
|
||||||
seconds = 0;
|
seconds = 0;
|
||||||
minutes++;
|
if (++minutes == 60) {
|
||||||
if (((minutes % 5) == 0)) shouldUpdate = true;
|
|
||||||
if (minutes == 60) {
|
|
||||||
minutes = 0;
|
minutes = 0;
|
||||||
Serial.println("Minutes set to zero - should query NTP on next loop()");
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user