diff --git a/examples/WatchFaces/7_SEG/settings.h b/examples/WatchFaces/7_SEG/settings.h index acf4169..654a219 100644 --- a/examples/WatchFaces/7_SEG/settings.h +++ b/examples/WatchFaces/7_SEG/settings.h @@ -10,8 +10,7 @@ #define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes //NTP Settings #define NTP_SERVER "pool.ntp.org" -#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 -#define DST_OFFSET_SEC 3600 +#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT watchySettings settings{ CITY_ID, @@ -21,8 +20,7 @@ watchySettings settings{ TEMP_LANG, WEATHER_UPDATE_INTERVAL, NTP_SERVER, - GMT_OFFSET_SEC, - DST_OFFSET_SEC + GMT_OFFSET_SEC }; #endif \ No newline at end of file diff --git a/examples/WatchFaces/Basic/settings.h b/examples/WatchFaces/Basic/settings.h index acf4169..654a219 100644 --- a/examples/WatchFaces/Basic/settings.h +++ b/examples/WatchFaces/Basic/settings.h @@ -10,8 +10,7 @@ #define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes //NTP Settings #define NTP_SERVER "pool.ntp.org" -#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 -#define DST_OFFSET_SEC 3600 +#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT watchySettings settings{ CITY_ID, @@ -21,8 +20,7 @@ watchySettings settings{ TEMP_LANG, WEATHER_UPDATE_INTERVAL, NTP_SERVER, - GMT_OFFSET_SEC, - DST_OFFSET_SEC + GMT_OFFSET_SEC }; #endif \ No newline at end of file diff --git a/examples/WatchFaces/DOS/settings.h b/examples/WatchFaces/DOS/settings.h index acf4169..654a219 100644 --- a/examples/WatchFaces/DOS/settings.h +++ b/examples/WatchFaces/DOS/settings.h @@ -10,8 +10,7 @@ #define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes //NTP Settings #define NTP_SERVER "pool.ntp.org" -#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 -#define DST_OFFSET_SEC 3600 +#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT watchySettings settings{ CITY_ID, @@ -21,8 +20,7 @@ watchySettings settings{ TEMP_LANG, WEATHER_UPDATE_INTERVAL, NTP_SERVER, - GMT_OFFSET_SEC, - DST_OFFSET_SEC + GMT_OFFSET_SEC }; #endif \ No newline at end of file diff --git a/examples/WatchFaces/MacPaint/settings.h b/examples/WatchFaces/MacPaint/settings.h index acf4169..654a219 100644 --- a/examples/WatchFaces/MacPaint/settings.h +++ b/examples/WatchFaces/MacPaint/settings.h @@ -10,8 +10,7 @@ #define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes //NTP Settings #define NTP_SERVER "pool.ntp.org" -#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 -#define DST_OFFSET_SEC 3600 +#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT watchySettings settings{ CITY_ID, @@ -21,8 +20,7 @@ watchySettings settings{ TEMP_LANG, WEATHER_UPDATE_INTERVAL, NTP_SERVER, - GMT_OFFSET_SEC, - DST_OFFSET_SEC + GMT_OFFSET_SEC }; #endif \ No newline at end of file diff --git a/examples/WatchFaces/Pokemon/settings.h b/examples/WatchFaces/Pokemon/settings.h index acf4169..654a219 100644 --- a/examples/WatchFaces/Pokemon/settings.h +++ b/examples/WatchFaces/Pokemon/settings.h @@ -10,8 +10,7 @@ #define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes //NTP Settings #define NTP_SERVER "pool.ntp.org" -#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 -#define DST_OFFSET_SEC 3600 +#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT watchySettings settings{ CITY_ID, @@ -21,8 +20,7 @@ watchySettings settings{ TEMP_LANG, WEATHER_UPDATE_INTERVAL, NTP_SERVER, - GMT_OFFSET_SEC, - DST_OFFSET_SEC + GMT_OFFSET_SEC }; #endif \ No newline at end of file diff --git a/examples/WatchFaces/StarryHorizon/settings.h b/examples/WatchFaces/StarryHorizon/settings.h index acf4169..654a219 100644 --- a/examples/WatchFaces/StarryHorizon/settings.h +++ b/examples/WatchFaces/StarryHorizon/settings.h @@ -10,8 +10,7 @@ #define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes //NTP Settings #define NTP_SERVER "pool.ntp.org" -#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 -#define DST_OFFSET_SEC 3600 +#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT watchySettings settings{ CITY_ID, @@ -21,8 +20,7 @@ watchySettings settings{ TEMP_LANG, WEATHER_UPDATE_INTERVAL, NTP_SERVER, - GMT_OFFSET_SEC, - DST_OFFSET_SEC + GMT_OFFSET_SEC }; #endif \ No newline at end of file diff --git a/examples/WatchFaces/Tetris/settings.h b/examples/WatchFaces/Tetris/settings.h index acf4169..654a219 100644 --- a/examples/WatchFaces/Tetris/settings.h +++ b/examples/WatchFaces/Tetris/settings.h @@ -10,8 +10,7 @@ #define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes //NTP Settings #define NTP_SERVER "pool.ntp.org" -#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 -#define DST_OFFSET_SEC 3600 +#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT watchySettings settings{ CITY_ID, @@ -21,8 +20,7 @@ watchySettings settings{ TEMP_LANG, WEATHER_UPDATE_INTERVAL, NTP_SERVER, - GMT_OFFSET_SEC, - DST_OFFSET_SEC + GMT_OFFSET_SEC }; #endif \ No newline at end of file diff --git a/library.json b/library.json index 0519f2c..a30ac1f 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Watchy", - "version": "1.4.2", + "version": "1.4.3", "description": "Watchy - An Open Source E-Paper Watch by SQFMI", "authors": [ { diff --git a/library.properties b/library.properties index ee16e1d..37e636b 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Watchy -version=1.4.2 +version=1.4.3 author=SQFMI maintainer=SQFMI sentence=Watchy - An Open Source E-Paper Watch by SQFMI diff --git a/src/Watchy.cpp b/src/Watchy.cpp index 0400acd..b95a036 100644 --- a/src/Watchy.cpp +++ b/src/Watchy.cpp @@ -54,7 +54,7 @@ void Watchy::displayBusyCallback(const void *) { void Watchy::deepSleep() { display.hibernate(); if (displayFullInit) // For some reason, seems to be enabled on first boot - esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER); + esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_ALL); displayFullInit = false; // Notify not to init it again RTC.clearAlarm(); // resets the alarm flag in the RTC @@ -618,6 +618,8 @@ weatherData Watchy::getWeatherData(String cityID, String units, String lang, int(responseObject["weather"][0]["id"]); currentWeather.weatherDescription = responseObject["weather"][0]["main"]; + // sync NTP during weather API call and use timezone of city + syncNTP(long(responseObject["timezone"])); } else { // http error } @@ -975,13 +977,17 @@ void Watchy::showSyncNTP() { bool Watchy::syncNTP() { // NTP sync - call after connecting to WiFi and // remember to turn it back off - return syncNTP(settings.gmtOffset, settings.dstOffset, + return syncNTP(settings.gmtOffset, settings.ntpServer.c_str()); } -bool Watchy::syncNTP(long gmt, int dst, - String ntpServer) { // NTP sync - call after connecting to - // WiFi and remember to turn it back off +bool Watchy::syncNTP(long gmt) { + return syncNTP(gmt, settings.ntpServer.c_str()); +} + +bool Watchy::syncNTP(long gmt, String ntpServer) { + // NTP sync - call after connecting to + // WiFi and remember to turn it back off WiFiUDP ntpUDP; NTPClient timeClient(ntpUDP, ntpServer.c_str(), gmt); timeClient.begin(); diff --git a/src/Watchy.h b/src/Watchy.h index 43fa9ae..af6ae29 100644 --- a/src/Watchy.h +++ b/src/Watchy.h @@ -61,7 +61,8 @@ public: void showUpdateFW(); void showSyncNTP(); bool syncNTP(); - bool syncNTP(long gmt, int dst, String ntpServer); + bool syncNTP(long gmt); + bool syncNTP(long gmt, String ntpServer); void setTime(); void setupWifi(); bool connectWiFi();