Created
March 31, 2019 20:47
-
-
Save xxlukas42/dab2cbd1202ce75b5d421490910e8639 to your computer and use it in GitHub Desktop.
MH-ET LIVE 1.54-inches E-Paper demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <GxEPD.h> | |
#include <GxGDEP015OC1/GxGDEP015OC1.cpp> | |
#include <Fonts/OpenSansBold12pt7b.h> | |
#include <Fonts/OpenSansBold14pt7b.h> | |
#include <Fonts/OpenSansBold30pt7b.h> | |
#include <GxIO/GxIO_SPI/GxIO_SPI.cpp> | |
#include <GxIO/GxIO.cpp> | |
#include GxEPD_BitmapExamples | |
#include "qrcode.h" | |
GxIO_Class io(SPI, /*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2); // arbitrary selection of D3(=0), D4(=2), selected for default of GxEPD_Class | |
GxEPD_Class display(io /*RST=D4*/ /*BUSY=D2*/); // default selection of D4(=2), D2(=4) | |
void setup() { | |
Serial.begin(115200); | |
Serial.println(); | |
Serial.println("Display setup..."); | |
display.init(115200); // enable diagnostic output on Serial | |
display.setRotation(0); | |
display.update(); | |
Serial.println("Done"); | |
pinMode(D0, WAKEUP_PULLUP); | |
} | |
void loop() { | |
weatherDemo(); | |
drawPicture(); | |
qrCard(); | |
// Use this line if you need to save energy (e.g. battery application) | |
int seconds = 10; | |
ESP.deepSleep(seconds * 1000000); | |
} | |
void weatherDemo(){ | |
float temp = 16.4; | |
int hum = 54; | |
float pres = 1010.5; | |
uint16_t line_y = 0; | |
uint16_t line_x = 0; | |
display.setTextColor(GxEPD_BLACK); | |
line_y = 50; | |
display.drawLine(0, line_y, 200, line_y, GxEPD_BLACK); | |
line_y = 135; | |
display.drawLine(0, line_y, 200, line_y, GxEPD_BLACK); | |
line_x = 100; | |
display.drawLine(line_x, 135, line_x, 200, GxEPD_BLACK); | |
display.setFont(&OpenSansBold12pt7b); | |
display.setCursor(10, 35); | |
display.print("clear sky"); | |
display.setFont(&OpenSansBold14pt7b); | |
display.setCursor(155, 90); | |
display.print("C"); | |
display.setCursor(173, 83); | |
display.print("o"); | |
display.setFont(&OpenSansBold30pt7b); | |
display.setCursor(15, 115); | |
display.print(temp,1); | |
display.setFont(&OpenSansBold12pt7b); | |
display.setCursor(10, 160); | |
display.print("%"); | |
display.setFont(&OpenSansBold14pt7b); | |
display.setCursor(10, 190); | |
display.print(hum); | |
display.setFont(&OpenSansBold12pt7b); | |
display.setCursor(110, 160); | |
display.print("hPa"); | |
display.setFont(&OpenSansBold14pt7b); | |
display.setCursor(110, 190); | |
display.print(pres,1); | |
display.update(); | |
delay(2000); | |
} | |
void drawPicture(){ | |
display.fillRect(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_WHITE); | |
display.update(); | |
display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); | |
display.update(); | |
delay(2000); | |
} | |
void qrCard(){ | |
display.fillRect(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_WHITE); | |
display.update(); | |
// Start time | |
uint32_t dt = millis(); | |
byte box_x = 1; | |
byte box_y = 1; | |
byte box_s = 6; | |
byte init_x = box_x; | |
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, false); | |
// Create the QR code | |
QRCode qrcode; | |
uint8_t qrcodeData[qrcode_getBufferSize(4)]; | |
qrcode_initText(&qrcode, qrcodeData, 4, 0, "https://www.youtube.com/channel/UCrynPq5AwTTXQr-Hv9_fzMA?sub_confirmation=1"); | |
// Delta time | |
dt = millis() - dt; | |
Serial.print("QR Code Generation Time: "); | |
Serial.print(dt); | |
Serial.print("\n"); | |
// Top quiet zone | |
Serial.print("\n\n\n\n"); | |
for (uint8_t y = 0; y < qrcode.size; y++) { | |
// Left quiet zone | |
Serial.print(" "); | |
// Each horizontal module | |
for (uint8_t x = 0; x < qrcode.size; x++) { | |
// Print each module (UTF-8 \u2588 is a solid block) | |
//Serial.print(qrcode_getModule(&qrcode, x, y) ? "\u2588\u2588": " "); | |
if(qrcode_getModule(&qrcode, x, y)){ | |
Serial.print("\u2588\u2588"); | |
//Serial.println(py+ps); | |
display.fillRect(box_x, box_y, box_s, box_s, GxEPD_BLACK); | |
} else { | |
Serial.print(" "); | |
//Serial.println(py+ps); | |
display.fillRect(box_x, box_y, box_s, box_s, GxEPD_WHITE); | |
} | |
box_x = box_x + box_s; | |
} | |
Serial.print("\n"); | |
display.updateWindow(0, box_y, 200, box_s, true); | |
box_y = box_y + box_s; | |
box_x = init_x; | |
} | |
//display.update(); | |
// Bottom quiet zone | |
Serial.print("\n\n\n\n"); | |
} |
Thnx for posting! Have been trying to figure out where the <Fonts/OpenSansBold12pt7b.h> should be stored. Tried the directories within the library installation folders, the root and sub directory within my sketches, and everywhere in between. If there are any experts who know the protocol as to where/how the program would search for this file to mitigate this error message, I'd much appreciate you sharing. Thank you!
Arduino: 1.8.15 (Windows 10), Board: "NodeMCU 0.9 (ESP-12 Module), 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, None, Only Sketch, 115200" MH-ET_LIVE_ePaperDemo:3:10: fatal error: Fonts/OpenSansBold12pt7b.h: No such file or directory 3 | #include <Fonts/OpenSansBold12pt7b.h> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. exit status 1 Fonts/OpenSansBold12pt7b.h: No such file or directory
They say, there:
Arduino\libraries\Adafruit_GFX_Library\Fonts
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thnx for posting! Have been trying to figure out where the <Fonts/OpenSansBold12pt7b.h> should be stored. Tried the directories within the library installation folders, the root and sub directory within my sketches, and everywhere in between. If there are any experts who know the protocol as to where/how the program would search for this file to mitigate this error message, I'd much appreciate you sharing. Thank you!