mirror of https://github.com/sqfmi/Watchy.git
update weather interval
parent
1ae5fa2654
commit
55cb672cee
|
@ -95,6 +95,7 @@ void Watchy7SEG::drawBattery(){
|
|||
void Watchy7SEG::drawWeather(){
|
||||
|
||||
weatherData currentWeather = getWeatherData();
|
||||
|
||||
int8_t temperature = currentWeather.temperature;
|
||||
int16_t weatherConditionCode = currentWeather.weatherConditionCode;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Watchy",
|
||||
"version": "1.2.3",
|
||||
"version": "1.2.5",
|
||||
"description": "Watchy - An Open Source E-Paper Watch by SQFMI",
|
||||
"authors": [
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name=Watchy
|
||||
version=1.2.3
|
||||
version=1.2.5
|
||||
author=SQFMI
|
||||
maintainer=SQFMI
|
||||
sentence=Watchy - An Open Source E-Paper Watch by SQFMI
|
||||
|
|
|
@ -8,6 +8,8 @@ RTC_DATA_ATTR int menuIndex;
|
|||
RTC_DATA_ATTR BMA423 sensor;
|
||||
RTC_DATA_ATTR bool WIFI_CONFIGURED;
|
||||
RTC_DATA_ATTR bool BLE_CONFIGURED;
|
||||
RTC_DATA_ATTR weatherData currentWeather;
|
||||
RTC_DATA_ATTR int weatherIntervalCounter = WEATHER_UPDATE_INTERVAL;
|
||||
|
||||
String getValue(String data, char separator, int index)
|
||||
{
|
||||
|
@ -484,9 +486,7 @@ void Watchy::drawWatchFace(){
|
|||
}
|
||||
|
||||
weatherData Watchy::getWeatherData(){
|
||||
|
||||
weatherData currentWeather;
|
||||
|
||||
if(weatherIntervalCounter >= WEATHER_UPDATE_INTERVAL){ //only update if WEATHER_UPDATE_INTERVAL has elapsed i.e. 30 minutes
|
||||
if(connectWiFi()){//Use Weather API for live data if WiFi is connected
|
||||
HTTPClient http;
|
||||
http.setConnectTimeout(3000);//3 second max timeout
|
||||
|
@ -513,6 +513,10 @@ weatherData Watchy::getWeatherData(){
|
|||
currentWeather.temperature = temperature;
|
||||
currentWeather.weatherConditionCode = 800;
|
||||
}
|
||||
weatherIntervalCounter = 0;
|
||||
}else{
|
||||
weatherIntervalCounter++;
|
||||
}
|
||||
return currentWeather;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ class Watchy {
|
|||
|
||||
void handleButtonPress();
|
||||
void showMenu(byte menuIndex, bool partialRefresh);
|
||||
void showFastMenu(byte menuIndex);
|
||||
void showBattery();
|
||||
void showBuzz();
|
||||
void showAccelerometer();
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#define OPENWEATHERMAP_APIKEY "f058fe1cad2afe8e2ddc5d063a64cecb" //use your own API key :)
|
||||
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?q="
|
||||
#define TEMP_UNIT "metric" //use "imperial" for Fahrenheit"
|
||||
#define WEATHER_UPDATE_INTERVAL 30 //minutes
|
||||
//wifi
|
||||
#define WIFI_AP_TIMEOUT 60
|
||||
#define WIFI_AP_SSID "Watchy AP"
|
||||
|
|
Loading…
Reference in New Issue