| 1040 | } |
| 1041 | |
| 1042 | void drawWeather(String &filename, JsonObject &cfgobj, const tagRecord *taginfo, imgParam &imageParams) { |
| 1043 | wsLog("get weather"); |
| 1044 | |
| 1045 | getLocation(cfgobj); |
| 1046 | |
| 1047 | const String lat = cfgobj["#lat"]; |
| 1048 | const String lon = cfgobj["#lon"]; |
| 1049 | const String tz = cfgobj["#tz"]; |
| 1050 | String units = ""; |
| 1051 | if (cfgobj["units"] == "1") { |
| 1052 | units += "&temperature_unit=fahrenheit&windspeed_unit=mph&precipitation_unit=inch"; |
| 1053 | } |
| 1054 | |
| 1055 | JsonDocument doc; |
| 1056 | const bool success = util::httpGetJson("https://api.open-meteo.com/v1/forecast?latitude=" + lat + "&longitude=" + lon + "¤t_weather=true&windspeed_unit=ms&timezone=" + tz + units, doc, 5000); |
| 1057 | if (!success) { |
| 1058 | return; |
| 1059 | } |
| 1060 | JsonDocument loc; |
| 1061 | getTemplate(loc, 4, taginfo->hwType); |
| 1062 | |
| 1063 | TFT_eSprite spr = TFT_eSprite(&tft); |
| 1064 | tft.setTextWrap(false, false); |
| 1065 | initSprite(spr, imageParams.width, imageParams.height, imageParams); |
| 1066 | |
| 1067 | drawWeatherContent(doc, loc, spr, cfgobj, imageParams); |
| 1068 | |
| 1069 | spr2buffer(spr, filename, imageParams); |
| 1070 | spr.deleteSprite(); |
| 1071 | } |
| 1072 | |
| 1073 | void drawForecast(String &filename, JsonObject &cfgobj, const tagRecord *taginfo, imgParam &imageParams) { |
| 1074 | wsLog("get weather"); |
no test coverage detected