@@ -2944,6 +2944,37 @@ void ILI9341::drawJpgFile(fs::FS &fs, const char *path, uint16_t x, uint16_t y,
29442944 file.close ();
29452945}
29462946
2947+
2948+ #include " qrcode.h"
2949+ void ILI9341::qrcode (const char *string, uint16_t x, uint16_t y, uint8_t width, uint8_t version) {
2950+
2951+ // Create the QR code
2952+ QRCode qrcode;
2953+ uint8_t qrcodeData[qrcode_getBufferSize (version)];
2954+ qrcode_initText (&qrcode, qrcodeData, version, 0 , string);
2955+
2956+ // Top quiet zone
2957+ uint8_t thickness = width / qrcode.size ;
2958+ uint16_t lineLength = qrcode.size * thickness;
2959+ uint8_t xOffset = x + (width-lineLength)/2 ;
2960+ uint8_t yOffset = y + (width-lineLength)/2 ;
2961+ fillRect (x, y, width, width, TFT_WHITE);
2962+
2963+ for (uint8_t y = 0 ; y < qrcode.size ; y++) {
2964+ for (uint8_t x = 0 ; x < qrcode.size ; x++) {
2965+ uint8_t q = qrcode_getModule (&qrcode, x, y);
2966+ if (q) fillRect (x * thickness + xOffset, y * thickness + yOffset, thickness, thickness, TFT_BLACK);
2967+ }
2968+ }
2969+ }
2970+
2971+ void ILI9341::qrcode (const String &string, uint16_t x, uint16_t y, uint8_t width, uint8_t version) {
2972+ int16_t len = string.length () + 2 ;
2973+ char buffer[len];
2974+ string.toCharArray (buffer, len);
2975+ qrcode (buffer, x, y, width, version);
2976+ }
2977+
29472978/* *************************************************************************
29482979**
29492980** GBK character support
0 commit comments