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

Function getCalFeed

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

Source from the content-addressed store, hash-verified

1312
1313#ifdef CONTENT_CAL
1314bool getCalFeed(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, imgParam &imageParams) {
1315 // google apps scripts method to retrieve calendar
1316 // see https://github.com/OpenEPaperLink/OpenEPaperLink/wiki/Google-Apps-Scripts for description
1317
1318 wsLog("get calendar");
1319
1320 JsonDocument loc;
1321 getTemplate(loc, 11, taginfo->hwType);
1322
1323 String URL = cfgobj["apps_script_url"].as<String>() + "?days=" + loc["days"].as<String>();
1324
1325 time_t now;
1326 time(&now);
1327 struct tm timeinfo;
1328 localtime_r(&now, &timeinfo);
1329 char dateString[40];
1330 strftime(dateString, sizeof(dateString), languageDateFormat[0].c_str(), &timeinfo);
1331
1332 HTTPClient http;
1333 // logLine("http getCalFeed " + URL);
1334 http.begin(URL);
1335 http.setTimeout(10000);
1336 http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
1337 int httpCode = http.GET();
1338 if (httpCode != 200) {
1339 wsErr("getCalFeed http error " + String(httpCode));
1340 return false;
1341 }
1342
1343 JsonDocument doc;
1344 DeserializationError error = deserializeJson(doc, http.getString());
1345 if (error) {
1346 wsErr(error.c_str());
1347 }
1348 http.end();
1349
1350 TFT_eSprite spr = TFT_eSprite(&tft);
1351
1352 if (loc["rotate"] == 1) {
1353 int temp = imageParams.height;
1354 imageParams.height = imageParams.width;
1355 imageParams.width = temp;
1356 imageParams.rotatebuffer = 1 - (imageParams.rotatebuffer % 2);
1357 initSprite(spr, imageParams.width, imageParams.height, imageParams);
1358 } else {
1359 initSprite(spr, imageParams.width, imageParams.height, imageParams);
1360 }
1361
1362 switch (loc["mode"].as<int>()) {
1363 case 0: {
1364 // appointment list
1365 String title = cfgobj["title"];
1366 if (util::isEmptyOrNull(title)) title = "Calendar";
1367 drawString(spr, title, loc["title"][0], loc["title"][1], loc["title"][2], TL_DATUM, TFT_BLACK);
1368 drawString(spr, dateString, loc["date"][0], loc["date"][1], loc["title"][2], TR_DATUM, TFT_BLACK);
1369
1370 int n = doc.size();
1371 if (n > loc["items"]) n = loc["items"];

Callers 1

drawNewFunction · 0.85

Calls 15

wsLogFunction · 0.85
getTemplateFunction · 0.85
wsErrFunction · 0.85
initSpriteFunction · 0.85
isEmptyOrNullFunction · 0.85
drawStringFunction · 0.85
epoch_to_displayFunction · 0.85
getColorFunction · 0.85
drawTextBoxFunction · 0.85
spr2bufferFunction · 0.85
fillRectMethod · 0.80
drawLineMethod · 0.80

Tested by

no test coverage detected