mirror of https://github.com/sqfmi/Watchy.git
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
commit
5921655691
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue