Open janna574 opened 4 years ago
Hope this helps.... Example below generates a WiFi QR code. It is a version 3 code, then printed at 5 times the size.
if (tpScan("", 1)) {
Serial.println((char *)"Found a printer!, connecting...");
if (tpConnect()){
uint8_t qrVersion = 3;
static uint8_t ucBuf[48 * 160]; //tp printer buffer 48 * ver lines
tpSetBackBuffer(ucBuf, 384, 160);
tpFill(0);
char buf[50];
sprintf(buf, "WIFI:S:%s;T:WPA;P:%s;;", config.networkConfig.apSSID, config.networkConfig.apPassword);
Serial.println(buf);
uint8_t qrcodeData[qrcode_getBufferSize(qrVersion)];
qrcode_initText(&qrcode, qrcodeData, qrVersion, 0, buf); //ver 3 = 29*29 //ver 40 177*177
uint8_t startX = 117;
uint8_t startY = 10;
for (uint8_t y = 0; y < qrcode.size; y++) {
for (uint8_t x = 0; x < qrcode.size; x++) {
if (qrcode_getModule(&qrcode, x, y) == 1){
//below, print QR 5 times as big
tpSetPixel(startX + 5 * x, startY + 5 * y, 1);
tpSetPixel(startX + 5 * x + 1, startY + 5 * y, 1);
tpSetPixel(startX + 5 * x + 2, startY + 5 * y, 1);
tpSetPixel(startX + 5 * x + 2, startY + 5 * y, 1);
tpSetPixel(startX + 5 * x + 2, startY + 5 * y, 1);
tpSetPixel(startX + 5 * x, startY + 5 * y + 1, 1);
tpSetPixel(startX + 5 * x + 1, startY + 5 * y + 1, 1);
tpSetPixel(startX + 5 * x + 2, startY + 5 * y + 1, 1);
tpSetPixel(startX + 5 * x + 3, startY + 5 * y + 1, 1);
tpSetPixel(startX + 5 * x + 4, startY + 5 * y + 1, 1);
tpSetPixel(startX + 5 * x, startY + 5 * y + 2, 1);
tpSetPixel(startX + 5 * x + 1, startY + 5 * y + 2, 1);
tpSetPixel(startX + 5 * x + 2, startY + 5 * y + 2, 1);
tpSetPixel(startX + 5 * x + 3, startY + 5 * y + 2, 1);
tpSetPixel(startX + 5 * x + 4, startY + 5 * y + 2, 1);
tpSetPixel(startX + 5 * x, startY + 5 * y + 3, 1);
tpSetPixel(startX + 5 * x + 1, startY + 5 * y + 3, 1);
tpSetPixel(startX + 5 * x + 2, startY + 5 * y + 3, 1);
tpSetPixel(startX + 5 * x + 3, startY + 5 * y + 3, 1);
tpSetPixel(startX + 5 * x + 4, startY + 5 * y + 3, 1);
tpSetPixel(startX + 5 * x, startY + 5 * y + 4, 1);
tpSetPixel(startX + 5 * x + 1, startY + 5 * y + 4, 1);
tpSetPixel(startX + 5 * x + 2, startY + 5 * y + 4, 1);
tpSetPixel(startX + 5 * x + 3, startY + 5 * y + 4, 1);
tpSetPixel(startX + 5 * x + 4, startY + 5 * y + 4, 1);
}
}
}
tpPrintBuffer();
tpDisconnect();
}
} else {
Serial.println((char *)"Didn't find a printer :( ");
}
I implemented saving a QR code as a BMP file using C language
how can i get a bitmap from qrcode to print via ThermalPrinter !
printer.printBitmap(50,50,qrcode data,false);