mirror of https://github.com/sqfmi/Watchy.git
getWeatherData to accept cityID or lat lon
parent
b84ab91c6b
commit
aa3528371d
|
@ -2,10 +2,19 @@
|
||||||
#define SETTINGS_H
|
#define SETTINGS_H
|
||||||
|
|
||||||
//Weather Settings
|
//Weather Settings
|
||||||
#define LAT "45.793411" // New York City, Looked up on https://www.latlong.net/
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
#define LON "-97.751968"
|
|
||||||
|
//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?lat={lat}&lon={lon}&lang={lang}&units={units}&appid={apiKey}" //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
|
||||||
|
@ -14,8 +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{
|
||||||
.lat = LAT,
|
#ifdef CITY_ID
|
||||||
.lon = LON,
|
.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,
|
||||||
|
@ -26,4 +40,4 @@ watchySettings settings{
|
||||||
.vibrateOClock = true,
|
.vibrateOClock = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -2,10 +2,19 @@
|
||||||
#define SETTINGS_H
|
#define SETTINGS_H
|
||||||
|
|
||||||
//Weather Settings
|
//Weather Settings
|
||||||
#define LAT "45.793411" // New York City, Looked up on https://www.latlong.net/
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
#define LON "-97.751968"
|
|
||||||
|
//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?lat={lat}&lon={lon}&lang={lang}&units={units}&appid={apiKey}" //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
|
||||||
|
@ -14,8 +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{
|
||||||
.lat = LAT,
|
#ifdef CITY_ID
|
||||||
.lon = LON,
|
.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,
|
||||||
|
@ -23,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
|
|
@ -2,10 +2,19 @@
|
||||||
#define SETTINGS_H
|
#define SETTINGS_H
|
||||||
|
|
||||||
//Weather Settings
|
//Weather Settings
|
||||||
#define LAT "45.793411" // New York City, Looked up on https://www.latlong.net/
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
#define LON "-97.751968"
|
|
||||||
|
//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?lat={lat}&lon={lon}&lang={lang}&units={units}&appid={apiKey}" //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
|
||||||
|
@ -14,8 +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{
|
||||||
.lat = LAT,
|
#ifdef CITY_ID
|
||||||
.lon = LON,
|
.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,
|
||||||
|
@ -23,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
|
|
@ -2,10 +2,19 @@
|
||||||
#define SETTINGS_H
|
#define SETTINGS_H
|
||||||
|
|
||||||
//Weather Settings
|
//Weather Settings
|
||||||
#define LAT "45.793411" // New York City, Looked up on https://www.latlong.net/
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
#define LON "-97.751968"
|
|
||||||
|
//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?lat={lat}&lon={lon}&lang={lang}&units={units}&appid={apiKey}" //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
|
||||||
|
@ -14,8 +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{
|
||||||
.lat = LAT,
|
#ifdef CITY_ID
|
||||||
.lon = LON,
|
.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,
|
||||||
|
@ -23,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
|
|
@ -2,10 +2,19 @@
|
||||||
#define SETTINGS_H
|
#define SETTINGS_H
|
||||||
|
|
||||||
//Weather Settings
|
//Weather Settings
|
||||||
#define LAT "45.793411" // New York City, Looked up on https://www.latlong.net/
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
#define LON "-97.751968"
|
|
||||||
|
//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?lat={lat}&lon={lon}&lang={lang}&units={units}&appid={apiKey}" //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
|
||||||
|
@ -14,8 +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{
|
||||||
.lat = LAT,
|
#ifdef CITY_ID
|
||||||
.lon = LON,
|
.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,
|
||||||
|
@ -26,4 +40,4 @@ watchySettings settings{
|
||||||
.vibrateOClock = true,
|
.vibrateOClock = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -2,10 +2,19 @@
|
||||||
#define SETTINGS_H
|
#define SETTINGS_H
|
||||||
|
|
||||||
//Weather Settings
|
//Weather Settings
|
||||||
#define LAT "45.793411" // New York City, Looked up on https://www.latlong.net/
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
#define LON "-97.751968"
|
|
||||||
|
//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?lat={lat}&lon={lon}&lang={lang}&units={units}&appid={apiKey}" //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
|
||||||
|
@ -14,8 +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{
|
||||||
.lat = LAT,
|
#ifdef CITY_ID
|
||||||
.lon = LON,
|
.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,
|
||||||
|
@ -23,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
|
|
@ -2,10 +2,19 @@
|
||||||
#define SETTINGS_H
|
#define SETTINGS_H
|
||||||
|
|
||||||
//Weather Settings
|
//Weather Settings
|
||||||
#define LAT "45.793411" // New York City, Looked up on https://www.latlong.net/
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
#define LON "-97.751968"
|
|
||||||
|
//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?lat={lat}&lon={lon}&lang={lang}&units={units}&appid={apiKey}" //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
|
||||||
|
@ -14,8 +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{
|
||||||
.lat = LAT,
|
#ifdef CITY_ID
|
||||||
.lon = LON,
|
.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,
|
||||||
|
@ -23,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
|
|
@ -2,10 +2,19 @@
|
||||||
#define SETTINGS_H
|
#define SETTINGS_H
|
||||||
|
|
||||||
//Weather Settings
|
//Weather Settings
|
||||||
#define LAT "45.793411" // New York City, Looked up on https://www.latlong.net/
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
#define LON "-97.751968"
|
|
||||||
|
//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?lat={lat}&lon={lon}&lang={lang}&units={units}&appid={apiKey}" //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
|
||||||
|
@ -14,8 +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{
|
||||||
.lat = LAT,
|
#ifdef CITY_ID
|
||||||
.lon = LON,
|
.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,
|
||||||
|
@ -23,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
|
|
@ -626,12 +626,12 @@ void Watchy::drawWatchFace() {
|
||||||
}
|
}
|
||||||
|
|
||||||
weatherData Watchy::getWeatherData() {
|
weatherData Watchy::getWeatherData() {
|
||||||
return getWeatherData(settings.lat, settings.lon, 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 lat, String lon, 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");
|
||||||
|
@ -645,8 +645,12 @@ weatherData Watchy::getWeatherData(String lat, String lon, String units, String
|
||||||
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;
|
String weatherQueryURL = url;
|
||||||
weatherQueryURL.replace("{lat}", lat);
|
if(cityID != ""){
|
||||||
weatherQueryURL.replace("{lon}", lon);
|
weatherQueryURL.replace("{cityID}", cityID);
|
||||||
|
}else{
|
||||||
|
weatherQueryURL.replace("{lat}", lat);
|
||||||
|
weatherQueryURL.replace("{lon}", lon);
|
||||||
|
}
|
||||||
weatherQueryURL.replace("{units}", units);
|
weatherQueryURL.replace("{units}", units);
|
||||||
weatherQueryURL.replace("{lang}", lang);
|
weatherQueryURL.replace("{lang}", lang);
|
||||||
weatherQueryURL.replace("{apiKey}", apiKey);
|
weatherQueryURL.replace("{apiKey}", apiKey);
|
||||||
|
@ -659,10 +663,10 @@ weatherData Watchy::getWeatherData(String lat, String lon, String units, String
|
||||||
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;
|
||||||
breakTime((time_t)(int)responseObject["sys"]["sunrise"], currentWeather.sunrise);
|
breakTime((time_t)(int)responseObject["sys"]["sunrise"], currentWeather.sunrise);
|
||||||
breakTime((time_t)(int)responseObject["sys"]["sunset"], currentWeather.sunset);
|
breakTime((time_t)(int)responseObject["sys"]["sunset"], currentWeather.sunset);
|
||||||
// sync NTP during weather API call and use timezone of lat & lon
|
// sync NTP during weather API call and use timezone of lat & lon
|
||||||
gmtOffset = int(responseObject["timezone"]);
|
gmtOffset = int(responseObject["timezone"]);
|
||||||
syncNTP(gmtOffset);
|
syncNTP(gmtOffset);
|
||||||
|
|
|
@ -29,6 +29,7 @@ typedef struct weatherData {
|
||||||
|
|
||||||
typedef struct watchySettings {
|
typedef struct watchySettings {
|
||||||
// Weather Settings
|
// Weather Settings
|
||||||
|
String cityID;
|
||||||
String lat;
|
String lat;
|
||||||
String lon;
|
String lon;
|
||||||
String weatherAPIKey;
|
String weatherAPIKey;
|
||||||
|
@ -73,8 +74,6 @@ public:
|
||||||
void setupWifi();
|
void setupWifi();
|
||||||
bool connectWiFi();
|
bool connectWiFi();
|
||||||
weatherData getWeatherData();
|
weatherData getWeatherData();
|
||||||
weatherData getWeatherData(String lat, String lon, String units, String lang,
|
|
||||||
String url, String apiKey, uint8_t updateInterval);
|
|
||||||
void updateFWBegin();
|
void updateFWBegin();
|
||||||
|
|
||||||
void showWatchFace(bool partialRefresh);
|
void showWatchFace(bool partialRefresh);
|
||||||
|
@ -88,6 +87,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