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

Function drawQR

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

Source from the content-addressed store, hash-verified

2348
2349#ifdef CONTENT_QR
2350void drawQR(String &filename, String qrcontent, String title, tagRecord *&taginfo, imgParam &imageParams) {
2351 TFT_eSprite spr = TFT_eSprite(&tft);
2352
2353 const char *text = qrcontent.c_str();
2354 QRCode qrcode;
2355 uint8_t version = findFittingVersion_text(ECC_MEDIUM, text);
2356 uint8_t qrcodeData[qrcode_getBufferSize(version)];
2357 // https://github.com/ricmoo/QRCode
2358 qrcode_initText(&qrcode, qrcodeData, version, ECC_MEDIUM, text);
2359
2360 JsonDocument loc;
2361 getTemplate(loc, 10, taginfo->hwType);
2362 initSprite(spr, imageParams.width, imageParams.height, imageParams);
2363 drawString(spr, title, loc["title"][0], loc["title"][1], loc["title"][2], TC_DATUM, TFT_BLACK, loc["title"][3]);
2364
2365 const int size = qrcode.size;
2366 const int dotsize = int((imageParams.height - loc["pos"][1].as<int>()) / size);
2367 const int xpos = loc["pos"][0].as<int>() - dotsize * size / 2;
2368 const int ypos = loc["pos"][1].as<int>() + (imageParams.height - loc["pos"][1].as<int>() - dotsize * size) / 2;
2369
2370 for (int y = 0; y < size; y++) {
2371 for (int x = 0; x < size; x++) {
2372 if (qrcode_getModule(&qrcode, x, y)) {
2373 spr.fillRect(xpos + x * dotsize, ypos + y * dotsize, dotsize, dotsize, TFT_BLACK);
2374 }
2375 }
2376 }
2377
2378 spr2buffer(spr, filename, imageParams);
2379 spr.deleteSprite();
2380}
2381#endif
2382
2383#ifdef CONTENT_BUIENRADAR

Callers 1

drawNewFunction · 0.85

Calls 5

getTemplateFunction · 0.85
initSpriteFunction · 0.85
drawStringFunction · 0.85
spr2bufferFunction · 0.85
fillRectMethod · 0.80

Tested by

no test coverage detected