diff --git a/watchfaces/tetris-2.0/Watchy_Tetris.cpp b/watchfaces/tetris-2.0/Watchy_Tetris.cpp index 6bfb09e..19008f8 100644 --- a/watchfaces/tetris-2.0/Watchy_Tetris.cpp +++ b/watchfaces/tetris-2.0/Watchy_Tetris.cpp @@ -66,7 +66,7 @@ void WatchyTetris::drawWatchFace() void WatchyTetris::drawNumber(int x, int y, int value, int max_digits) { - for (int8_t i = 0; i <= max_digits; i++) + for (int8_t i = 0; i < max_digits; i++) { display.drawBitmap(x - i * 10, y, tetris_small_nums[value % 10], 8, 8, GxEPD_BLACK); value /= 10; diff --git a/watchfaces/tetris-2.0/Watchy_Tetris.h b/watchfaces/tetris-2.0/Watchy_Tetris.h index 54265bc..a3b0064 100644 --- a/watchfaces/tetris-2.0/Watchy_Tetris.h +++ b/watchfaces/tetris-2.0/Watchy_Tetris.h @@ -5,9 +5,6 @@ #include "tetris.h" #include "wta.h" -#undef WTA_TIMEZONE -#define WTA_TIMEZONE "Europe/Paris" - class WatchyTetris : public WatchySynced { public: diff --git a/watchfaces/tetris-2.0/wta.cpp b/watchfaces/tetris-2.0/wta.cpp index 28afea2..7e55099 100644 --- a/watchfaces/tetris-2.0/wta.cpp +++ b/watchfaces/tetris-2.0/wta.cpp @@ -1,15 +1,16 @@ #include "wta.h" -RTC_DATA_ATTR int worldTimeIntervalCounter = WTA_UPDATE_INTERVAL; +RTC_DATA_ATTR int worldTimeIntervalCounter = 0; void WatchySynced::readWorldTime() { - if (worldTimeIntervalCounter >= WTA_UPDATE_INTERVAL) + if (worldTimeIntervalCounter == 0) { + worldTimeIntervalCounter = WTA_UPDATE_SHORT_INTERVAL; if (connectWiFi()) { HTTPClient http; - http.setConnectTimeout(10000); + http.setConnectTimeout(WTA_UPDATE_TIMEOUT); String queryURL = String(WTA_URL) + String(WTA_TIMEZONE); http.begin(queryURL.c_str()); int httpResponseCode = http.GET(); @@ -28,15 +29,15 @@ void WatchySynced::readWorldTime() time_t t = makeTime(tm); RTC.set(t); RTC.read(currentTime); + worldTimeIntervalCounter = WTA_UPDATE_LONG_INTERVAL; } http.end(); WiFi.mode(WIFI_OFF); btStop(); } - worldTimeIntervalCounter = 0; } else { - worldTimeIntervalCounter++; + worldTimeIntervalCounter = worldTimeIntervalCounter < 0 ? 0 : worldTimeIntervalCounter - 1; } } \ No newline at end of file diff --git a/watchfaces/tetris-2.0/wta.h b/watchfaces/tetris-2.0/wta.h index a350c78..902d702 100644 --- a/watchfaces/tetris-2.0/wta.h +++ b/watchfaces/tetris-2.0/wta.h @@ -4,8 +4,10 @@ #include #define WTA_URL "http://worldtimeapi.org/api/timezone/" -#define WTA_TIMEZONE "Etc/UTC" -#define WTA_UPDATE_INTERVAL 60 //minutes +#define WTA_TIMEZONE "Europe/Paris" +#define WTA_UPDATE_SHORT_INTERVAL 30 //minutes +#define WTA_UPDATE_LONG_INTERVAL 300 //minutes +#define WTA_UPDATE_TIMEOUT 10000 //ms class WatchySynced : public Watchy {