diff --git a/examples/WatchFaces/7_SEG/settings.h b/examples/WatchFaces/7_SEG/settings.h index e4f2669..808a79b 100644 --- a/examples/WatchFaces/7_SEG/settings.h +++ b/examples/WatchFaces/7_SEG/settings.h @@ -10,7 +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 EST, -4 EDT +#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data watchySettings settings{ .cityID = CITY_ID, @@ -24,4 +24,4 @@ watchySettings settings{ .vibrateOClock = true, }; -#endif \ No newline at end of file +#endif diff --git a/examples/WatchFaces/Basic/settings.h b/examples/WatchFaces/Basic/settings.h index 53d47e3..fa537fa 100644 --- a/examples/WatchFaces/Basic/settings.h +++ b/examples/WatchFaces/Basic/settings.h @@ -10,7 +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 EST, -4 EDT +#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data watchySettings settings{ .cityID = CITY_ID, @@ -23,4 +23,4 @@ watchySettings settings{ .gmtOffset = GMT_OFFSET_SEC, }; -#endif \ No newline at end of file +#endif diff --git a/examples/WatchFaces/DOS/settings.h b/examples/WatchFaces/DOS/settings.h index 53d47e3..fa537fa 100644 --- a/examples/WatchFaces/DOS/settings.h +++ b/examples/WatchFaces/DOS/settings.h @@ -10,7 +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 EST, -4 EDT +#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data watchySettings settings{ .cityID = CITY_ID, @@ -23,4 +23,4 @@ watchySettings settings{ .gmtOffset = GMT_OFFSET_SEC, }; -#endif \ No newline at end of file +#endif diff --git a/examples/WatchFaces/MacPaint/settings.h b/examples/WatchFaces/MacPaint/settings.h index 53d47e3..fa537fa 100644 --- a/examples/WatchFaces/MacPaint/settings.h +++ b/examples/WatchFaces/MacPaint/settings.h @@ -10,7 +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 EST, -4 EDT +#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data watchySettings settings{ .cityID = CITY_ID, @@ -23,4 +23,4 @@ watchySettings settings{ .gmtOffset = GMT_OFFSET_SEC, }; -#endif \ No newline at end of file +#endif diff --git a/examples/WatchFaces/Pokemon/settings.h b/examples/WatchFaces/Pokemon/settings.h index 53d47e3..fa537fa 100644 --- a/examples/WatchFaces/Pokemon/settings.h +++ b/examples/WatchFaces/Pokemon/settings.h @@ -10,7 +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 EST, -4 EDT +#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data watchySettings settings{ .cityID = CITY_ID, @@ -23,4 +23,4 @@ watchySettings settings{ .gmtOffset = GMT_OFFSET_SEC, }; -#endif \ No newline at end of file +#endif diff --git a/examples/WatchFaces/StarryHorizon/settings.h b/examples/WatchFaces/StarryHorizon/settings.h index 53d47e3..fa537fa 100644 --- a/examples/WatchFaces/StarryHorizon/settings.h +++ b/examples/WatchFaces/StarryHorizon/settings.h @@ -10,7 +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 EST, -4 EDT +#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data watchySettings settings{ .cityID = CITY_ID, @@ -23,4 +23,4 @@ watchySettings settings{ .gmtOffset = GMT_OFFSET_SEC, }; -#endif \ No newline at end of file +#endif diff --git a/examples/WatchFaces/Tetris/settings.h b/examples/WatchFaces/Tetris/settings.h index 53d47e3..fa537fa 100644 --- a/examples/WatchFaces/Tetris/settings.h +++ b/examples/WatchFaces/Tetris/settings.h @@ -10,7 +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 EST, -4 EDT +#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data watchySettings settings{ .cityID = CITY_ID, @@ -23,4 +23,4 @@ watchySettings settings{ .gmtOffset = GMT_OFFSET_SEC, }; -#endif \ No newline at end of file +#endif diff --git a/src/Watchy.cpp b/src/Watchy.cpp index 26f022e..0ffb0a2 100644 --- a/src/Watchy.cpp +++ b/src/Watchy.cpp @@ -12,6 +12,7 @@ RTC_DATA_ATTR bool BLE_CONFIGURED; RTC_DATA_ATTR weatherData currentWeather; RTC_DATA_ATTR int weatherIntervalCounter = -1; RTC_DATA_ATTR bool displayFullInit = true; +RTC_DATA_ATTR long gmtOffset = 0; RTC_DATA_ATTR bool alreadyInMenu = true; void Watchy::init(String datetime) { @@ -56,6 +57,7 @@ void Watchy::init(String datetime) { default: // reset RTC.config(datetime); _bmaConfig(); + gmtOffset = settings.gmtOffset; RTC.read(currentTime); showWatchFace(false); // full update on reset vibMotor(75, 4); @@ -639,7 +641,8 @@ weatherData Watchy::getWeatherData(String cityID, String units, String lang, currentWeather.weatherDescription = responseObject["weather"][0]["main"]; // sync NTP during weather API call and use timezone of city - syncNTP(long(responseObject["timezone"])); + gmtOffset = int(responseObject["timezone"]); + syncNTP(gmtOffset); } else { // http error } @@ -960,6 +963,8 @@ void Watchy::showSyncNTP() { display.setTextColor(GxEPD_WHITE); display.setCursor(0, 30); display.println("Syncing NTP... "); + display.print("GMT offset: "); + display.println(gmtOffset); display.display(false); // full refresh if (connectWiFi()) { if (syncNTP()) { @@ -997,7 +1002,7 @@ void Watchy::showSyncNTP() { bool Watchy::syncNTP() { // NTP sync - call after connecting to WiFi and // remember to turn it back off - return syncNTP(settings.gmtOffset, + return syncNTP(gmtOffset, settings.ntpServer.c_str()); }