diff --git a/platformio.ini b/platformio.ini index 6af2a57..e658506 100644 --- a/platformio.ini +++ b/platformio.ini @@ -17,4 +17,5 @@ upload_port = /dev/cu.wchusbserial1420 [lib_deps] library = WifiManager, - Adafruit NeoPixel + Adafruit NeoPixel, + NTPClient diff --git a/src/SevenSegmentClock.cpp b/src/SevenSegmentClock.cpp index f0a4354..b3e2fec 100644 --- a/src/SevenSegmentClock.cpp +++ b/src/SevenSegmentClock.cpp @@ -193,10 +193,12 @@ void SevenSegmentClock::displaySeperator(char seperatorCharacter) { void SevenSegmentClock::displayTime(int hour, int minute) { - clockHour = hour; - clockMinute = minute; - Serial.print("SevenSegmentClock: new time "); - Serial.print(clockHour); Serial.print(":"); Serial.println(clockMinute); + if (clockHour != hour || clockMinute != minute) { + clockHour = hour; + clockMinute = minute; + Serial.print("SevenSegmentClock: new time "); + Serial.print(clockHour); Serial.print(":"); Serial.println(clockMinute); + } displayUpdate(); }; diff --git a/src/main.cpp b/src/main.cpp index 304a97b..c230536 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,8 @@ #include #include //this needs to be first, or it all crashes and burns... -#include //https://github.com/esp8266/Arduino +#include +#include //https://github.com/esp8266/Arduino +#include //needed for library #include @@ -11,6 +13,19 @@ #include #include "SevenSegmentClock.h" +// NTP +WiFiUDP ntpUDP; +// You can specify the time server pool and the offset (in seconds, can be +// changed later with setTimeOffset() ). Additionaly you can specify the +// update interval (in milliseconds, can be changed using setUpdateInterval() ). +NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", 3600, 60000); + +#define MODE_DEMO 1 +#define MODE_REALCLOCK 2 +#define MODE_FASTCLOCK 3 +static int appMode = MODE_DEMO; + + static const char *appName = "FastclockClient7Seg"; @@ -174,7 +189,12 @@ const char _SCRIPT[] PROGMEM = "