Skip to content

Commit

Permalink
v1.4.3
Browse files Browse the repository at this point in the history
- add ntp sync to weather call
- removed dst param since it's not used
  • Loading branch information
sqfmi committed Oct 15, 2022
1 parent 8adde78 commit 99158e1
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 36 deletions.
6 changes: 2 additions & 4 deletions examples/WatchFaces/7_SEG/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -21,8 +20,7 @@ watchySettings settings{
TEMP_LANG,
WEATHER_UPDATE_INTERVAL,
NTP_SERVER,
GMT_OFFSET_SEC,
DST_OFFSET_SEC
GMT_OFFSET_SEC
};

#endif
6 changes: 2 additions & 4 deletions examples/WatchFaces/Basic/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -21,8 +20,7 @@ watchySettings settings{
TEMP_LANG,
WEATHER_UPDATE_INTERVAL,
NTP_SERVER,
GMT_OFFSET_SEC,
DST_OFFSET_SEC
GMT_OFFSET_SEC
};

#endif
6 changes: 2 additions & 4 deletions examples/WatchFaces/DOS/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -21,8 +20,7 @@ watchySettings settings{
TEMP_LANG,
WEATHER_UPDATE_INTERVAL,
NTP_SERVER,
GMT_OFFSET_SEC,
DST_OFFSET_SEC
GMT_OFFSET_SEC
};

#endif
6 changes: 2 additions & 4 deletions examples/WatchFaces/MacPaint/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -21,8 +20,7 @@ watchySettings settings{
TEMP_LANG,
WEATHER_UPDATE_INTERVAL,
NTP_SERVER,
GMT_OFFSET_SEC,
DST_OFFSET_SEC
GMT_OFFSET_SEC
};

#endif
6 changes: 2 additions & 4 deletions examples/WatchFaces/Pokemon/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -21,8 +20,7 @@ watchySettings settings{
TEMP_LANG,
WEATHER_UPDATE_INTERVAL,
NTP_SERVER,
GMT_OFFSET_SEC,
DST_OFFSET_SEC
GMT_OFFSET_SEC
};

#endif
6 changes: 2 additions & 4 deletions examples/WatchFaces/StarryHorizon/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -21,8 +20,7 @@ watchySettings settings{
TEMP_LANG,
WEATHER_UPDATE_INTERVAL,
NTP_SERVER,
GMT_OFFSET_SEC,
DST_OFFSET_SEC
GMT_OFFSET_SEC
};

#endif
6 changes: 2 additions & 4 deletions examples/WatchFaces/Tetris/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -21,8 +20,7 @@ watchySettings settings{
TEMP_LANG,
WEATHER_UPDATE_INTERVAL,
NTP_SERVER,
GMT_OFFSET_SEC,
DST_OFFSET_SEC
GMT_OFFSET_SEC
};

#endif
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -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": [
{
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 11 additions & 5 deletions src/Watchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion src/Watchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class Watchy {
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();
Expand Down

0 comments on commit 99158e1

Please sign in to comment.