Skip to content

Instantly share code, notes, and snippets.

@ByronScottJones
Created March 2, 2021 02:03
Show Gist options
  • Save ByronScottJones/f2c4b96048c1dd445c652986c8705f14 to your computer and use it in GitHub Desktop.
Save ByronScottJones/f2c4b96048c1dd445c652986c8705f14 to your computer and use it in GitHub Desktop.
ESP32 TTGO QRCODE based access
#include <TFT_eSPI.h>
#include <SPI.h>
#include "qrcode.h"
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
void setup(void) {
// Create the QR code
QRCode qrcode;
uint8_t qrcodeData[qrcode_getBufferSize(1)];
qrcode_initText(&qrcode, qrcodeData, 1, 0, "[192.168.1.12](https://192.168.1.12)");
tft.init();
tft.setRotation(1);
int QRxBegin = 75;
int QRyBegin = 23;
int QRmoduleSize = 4;
tft.fillScreen(TFT_WHITE);
// Draw QR code
for (uint8_t y = 0; y < qrcode.size; y++) {
// Each horizontal module
for (uint8_t x = 0; x < qrcode.size; x++) {
if(qrcode_getModule(&qrcode, x, y))tft.fillRect(QRxBegin+ x*QRmoduleSize, QRyBegin + y*QRmoduleSize, QRmoduleSize, QRmoduleSize, TFT_BLACK);
}
}
}
void loop() {
@ByronScottJones
Copy link
Author

ByronScottJones commented Mar 2, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment