Merge pull request #188 from shtrom/fix/gmtOffset_from_weather

Set GMT offset from weatherdata. Will override GMT offset in settings after API call.
pull/205/head
SQFMI 2022-12-26 12:16:40 -05:00 committed by GitHub
commit 5921655691
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 21 additions and 16 deletions

View File

@ -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
#endif

View File

@ -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
#endif

View File

@ -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
#endif

View File

@ -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
#endif

View File

@ -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
#endif

View File

@ -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
#endif

View File

@ -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
#endif

View File

@ -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());
}