|
/* ESP32 e-paper display
####################################################################################################################################
*/
#include <SPI.h> // Built-in
#include "EPD_WaveShare.h" // Copyright (c) 2017 by Daniel Eichhorn https://github.com/ThingPulse/minigrafx
#include "EPD_WaveShare_42.h" // Copyright (c) 2017 by Daniel Eichhorn https://github.com/ThingPulse/minigrafx
#include "MiniGrafx.h" // Copyright (c) 2017 by Daniel Eichhorn https://github.com/ThingPulse/minigrafx
#include "DisplayDriver.h" // Copyright (c) 2017 by Daniel Eichhorn https://github.com/ThingPulse/minigrafx
#include "qrcode.h" // Copyright (c) //https://github.com/ricmoo/qrcode/
#define SCREEN_WIDTH 400.0 // Set for landscape mode, don't remove the decimal place!
#define SCREEN_HEIGHT 300.0
#define BITS_PER_PIXEL 1
#define EPD_BLACK 0
#define EPD_WHITE 1
uint16_t palette[] = { 0, 1 };
// pins_arduino.h, e.g. LOLIN32
static const uint8_t EPD_BUSY = 4;
static const uint8_t EPD_SS = 5;
static const uint8_t EPD_RST = 16;
static const uint8_t EPD_DC = 17;
static const uint8_t EPD_SCK = 18;
static const uint8_t EPD_MISO = 19; // Master-In Slave-Out not used, as no data from display
static const uint8_t EPD_MOSI = 23;
EPD_WaveShare42 epd(EPD_SS, EPD_RST, EPD_DC, EPD_BUSY);
MiniGrafx gfx = MiniGrafx(&epd, BITS_PER_PIXEL, palette);
//################# LIBRARIES ##########################
String version = "1.0"; // Version of this program
//################ VARIABLES ##########################
QRCode qrcode;
//#########################################################################################
void setup() {
gfx.init();
gfx.setRotation(0);
gfx.fillBuffer(EPD_WHITE);
}
//#########################################################################################
void loop() {
Display_QRcode(25,75,"Hello World!\n\nG6EJD");
Display_QRcode(225,75,"http://example.com/");
gfx.commit();
delay(120000);
Clear_Screen();
}
//#########################################################################################
void Display_QRcode(int offset_x, int offset_y, const char* Message){
#define element_size 4
// Create the QR code ~120 char maximum
uint8_t qrcodeData[qrcode_getBufferSize(3)];
qrcode_initText(&qrcode, qrcodeData, 3, 0, Message);
for (int y = 0; y < qrcode.size; y++) {
for (int x = 0; x < qrcode.size; x++) {
if (qrcode_getModule(&qrcode, x, y)) {
gfx.setColor(EPD_BLACK);
gfx.fillRect(x*element_size+offset_x,y*element_size+offset_y,element_size,element_size);
}
else
{
gfx.setColor(EPD_WHITE);
gfx.fillRect(x*element_size+offset_x,y*element_size+offset_y,element_size,element_size);
}
}
}
}
//#########################################################################################
void Clear_Screen(){
gfx.fillBuffer(EPD_WHITE);
gfx.commit();
delay(2000);
}
|
-
-
|