mirror of https://github.com/sqfmi/Watchy.git
Compare commits
6 Commits
3ffb0f8697
...
fbbcaabbd1
Author | SHA1 | Date |
---|---|---|
sqfmi | fbbcaabbd1 | |
SQFMI | e9854a7fa2 | |
sqfmi | fddbe504c1 | |
sqfmi | aa3528371d | |
Sudrien | b84ab91c6b | |
Denis Pitzalis | df5fce8d40 |
|
@ -125,24 +125,29 @@ void Watchy7SEG::drawWeather(){
|
||||||
display.drawBitmap(165, 110, currentWeather.isMetric ? celsius : fahrenheit, 26, 20, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
display.drawBitmap(165, 110, currentWeather.isMetric ? celsius : fahrenheit, 26, 20, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
||||||
const unsigned char* weatherIcon;
|
const unsigned char* weatherIcon;
|
||||||
|
|
||||||
//https://openweathermap.org/weather-conditions
|
if(WIFI_CONFIGURED){
|
||||||
if(weatherConditionCode > 801){//Cloudy
|
//https://openweathermap.org/weather-conditions
|
||||||
weatherIcon = cloudy;
|
if(weatherConditionCode > 801){//Cloudy
|
||||||
}else if(weatherConditionCode == 801){//Few Clouds
|
weatherIcon = cloudy;
|
||||||
weatherIcon = cloudsun;
|
}else if(weatherConditionCode == 801){//Few Clouds
|
||||||
}else if(weatherConditionCode == 800){//Clear
|
weatherIcon = cloudsun;
|
||||||
weatherIcon = sunny;
|
}else if(weatherConditionCode == 800){//Clear
|
||||||
}else if(weatherConditionCode >=700){//Atmosphere
|
weatherIcon = sunny;
|
||||||
weatherIcon = atmosphere;
|
}else if(weatherConditionCode >=700){//Atmosphere
|
||||||
}else if(weatherConditionCode >=600){//Snow
|
weatherIcon = atmosphere;
|
||||||
weatherIcon = snow;
|
}else if(weatherConditionCode >=600){//Snow
|
||||||
}else if(weatherConditionCode >=500){//Rain
|
weatherIcon = snow;
|
||||||
weatherIcon = rain;
|
}else if(weatherConditionCode >=500){//Rain
|
||||||
}else if(weatherConditionCode >=300){//Drizzle
|
weatherIcon = rain;
|
||||||
weatherIcon = drizzle;
|
}else if(weatherConditionCode >=300){//Drizzle
|
||||||
}else if(weatherConditionCode >=200){//Thunderstorm
|
weatherIcon = drizzle;
|
||||||
weatherIcon = thunderstorm;
|
}else if(weatherConditionCode >=200){//Thunderstorm
|
||||||
}else
|
weatherIcon = thunderstorm;
|
||||||
return;
|
}else
|
||||||
|
return;
|
||||||
|
}else{
|
||||||
|
weatherIcon = cputemp;
|
||||||
|
}
|
||||||
|
|
||||||
display.drawBitmap(145, 158, weatherIcon, WEATHER_ICON_WIDTH, WEATHER_ICON_HEIGHT, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
display.drawBitmap(145, 158, weatherIcon, WEATHER_ICON_WIDTH, WEATHER_ICON_HEIGHT, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,6 +150,21 @@ const unsigned char thunderstorm[] PROGMEM = {
|
||||||
0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x01,
|
0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||||
0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
};
|
};
|
||||||
|
// 'cputemp', 48x32px
|
||||||
|
const unsigned char cputemp [] PROGMEM = {
|
||||||
|
0x00, 0x01, 0x8c, 0xe7, 0x00, 0x00, 0x00, 0x01, 0x8c, 0xe7, 0x00, 0x00, 0x00, 0x01, 0x8c, 0xe7,
|
||||||
|
0x00, 0x00, 0x00, 0x01, 0x8c, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
|
||||||
|
0xff, 0xff, 0xe0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xe0, 0x00, 0x03, 0xef, 0xff, 0xff, 0xef, 0x80,
|
||||||
|
0x03, 0xef, 0xff, 0xff, 0xef, 0x80, 0x03, 0xef, 0xff, 0xff, 0xe7, 0x80, 0x00, 0x0f, 0xff, 0xff,
|
||||||
|
0xe0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xe0, 0x00, 0x03, 0xef, 0xff, 0xff, 0xef, 0x80, 0x03, 0xef,
|
||||||
|
0xff, 0xff, 0xef, 0x80, 0x00, 0x0f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xe0, 0x00,
|
||||||
|
0x00, 0x0f, 0xff, 0xff, 0xe0, 0x00, 0x03, 0xef, 0xff, 0xff, 0xef, 0x80, 0x03, 0xef, 0xff, 0xff,
|
||||||
|
0xef, 0x80, 0x00, 0x0f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x0f,
|
||||||
|
0xff, 0xff, 0xe0, 0x00, 0x03, 0xef, 0xff, 0xff, 0xef, 0x80, 0x03, 0xef, 0xff, 0xff, 0xef, 0x80,
|
||||||
|
0x00, 0x0f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x8c, 0xe7, 0x00, 0x00, 0x00, 0x01,
|
||||||
|
0x8c, 0xe7, 0x00, 0x00, 0x00, 0x01, 0x8c, 0xe7, 0x00, 0x00, 0x00, 0x01, 0x8c, 0xe7, 0x00, 0x00
|
||||||
|
};
|
||||||
// 'steps', 19x23px
|
// 'steps', 19x23px
|
||||||
const unsigned char steps [] PROGMEM = {
|
const unsigned char steps [] PROGMEM = {
|
||||||
0x00, 0x03, 0xc0, 0x00, 0x07, 0xe0, 0x00, 0x07, 0xe0, 0x00, 0x0f, 0xe0, 0x78, 0x0f, 0xe0, 0xfc,
|
0x00, 0x03, 0xc0, 0x00, 0x07, 0xe0, 0x00, 0x07, 0xe0, 0x00, 0x0f, 0xe0, 0x78, 0x0f, 0xe0, 0xfc,
|
||||||
|
@ -174,3 +189,19 @@ const unsigned char wifioff [] PROGMEM = {
|
||||||
0x01, 0xff, 0xc0, 0x00, 0x07, 0xe1, 0xc0, 0x00, 0x0f, 0xc0, 0x80, 0x00, 0x1f, 0x0c, 0x00, 0x00,
|
0x01, 0xff, 0xc0, 0x00, 0x07, 0xe1, 0xc0, 0x00, 0x0f, 0xc0, 0x80, 0x00, 0x1f, 0x0c, 0x00, 0x00,
|
||||||
0x3c, 0x1e, 0x00, 0x00, 0xf8, 0x0c, 0x00, 0x00
|
0x3c, 0x1e, 0x00, 0x00, 0xf8, 0x0c, 0x00, 0x00
|
||||||
};
|
};
|
||||||
|
// 'chip', 32x32px
|
||||||
|
const unsigned char chip [] PROGMEM = {
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x48, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x12, 0x48, 0x00, 0x00, 0x00, 0x00, 0x12, 0x48, 0x00, 0x00, 0x00, 0x00, 0x12, 0x48, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x1f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01,
|
||||||
|
0x00, 0x00, 0x00, 0x0f, 0x87, 0xf9, 0xf0, 0x00, 0x00, 0x00, 0x88, 0x09, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x90, 0x09, 0x00, 0x00, 0x00, 0x0f, 0x90, 0x09, 0xf0, 0x00, 0x00, 0x00, 0x90, 0x09, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x90, 0x09, 0x00, 0x00, 0x00, 0x0f, 0x90, 0x09, 0xf0, 0x00, 0x00, 0x00, 0x90, 0x09,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x90, 0x09, 0x00, 0x00, 0x00, 0x0f, 0x9f, 0xf9, 0xf0, 0x00, 0x00, 0x00,
|
||||||
|
0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x12, 0x48, 0x00, 0x00, 0x00, 0x00, 0x12, 0x48, 0x00, 0x00, 0x00, 0x00, 0x12, 0x48,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x12, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,18 @@
|
||||||
|
|
||||||
//Weather Settings
|
//Weather Settings
|
||||||
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
|
|
||||||
|
//You can also use LAT,LON for your location instead of CITY_ID, but not both
|
||||||
|
//#define LAT "40.7127" //New York City, Looked up on https://www.latlong.net/
|
||||||
|
//#define LON "-74.0059"
|
||||||
|
|
||||||
|
#ifdef CITY_ID
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?id={cityID}&lang={lang}&units={units}&appid={apiKey}" //open weather api using city ID
|
||||||
|
#else
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&lang={lang}&units={units}&appid={apiKey}" //open weather api using lat lon
|
||||||
|
#endif
|
||||||
|
|
||||||
#define OPENWEATHERMAP_APIKEY "f058fe1cad2afe8e2ddc5d063a64cecb" //use your own API key :)
|
#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_UNIT "metric" //metric = Celsius , imperial = Fahrenheit
|
||||||
#define TEMP_LANG "en"
|
#define TEMP_LANG "en"
|
||||||
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
||||||
|
@ -13,7 +23,13 @@
|
||||||
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data
|
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data
|
||||||
|
|
||||||
watchySettings settings{
|
watchySettings settings{
|
||||||
.cityID = CITY_ID,
|
#ifdef CITY_ID
|
||||||
|
.cityID = CITY_ID,
|
||||||
|
#else
|
||||||
|
.cityID = "",
|
||||||
|
.lat = LAT,
|
||||||
|
.lon = LON,
|
||||||
|
#endif
|
||||||
.weatherAPIKey = OPENWEATHERMAP_APIKEY,
|
.weatherAPIKey = OPENWEATHERMAP_APIKEY,
|
||||||
.weatherURL = OPENWEATHERMAP_URL,
|
.weatherURL = OPENWEATHERMAP_URL,
|
||||||
.weatherUnit = TEMP_UNIT,
|
.weatherUnit = TEMP_UNIT,
|
||||||
|
@ -24,4 +40,4 @@ watchySettings settings{
|
||||||
.vibrateOClock = true,
|
.vibrateOClock = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -3,8 +3,18 @@
|
||||||
|
|
||||||
//Weather Settings
|
//Weather Settings
|
||||||
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
|
|
||||||
|
//You can also use LAT,LON for your location instead of CITY_ID, but not both
|
||||||
|
//#define LAT "40.7127" //New York City, Looked up on https://www.latlong.net/
|
||||||
|
//#define LON "-74.0059"
|
||||||
|
|
||||||
|
#ifdef CITY_ID
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?id={cityID}&lang={lang}&units={units}&appid={apiKey}" //open weather api using city ID
|
||||||
|
#else
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&lang={lang}&units={units}&appid={apiKey}" //open weather api using lat lon
|
||||||
|
#endif
|
||||||
|
|
||||||
#define OPENWEATHERMAP_APIKEY "f058fe1cad2afe8e2ddc5d063a64cecb" //use your own API key :)
|
#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_UNIT "metric" //metric = Celsius , imperial = Fahrenheit
|
||||||
#define TEMP_LANG "en"
|
#define TEMP_LANG "en"
|
||||||
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
||||||
|
@ -13,7 +23,13 @@
|
||||||
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data
|
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data
|
||||||
|
|
||||||
watchySettings settings{
|
watchySettings settings{
|
||||||
.cityID = CITY_ID,
|
#ifdef CITY_ID
|
||||||
|
.cityID = CITY_ID,
|
||||||
|
#else
|
||||||
|
.cityID = "",
|
||||||
|
.lat = LAT,
|
||||||
|
.lon = LON,
|
||||||
|
#endif
|
||||||
.weatherAPIKey = OPENWEATHERMAP_APIKEY,
|
.weatherAPIKey = OPENWEATHERMAP_APIKEY,
|
||||||
.weatherURL = OPENWEATHERMAP_URL,
|
.weatherURL = OPENWEATHERMAP_URL,
|
||||||
.weatherUnit = TEMP_UNIT,
|
.weatherUnit = TEMP_UNIT,
|
||||||
|
@ -21,6 +37,7 @@ watchySettings settings{
|
||||||
.weatherUpdateInterval = WEATHER_UPDATE_INTERVAL,
|
.weatherUpdateInterval = WEATHER_UPDATE_INTERVAL,
|
||||||
.ntpServer = NTP_SERVER,
|
.ntpServer = NTP_SERVER,
|
||||||
.gmtOffset = GMT_OFFSET_SEC,
|
.gmtOffset = GMT_OFFSET_SEC,
|
||||||
|
.vibrateOClock = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -3,8 +3,18 @@
|
||||||
|
|
||||||
//Weather Settings
|
//Weather Settings
|
||||||
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
|
|
||||||
|
//You can also use LAT,LON for your location instead of CITY_ID, but not both
|
||||||
|
//#define LAT "40.7127" //New York City, Looked up on https://www.latlong.net/
|
||||||
|
//#define LON "-74.0059"
|
||||||
|
|
||||||
|
#ifdef CITY_ID
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?id={cityID}&lang={lang}&units={units}&appid={apiKey}" //open weather api using city ID
|
||||||
|
#else
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&lang={lang}&units={units}&appid={apiKey}" //open weather api using lat lon
|
||||||
|
#endif
|
||||||
|
|
||||||
#define OPENWEATHERMAP_APIKEY "f058fe1cad2afe8e2ddc5d063a64cecb" //use your own API key :)
|
#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_UNIT "metric" //metric = Celsius , imperial = Fahrenheit
|
||||||
#define TEMP_LANG "en"
|
#define TEMP_LANG "en"
|
||||||
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
||||||
|
@ -13,7 +23,13 @@
|
||||||
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data
|
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data
|
||||||
|
|
||||||
watchySettings settings{
|
watchySettings settings{
|
||||||
.cityID = CITY_ID,
|
#ifdef CITY_ID
|
||||||
|
.cityID = CITY_ID,
|
||||||
|
#else
|
||||||
|
.cityID = "",
|
||||||
|
.lat = LAT,
|
||||||
|
.lon = LON,
|
||||||
|
#endif
|
||||||
.weatherAPIKey = OPENWEATHERMAP_APIKEY,
|
.weatherAPIKey = OPENWEATHERMAP_APIKEY,
|
||||||
.weatherURL = OPENWEATHERMAP_URL,
|
.weatherURL = OPENWEATHERMAP_URL,
|
||||||
.weatherUnit = TEMP_UNIT,
|
.weatherUnit = TEMP_UNIT,
|
||||||
|
@ -21,6 +37,7 @@ watchySettings settings{
|
||||||
.weatherUpdateInterval = WEATHER_UPDATE_INTERVAL,
|
.weatherUpdateInterval = WEATHER_UPDATE_INTERVAL,
|
||||||
.ntpServer = NTP_SERVER,
|
.ntpServer = NTP_SERVER,
|
||||||
.gmtOffset = GMT_OFFSET_SEC,
|
.gmtOffset = GMT_OFFSET_SEC,
|
||||||
|
.vibrateOClock = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -3,8 +3,18 @@
|
||||||
|
|
||||||
//Weather Settings
|
//Weather Settings
|
||||||
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
|
|
||||||
|
//You can also use LAT,LON for your location instead of CITY_ID, but not both
|
||||||
|
//#define LAT "40.7127" //New York City, Looked up on https://www.latlong.net/
|
||||||
|
//#define LON "-74.0059"
|
||||||
|
|
||||||
|
#ifdef CITY_ID
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?id={cityID}&lang={lang}&units={units}&appid={apiKey}" //open weather api using city ID
|
||||||
|
#else
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&lang={lang}&units={units}&appid={apiKey}" //open weather api using lat lon
|
||||||
|
#endif
|
||||||
|
|
||||||
#define OPENWEATHERMAP_APIKEY "f058fe1cad2afe8e2ddc5d063a64cecb" //use your own API key :)
|
#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_UNIT "metric" //metric = Celsius , imperial = Fahrenheit
|
||||||
#define TEMP_LANG "en"
|
#define TEMP_LANG "en"
|
||||||
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
||||||
|
@ -13,7 +23,13 @@
|
||||||
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data
|
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data
|
||||||
|
|
||||||
watchySettings settings{
|
watchySettings settings{
|
||||||
.cityID = CITY_ID,
|
#ifdef CITY_ID
|
||||||
|
.cityID = CITY_ID,
|
||||||
|
#else
|
||||||
|
.cityID = "",
|
||||||
|
.lat = LAT,
|
||||||
|
.lon = LON,
|
||||||
|
#endif
|
||||||
.weatherAPIKey = OPENWEATHERMAP_APIKEY,
|
.weatherAPIKey = OPENWEATHERMAP_APIKEY,
|
||||||
.weatherURL = OPENWEATHERMAP_URL,
|
.weatherURL = OPENWEATHERMAP_URL,
|
||||||
.weatherUnit = TEMP_UNIT,
|
.weatherUnit = TEMP_UNIT,
|
||||||
|
@ -21,6 +37,7 @@ watchySettings settings{
|
||||||
.weatherUpdateInterval = WEATHER_UPDATE_INTERVAL,
|
.weatherUpdateInterval = WEATHER_UPDATE_INTERVAL,
|
||||||
.ntpServer = NTP_SERVER,
|
.ntpServer = NTP_SERVER,
|
||||||
.gmtOffset = GMT_OFFSET_SEC,
|
.gmtOffset = GMT_OFFSET_SEC,
|
||||||
|
.vibrateOClock = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -3,8 +3,18 @@
|
||||||
|
|
||||||
//Weather Settings
|
//Weather Settings
|
||||||
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
|
|
||||||
|
//You can also use LAT,LON for your location instead of CITY_ID, but not both
|
||||||
|
//#define LAT "40.7127" //New York City, Looked up on https://www.latlong.net/
|
||||||
|
//#define LON "-74.0059"
|
||||||
|
|
||||||
|
#ifdef CITY_ID
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?id={cityID}&lang={lang}&units={units}&appid={apiKey}" //open weather api using city ID
|
||||||
|
#else
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&lang={lang}&units={units}&appid={apiKey}" //open weather api using lat lon
|
||||||
|
#endif
|
||||||
|
|
||||||
#define OPENWEATHERMAP_APIKEY "f058fe1cad2afe8e2ddc5d063a64cecb" //use your own API key :)
|
#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_UNIT "metric" //metric = Celsius , imperial = Fahrenheit
|
||||||
#define TEMP_LANG "en"
|
#define TEMP_LANG "en"
|
||||||
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
||||||
|
@ -13,7 +23,13 @@
|
||||||
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data
|
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data
|
||||||
|
|
||||||
watchySettings settings{
|
watchySettings settings{
|
||||||
.cityID = CITY_ID,
|
#ifdef CITY_ID
|
||||||
|
.cityID = CITY_ID,
|
||||||
|
#else
|
||||||
|
.cityID = "",
|
||||||
|
.lat = LAT,
|
||||||
|
.lon = LON,
|
||||||
|
#endif
|
||||||
.weatherAPIKey = OPENWEATHERMAP_APIKEY,
|
.weatherAPIKey = OPENWEATHERMAP_APIKEY,
|
||||||
.weatherURL = OPENWEATHERMAP_URL,
|
.weatherURL = OPENWEATHERMAP_URL,
|
||||||
.weatherUnit = TEMP_UNIT,
|
.weatherUnit = TEMP_UNIT,
|
||||||
|
@ -24,4 +40,4 @@ watchySettings settings{
|
||||||
.vibrateOClock = true,
|
.vibrateOClock = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -3,8 +3,18 @@
|
||||||
|
|
||||||
//Weather Settings
|
//Weather Settings
|
||||||
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
|
|
||||||
|
//You can also use LAT,LON for your location instead of CITY_ID, but not both
|
||||||
|
//#define LAT "40.7127" //New York City, Looked up on https://www.latlong.net/
|
||||||
|
//#define LON "-74.0059"
|
||||||
|
|
||||||
|
#ifdef CITY_ID
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?id={cityID}&lang={lang}&units={units}&appid={apiKey}" //open weather api using city ID
|
||||||
|
#else
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&lang={lang}&units={units}&appid={apiKey}" //open weather api using lat lon
|
||||||
|
#endif
|
||||||
|
|
||||||
#define OPENWEATHERMAP_APIKEY "f058fe1cad2afe8e2ddc5d063a64cecb" //use your own API key :)
|
#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_UNIT "metric" //metric = Celsius , imperial = Fahrenheit
|
||||||
#define TEMP_LANG "en"
|
#define TEMP_LANG "en"
|
||||||
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
||||||
|
@ -13,7 +23,13 @@
|
||||||
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data
|
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data
|
||||||
|
|
||||||
watchySettings settings{
|
watchySettings settings{
|
||||||
.cityID = CITY_ID,
|
#ifdef CITY_ID
|
||||||
|
.cityID = CITY_ID,
|
||||||
|
#else
|
||||||
|
.cityID = "",
|
||||||
|
.lat = LAT,
|
||||||
|
.lon = LON,
|
||||||
|
#endif
|
||||||
.weatherAPIKey = OPENWEATHERMAP_APIKEY,
|
.weatherAPIKey = OPENWEATHERMAP_APIKEY,
|
||||||
.weatherURL = OPENWEATHERMAP_URL,
|
.weatherURL = OPENWEATHERMAP_URL,
|
||||||
.weatherUnit = TEMP_UNIT,
|
.weatherUnit = TEMP_UNIT,
|
||||||
|
@ -21,6 +37,7 @@ watchySettings settings{
|
||||||
.weatherUpdateInterval = WEATHER_UPDATE_INTERVAL,
|
.weatherUpdateInterval = WEATHER_UPDATE_INTERVAL,
|
||||||
.ntpServer = NTP_SERVER,
|
.ntpServer = NTP_SERVER,
|
||||||
.gmtOffset = GMT_OFFSET_SEC,
|
.gmtOffset = GMT_OFFSET_SEC,
|
||||||
|
.vibrateOClock = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -3,8 +3,18 @@
|
||||||
|
|
||||||
//Weather Settings
|
//Weather Settings
|
||||||
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
|
|
||||||
|
//You can also use LAT,LON for your location instead of CITY_ID, but not both
|
||||||
|
//#define LAT "40.7127" //New York City, Looked up on https://www.latlong.net/
|
||||||
|
//#define LON "-74.0059"
|
||||||
|
|
||||||
|
#ifdef CITY_ID
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?id={cityID}&lang={lang}&units={units}&appid={apiKey}" //open weather api using city ID
|
||||||
|
#else
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&lang={lang}&units={units}&appid={apiKey}" //open weather api using lat lon
|
||||||
|
#endif
|
||||||
|
|
||||||
#define OPENWEATHERMAP_APIKEY "f058fe1cad2afe8e2ddc5d063a64cecb" //use your own API key :)
|
#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_UNIT "metric" //metric = Celsius , imperial = Fahrenheit
|
||||||
#define TEMP_LANG "en"
|
#define TEMP_LANG "en"
|
||||||
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
||||||
|
@ -13,7 +23,13 @@
|
||||||
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data
|
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data
|
||||||
|
|
||||||
watchySettings settings{
|
watchySettings settings{
|
||||||
.cityID = CITY_ID,
|
#ifdef CITY_ID
|
||||||
|
.cityID = CITY_ID,
|
||||||
|
#else
|
||||||
|
.cityID = "",
|
||||||
|
.lat = LAT,
|
||||||
|
.lon = LON,
|
||||||
|
#endif
|
||||||
.weatherAPIKey = OPENWEATHERMAP_APIKEY,
|
.weatherAPIKey = OPENWEATHERMAP_APIKEY,
|
||||||
.weatherURL = OPENWEATHERMAP_URL,
|
.weatherURL = OPENWEATHERMAP_URL,
|
||||||
.weatherUnit = TEMP_UNIT,
|
.weatherUnit = TEMP_UNIT,
|
||||||
|
@ -21,6 +37,7 @@ watchySettings settings{
|
||||||
.weatherUpdateInterval = WEATHER_UPDATE_INTERVAL,
|
.weatherUpdateInterval = WEATHER_UPDATE_INTERVAL,
|
||||||
.ntpServer = NTP_SERVER,
|
.ntpServer = NTP_SERVER,
|
||||||
.gmtOffset = GMT_OFFSET_SEC,
|
.gmtOffset = GMT_OFFSET_SEC,
|
||||||
|
.vibrateOClock = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -3,8 +3,18 @@
|
||||||
|
|
||||||
//Weather Settings
|
//Weather Settings
|
||||||
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
|
|
||||||
|
//You can also use LAT,LON for your location instead of CITY_ID, but not both
|
||||||
|
//#define LAT "40.7127" //New York City, Looked up on https://www.latlong.net/
|
||||||
|
//#define LON "-74.0059"
|
||||||
|
|
||||||
|
#ifdef CITY_ID
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?id={cityID}&lang={lang}&units={units}&appid={apiKey}" //open weather api using city ID
|
||||||
|
#else
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&lang={lang}&units={units}&appid={apiKey}" //open weather api using lat lon
|
||||||
|
#endif
|
||||||
|
|
||||||
#define OPENWEATHERMAP_APIKEY "f058fe1cad2afe8e2ddc5d063a64cecb" //use your own API key :)
|
#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_UNIT "metric" //metric = Celsius , imperial = Fahrenheit
|
||||||
#define TEMP_LANG "en"
|
#define TEMP_LANG "en"
|
||||||
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
||||||
|
@ -13,7 +23,13 @@
|
||||||
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data
|
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data
|
||||||
|
|
||||||
watchySettings settings{
|
watchySettings settings{
|
||||||
.cityID = CITY_ID,
|
#ifdef CITY_ID
|
||||||
|
.cityID = CITY_ID,
|
||||||
|
#else
|
||||||
|
.cityID = "",
|
||||||
|
.lat = LAT,
|
||||||
|
.lon = LON,
|
||||||
|
#endif
|
||||||
.weatherAPIKey = OPENWEATHERMAP_APIKEY,
|
.weatherAPIKey = OPENWEATHERMAP_APIKEY,
|
||||||
.weatherURL = OPENWEATHERMAP_URL,
|
.weatherURL = OPENWEATHERMAP_URL,
|
||||||
.weatherUnit = TEMP_UNIT,
|
.weatherUnit = TEMP_UNIT,
|
||||||
|
@ -21,6 +37,7 @@ watchySettings settings{
|
||||||
.weatherUpdateInterval = WEATHER_UPDATE_INTERVAL,
|
.weatherUpdateInterval = WEATHER_UPDATE_INTERVAL,
|
||||||
.ntpServer = NTP_SERVER,
|
.ntpServer = NTP_SERVER,
|
||||||
.gmtOffset = GMT_OFFSET_SEC,
|
.gmtOffset = GMT_OFFSET_SEC,
|
||||||
|
.vibrateOClock = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -337,7 +337,7 @@ void Watchy::showAbout() {
|
||||||
display.print("h");
|
display.print("h");
|
||||||
display.print(minutes);
|
display.print(minutes);
|
||||||
display.println("m");
|
display.println("m");
|
||||||
if(WIFI_CONFIGURED){
|
if(connectWiFi()){
|
||||||
display.print("SSID: ");
|
display.print("SSID: ");
|
||||||
display.println(WiFi.SSID());
|
display.println(WiFi.SSID());
|
||||||
display.println("IP: ");
|
display.println("IP: ");
|
||||||
|
@ -625,12 +625,12 @@ void Watchy::drawWatchFace() {
|
||||||
}
|
}
|
||||||
|
|
||||||
weatherData Watchy::getWeatherData() {
|
weatherData Watchy::getWeatherData() {
|
||||||
return getWeatherData(settings.cityID, settings.weatherUnit,
|
return _getWeatherData(settings.cityID, settings.lat, settings.lon,
|
||||||
settings.weatherLang, settings.weatherURL,
|
settings.weatherUnit, settings.weatherLang, settings.weatherURL,
|
||||||
settings.weatherAPIKey, settings.weatherUpdateInterval);
|
settings.weatherAPIKey, settings.weatherUpdateInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
weatherData Watchy::getWeatherData(String cityID, String units, String lang,
|
weatherData Watchy::_getWeatherData(String cityID, String lat, String lon, String units, String lang,
|
||||||
String url, String apiKey,
|
String url, String apiKey,
|
||||||
uint8_t updateInterval) {
|
uint8_t updateInterval) {
|
||||||
currentWeather.isMetric = units == String("metric");
|
currentWeather.isMetric = units == String("metric");
|
||||||
|
@ -643,9 +643,16 @@ weatherData Watchy::getWeatherData(String cityID, String units, String lang,
|
||||||
if (connectWiFi()) {
|
if (connectWiFi()) {
|
||||||
HTTPClient http; // Use Weather API for live data if WiFi is connected
|
HTTPClient http; // Use Weather API for live data if WiFi is connected
|
||||||
http.setConnectTimeout(3000); // 3 second max timeout
|
http.setConnectTimeout(3000); // 3 second max timeout
|
||||||
String weatherQueryURL = url + cityID + String("&units=") + units +
|
String weatherQueryURL = url;
|
||||||
String("&lang=") + lang + String("&appid=") +
|
if(cityID != ""){
|
||||||
apiKey;
|
weatherQueryURL.replace("{cityID}", cityID);
|
||||||
|
}else{
|
||||||
|
weatherQueryURL.replace("{lat}", lat);
|
||||||
|
weatherQueryURL.replace("{lon}", lon);
|
||||||
|
}
|
||||||
|
weatherQueryURL.replace("{units}", units);
|
||||||
|
weatherQueryURL.replace("{lang}", lang);
|
||||||
|
weatherQueryURL.replace("{apiKey}", apiKey);
|
||||||
http.begin(weatherQueryURL.c_str());
|
http.begin(weatherQueryURL.c_str());
|
||||||
int httpResponseCode = http.GET();
|
int httpResponseCode = http.GET();
|
||||||
if (httpResponseCode == 200) {
|
if (httpResponseCode == 200) {
|
||||||
|
@ -655,9 +662,11 @@ weatherData Watchy::getWeatherData(String cityID, String units, String lang,
|
||||||
currentWeather.weatherConditionCode =
|
currentWeather.weatherConditionCode =
|
||||||
int(responseObject["weather"][0]["id"]);
|
int(responseObject["weather"][0]["id"]);
|
||||||
currentWeather.weatherDescription =
|
currentWeather.weatherDescription =
|
||||||
JSONVar::stringify(responseObject["weather"][0]["main"]);
|
JSONVar::stringify(responseObject["weather"][0]["main"]);
|
||||||
currentWeather.external = true;
|
currentWeather.external = true;
|
||||||
// sync NTP during weather API call and use timezone of city
|
breakTime((time_t)(int)responseObject["sys"]["sunrise"], currentWeather.sunrise);
|
||||||
|
breakTime((time_t)(int)responseObject["sys"]["sunset"], currentWeather.sunset);
|
||||||
|
// sync NTP during weather API call and use timezone of lat & lon
|
||||||
gmtOffset = int(responseObject["timezone"]);
|
gmtOffset = int(responseObject["timezone"]);
|
||||||
syncNTP(gmtOffset);
|
syncNTP(gmtOffset);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -23,11 +23,15 @@ typedef struct weatherData {
|
||||||
bool isMetric;
|
bool isMetric;
|
||||||
String weatherDescription;
|
String weatherDescription;
|
||||||
bool external;
|
bool external;
|
||||||
|
tmElements_t sunrise;
|
||||||
|
tmElements_t sunset;
|
||||||
} weatherData;
|
} weatherData;
|
||||||
|
|
||||||
typedef struct watchySettings {
|
typedef struct watchySettings {
|
||||||
// Weather Settings
|
// Weather Settings
|
||||||
String cityID;
|
String cityID;
|
||||||
|
String lat;
|
||||||
|
String lon;
|
||||||
String weatherAPIKey;
|
String weatherAPIKey;
|
||||||
String weatherURL;
|
String weatherURL;
|
||||||
String weatherUnit;
|
String weatherUnit;
|
||||||
|
@ -69,8 +73,6 @@ public:
|
||||||
void setupWifi();
|
void setupWifi();
|
||||||
bool connectWiFi();
|
bool connectWiFi();
|
||||||
weatherData getWeatherData();
|
weatherData getWeatherData();
|
||||||
weatherData getWeatherData(String cityID, String units, String lang,
|
|
||||||
String url, String apiKey, uint8_t updateInterval);
|
|
||||||
void updateFWBegin();
|
void updateFWBegin();
|
||||||
|
|
||||||
void showWatchFace(bool partialRefresh);
|
void showWatchFace(bool partialRefresh);
|
||||||
|
@ -84,6 +86,8 @@ private:
|
||||||
uint16_t len);
|
uint16_t len);
|
||||||
static uint16_t _writeRegister(uint8_t address, uint8_t reg, uint8_t *data,
|
static uint16_t _writeRegister(uint8_t address, uint8_t reg, uint8_t *data,
|
||||||
uint16_t len);
|
uint16_t len);
|
||||||
|
weatherData _getWeatherData(String cityID, String lat, String lon, String units, String lang,
|
||||||
|
String url, String apiKey, uint8_t updateInterval);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern RTC_DATA_ATTR int guiState;
|
extern RTC_DATA_ATTR int guiState;
|
||||||
|
|
Loading…
Reference in New Issue