watchy lib 1.3 fixes
This commit is contained in:
@@ -13,8 +13,6 @@ const char *pokemon_names[151] = {"BULBASAUR","IVYSAUR","VENUSAUR","CHARMANDER",
|
||||
const float MAX_VBAT = 4.20;
|
||||
const float MIN_VBAT = 3.80;
|
||||
|
||||
WatchyPokemon::WatchyPokemon(){} //constructor
|
||||
|
||||
void WatchyPokemon::drawWatchFace(){
|
||||
|
||||
readWorldTime();
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "FreeMonoBold7pt7b.h"
|
||||
#include "wta.h"
|
||||
|
||||
#define FR
|
||||
|
||||
#ifdef FR
|
||||
#include "pokemon_fr.h"
|
||||
#else
|
||||
@@ -14,12 +16,12 @@
|
||||
|
||||
class WatchyPokemon : public WatchySynced
|
||||
{
|
||||
public:
|
||||
WatchyPokemon();
|
||||
void drawWatchFace();
|
||||
double randomDay();
|
||||
double randomHour();
|
||||
double randomMinute();
|
||||
using WatchySynced::WatchySynced;
|
||||
public:
|
||||
void drawWatchFace();
|
||||
double randomDay();
|
||||
double randomHour();
|
||||
double randomMinute();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "Watchy_Pokemon.h"
|
||||
#include "settings.h"
|
||||
|
||||
WatchyPokemon watchy;
|
||||
WatchyPokemon watchy(settings);
|
||||
|
||||
void setup(){
|
||||
watchy.init();
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef SETTINGS_H
|
||||
#define SETTINGS_H
|
||||
|
||||
//Weather Settings
|
||||
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||
#define OPENWEATHERMAP_APIKEY "f058fe1cad2afe8e2ddc5d063a64cecb" //use your own API key :)
|
||||
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?id=" //open weather api
|
||||
#define TEMP_UNIT "metric" //metric = Celsius , imperial = Fahrenheit
|
||||
#define TEMP_LANG "en"
|
||||
#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 * 1 //New York is UTC -5
|
||||
#define DST_OFFSET_SEC 3600
|
||||
|
||||
watchySettings settings{
|
||||
CITY_ID,
|
||||
OPENWEATHERMAP_APIKEY,
|
||||
OPENWEATHERMAP_URL,
|
||||
TEMP_UNIT,
|
||||
TEMP_LANG,
|
||||
WEATHER_UPDATE_INTERVAL,
|
||||
NTP_SERVER,
|
||||
GMT_OFFSET_SEC,
|
||||
DST_OFFSET_SEC
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,43 +1,42 @@
|
||||
#include "wta.h"
|
||||
|
||||
RTC_DATA_ATTR int worldTimeIntervalCounter = 0;
|
||||
|
||||
void WatchySynced::readWorldTime()
|
||||
{
|
||||
if (worldTimeIntervalCounter == 0)
|
||||
{
|
||||
worldTimeIntervalCounter = WTA_UPDATE_SHORT_INTERVAL;
|
||||
if (connectWiFi())
|
||||
{
|
||||
HTTPClient http;
|
||||
http.setConnectTimeout(WTA_UPDATE_TIMEOUT);
|
||||
String queryURL = String(WTA_URL) + String(WTA_TIMEZONE);
|
||||
http.begin(queryURL.c_str());
|
||||
int httpResponseCode = http.GET();
|
||||
if (httpResponseCode == 200)
|
||||
{
|
||||
String payload = http.getString();
|
||||
JSONVar responseObject = JSON.parse(payload);
|
||||
tmElements_t tm;
|
||||
String datetime = String((const char *)responseObject["datetime"]);
|
||||
tm.Year = datetime.substring(0, 4).toInt() - YEAR_OFFSET;
|
||||
tm.Month = datetime.substring(5, 7).toInt();
|
||||
tm.Day = datetime.substring(8, 10).toInt();
|
||||
tm.Hour = datetime.substring(11, 13).toInt();
|
||||
tm.Minute = datetime.substring(14, 16).toInt();
|
||||
tm.Second = 0;
|
||||
time_t t = makeTime(tm);
|
||||
RTC.set(t);
|
||||
RTC.read(currentTime);
|
||||
worldTimeIntervalCounter = WTA_UPDATE_LONG_INTERVAL;
|
||||
}
|
||||
http.end();
|
||||
WiFi.mode(WIFI_OFF);
|
||||
btStop();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
worldTimeIntervalCounter = worldTimeIntervalCounter < 0 ? 0 : worldTimeIntervalCounter - 1;
|
||||
}
|
||||
}
|
||||
#include "wta.h"
|
||||
|
||||
RTC_DATA_ATTR int worldTimeIntervalCounter = 0;
|
||||
|
||||
void WatchySynced::readWorldTime()
|
||||
{
|
||||
if (worldTimeIntervalCounter == 0)
|
||||
{
|
||||
worldTimeIntervalCounter = WTA_UPDATE_SHORT_INTERVAL;
|
||||
if (connectWiFi())
|
||||
{
|
||||
HTTPClient http;
|
||||
http.setConnectTimeout(WTA_UPDATE_TIMEOUT);
|
||||
String queryURL = String(WTA_URL) + String(WTA_TIMEZONE);
|
||||
http.begin(queryURL.c_str());
|
||||
int httpResponseCode = http.GET();
|
||||
if (httpResponseCode == 200)
|
||||
{
|
||||
String payload = http.getString();
|
||||
JSONVar responseObject = JSON.parse(payload);
|
||||
tmElements_t tm;
|
||||
String datetime = String((const char *)responseObject["datetime"]);
|
||||
tm.Year = y2kYearToTm(datetime.substring(0, 4).toInt());
|
||||
tm.Month = datetime.substring(5, 7).toInt();
|
||||
tm.Day = datetime.substring(8, 10).toInt();
|
||||
tm.Hour = datetime.substring(11, 13).toInt();
|
||||
tm.Minute = datetime.substring(14, 16).toInt();
|
||||
tm.Second = 0;
|
||||
RTC.set(tm);
|
||||
RTC.read(currentTime);
|
||||
worldTimeIntervalCounter = WTA_UPDATE_LONG_INTERVAL;
|
||||
}
|
||||
http.end();
|
||||
WiFi.mode(WIFI_OFF);
|
||||
btStop();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
worldTimeIntervalCounter = worldTimeIntervalCounter < 0 ? 0 : worldTimeIntervalCounter - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
|
||||
class WatchySynced : public Watchy
|
||||
{
|
||||
public:
|
||||
void readWorldTime();
|
||||
using Watchy::Watchy;
|
||||
public:
|
||||
void readWorldTime();
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user