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)
|
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);
|
display.drawBitmap(x - i * 10, y, tetris_small_nums[value % 10], 8, 8, GxEPD_BLACK);
|
||||||
value /= 10;
|
value /= 10;
|
||||||
|
|||||||
@@ -5,9 +5,6 @@
|
|||||||
#include "tetris.h"
|
#include "tetris.h"
|
||||||
#include "wta.h"
|
#include "wta.h"
|
||||||
|
|
||||||
#undef WTA_TIMEZONE
|
|
||||||
#define WTA_TIMEZONE "Europe/Paris"
|
|
||||||
|
|
||||||
class WatchyTetris : public WatchySynced
|
class WatchyTetris : public WatchySynced
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
#include "wta.h"
|
#include "wta.h"
|
||||||
|
|
||||||
RTC_DATA_ATTR int worldTimeIntervalCounter = WTA_UPDATE_INTERVAL;
|
RTC_DATA_ATTR int worldTimeIntervalCounter = 0;
|
||||||
|
|
||||||
void WatchySynced::readWorldTime()
|
void WatchySynced::readWorldTime()
|
||||||
{
|
{
|
||||||
if (worldTimeIntervalCounter >= WTA_UPDATE_INTERVAL)
|
if (worldTimeIntervalCounter == 0)
|
||||||
{
|
{
|
||||||
|
worldTimeIntervalCounter = WTA_UPDATE_SHORT_INTERVAL;
|
||||||
if (connectWiFi())
|
if (connectWiFi())
|
||||||
{
|
{
|
||||||
HTTPClient http;
|
HTTPClient http;
|
||||||
http.setConnectTimeout(10000);
|
http.setConnectTimeout(WTA_UPDATE_TIMEOUT);
|
||||||
String queryURL = String(WTA_URL) + String(WTA_TIMEZONE);
|
String queryURL = String(WTA_URL) + String(WTA_TIMEZONE);
|
||||||
http.begin(queryURL.c_str());
|
http.begin(queryURL.c_str());
|
||||||
int httpResponseCode = http.GET();
|
int httpResponseCode = http.GET();
|
||||||
@@ -28,15 +29,15 @@ void WatchySynced::readWorldTime()
|
|||||||
time_t t = makeTime(tm);
|
time_t t = makeTime(tm);
|
||||||
RTC.set(t);
|
RTC.set(t);
|
||||||
RTC.read(currentTime);
|
RTC.read(currentTime);
|
||||||
|
worldTimeIntervalCounter = WTA_UPDATE_LONG_INTERVAL;
|
||||||
}
|
}
|
||||||
http.end();
|
http.end();
|
||||||
WiFi.mode(WIFI_OFF);
|
WiFi.mode(WIFI_OFF);
|
||||||
btStop();
|
btStop();
|
||||||
}
|
}
|
||||||
worldTimeIntervalCounter = 0;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
worldTimeIntervalCounter++;
|
worldTimeIntervalCounter = worldTimeIntervalCounter < 0 ? 0 : worldTimeIntervalCounter - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,8 +4,10 @@
|
|||||||
#include <Watchy.h>
|
#include <Watchy.h>
|
||||||
|
|
||||||
#define WTA_URL "http://worldtimeapi.org/api/timezone/"
|
#define WTA_URL "http://worldtimeapi.org/api/timezone/"
|
||||||
#define WTA_TIMEZONE "Etc/UTC"
|
#define WTA_TIMEZONE "Europe/Paris"
|
||||||
#define WTA_UPDATE_INTERVAL 60 //minutes
|
#define WTA_UPDATE_SHORT_INTERVAL 30 //minutes
|
||||||
|
#define WTA_UPDATE_LONG_INTERVAL 300 //minutes
|
||||||
|
#define WTA_UPDATE_TIMEOUT 10000 //ms
|
||||||
|
|
||||||
class WatchySynced : public Watchy
|
class WatchySynced : public Watchy
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user