MCPcopy Create free account
hub / github.com/BruceDevices/firmware / qrencode

Function qrencode

lib/TFT_eSPI_QRcode/src/qrencode.c:486–516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

484}
485
486void qrencode()
487{
488 unsigned mindem = 30000;
489 unsigned char best = 0;
490 unsigned char i;
491 unsigned badness;
492
493 stringtoqr();
494 fillframe(); // Inisde loop to avoid having separate mask buffer
495 memcpy(strinbuf, qrframe, WD * WDB);
496 for (i = 0; i < 8; i++) {
497 applymask(i); // returns black-white imbalance
498 badness = badcheck();
499#if 0 //ndef PUREBAD
500 if (badness < WD * WD * 5 / 4) { // good enough - masks grow in compute complexity
501 best = i;
502 break;
503 }
504#endif
505 if (badness < mindem) {
506 mindem = badness;
507 best = i;
508 }
509 if (best == 7)
510 break; // don't increment i to avoid redoing mask
511 memcpy(qrframe, strinbuf, WD * WDB); // reset filled frame
512 }
513 if (best != i) // redo best mask - none good enough, last wasn't best
514 applymask(best);
515 addfmt(best); // add in final format bytes
516}

Callers 1

createMethod · 0.85

Calls 5

stringtoqrFunction · 0.85
fillframeFunction · 0.85
applymaskFunction · 0.85
badcheckFunction · 0.85
addfmtFunction · 0.85

Tested by

no test coverage detected