MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / drawWeather

Function drawWeather

ESP32_AP-Flasher/src/contentmanager.cpp:1042–1071  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1040}
1041
1042void 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 + "&current_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
1073void drawForecast(String &filename, JsonObject &cfgobj, const tagRecord *taginfo, imgParam &imageParams) {
1074 wsLog("get weather");

Callers 1

drawNewFunction · 0.85

Calls 8

wsLogFunction · 0.85
getLocationFunction · 0.85
httpGetJsonFunction · 0.85
getTemplateFunction · 0.85
initSpriteFunction · 0.85
drawWeatherContentFunction · 0.85
spr2bufferFunction · 0.85
setTextWrapMethod · 0.80

Tested by

no test coverage detected