mirror of https://github.com/sqfmi/Watchy.git
Properly handle metric temperature w/o wifi
parent
c5b43d2eac
commit
a7637604b4
|
@ -571,6 +571,7 @@ weatherData Watchy::getWeatherData(){
|
||||||
}
|
}
|
||||||
|
|
||||||
weatherData Watchy::getWeatherData(String cityID, String units, String lang, String url, String apiKey, uint8_t updateInterval){
|
weatherData Watchy::getWeatherData(String cityID, String units, String lang, String url, String apiKey, uint8_t updateInterval){
|
||||||
|
currentWeather.isMetric = settings.weatherUnit == String("metric");
|
||||||
if(weatherIntervalCounter < 0){ //-1 on first run, set to updateInterval
|
if(weatherIntervalCounter < 0){ //-1 on first run, set to updateInterval
|
||||||
weatherIntervalCounter = updateInterval;
|
weatherIntervalCounter = updateInterval;
|
||||||
}
|
}
|
||||||
|
@ -585,7 +586,6 @@ weatherData Watchy::getWeatherData(String cityID, String units, String lang, Str
|
||||||
String payload = http.getString();
|
String payload = http.getString();
|
||||||
JSONVar responseObject = JSON.parse(payload);
|
JSONVar responseObject = JSON.parse(payload);
|
||||||
currentWeather.temperature = int(responseObject["main"]["temp"]);
|
currentWeather.temperature = int(responseObject["main"]["temp"]);
|
||||||
currentWeather.isMetric = settings.weatherUnit == String("metric");
|
|
||||||
currentWeather.weatherConditionCode = int(responseObject["weather"][0]["id"]);
|
currentWeather.weatherConditionCode = int(responseObject["weather"][0]["id"]);
|
||||||
currentWeather.weatherDescription = responseObject["weather"][0]["main"];
|
currentWeather.weatherDescription = responseObject["weather"][0]["main"];
|
||||||
}else{
|
}else{
|
||||||
|
@ -597,7 +597,7 @@ weatherData Watchy::getWeatherData(String cityID, String units, String lang, Str
|
||||||
btStop();
|
btStop();
|
||||||
}else{//No WiFi, use internal temperature sensor
|
}else{//No WiFi, use internal temperature sensor
|
||||||
uint8_t temperature = sensor.readTemperature(); //celsius
|
uint8_t temperature = sensor.readTemperature(); //celsius
|
||||||
if(units != String("metric")){
|
if(!currentWeather.isMetric){
|
||||||
temperature = temperature * 9. / 5. + 32.; //fahrenheit
|
temperature = temperature * 9. / 5. + 32.; //fahrenheit
|
||||||
}
|
}
|
||||||
currentWeather.temperature = temperature;
|
currentWeather.temperature = temperature;
|
||||||
|
|
Loading…
Reference in New Issue