Skip to content

Instantly share code, notes, and snippets.

@oxyii
Created September 13, 2021 20:29
Show Gist options
  • Save oxyii/76265cfef0bde9bc6ce80b122f5e5514 to your computer and use it in GitHub Desktop.
Save oxyii/76265cfef0bde9bc6ce80b122f5e5514 to your computer and use it in GitHub Desktop.
QRcode_eSPI
#include <Arduino.h>
#include "qrencode.h"
#include "qrcode_espi.h"
QRcode_eSPI::QRcode_eSPI(TFT_eSPI *display) {
this->display = display;
}
void QRcode_eSPI::init() {
//display->init();
this->screenwidth = display->width();
this->screenheight = display->height();
display->fillScreen(TFT_WHITE);
int min = screenwidth;
if (screenheight<screenwidth)
min = screenheight;
multiply = min/WD;
offsetsX = (screenwidth-(WD*multiply))/2;
offsetsY = (screenheight-(WD*multiply))/2;
}
void QRcode_eSPI::screenwhite() {
display->fillScreen(TFT_WHITE);
}
void QRcode_eSPI::screenupdate() {
// No hay que hacer nada
}
void QRcode_eSPI::drawPixel(int x, int y, int color) {
if(color==1) {
color = TFT_BLACK;
} else {
color = TFT_WHITE;
}
display->drawPixel(x,y,color);
if (this->multiply>1) {
display->drawPixel(x+1,y,color);
display->drawPixel(x+1,y+1,color);
display->drawPixel(x,y+1,color);
}
}
#ifndef ESPQRST7735_H
#define ESPQRST7735_H
/* ESP_QRcode. tft version for ST7735
* include this .h if you have a TFT display
*/
#define TFTDISPLAY
#include <TFT_eSPI.h>
#include <SPI.h>
#include "qrcode.h"
class QRcode_eSPI : public QRcodeDisplay
{
private:
TFT_eSPI *display;
void drawPixel(int x, int y, int color);
public:
QRcode_eSPI(TFT_eSPI *display);
void init();
void screenwhite();
void screenupdate();
};
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment