improved timeauto sync
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
#include "tetris.h"
|
||||
#include "wta.h"
|
||||
|
||||
#undef WTA_TIMEZONE
|
||||
#define WTA_TIMEZONE "Europe/Paris"
|
||||
|
||||
class WatchyTetris : public WatchySynced
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,10 @@
|
||||
#include <Watchy.h>
|
||||
|
||||
#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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user