mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-08-08 14:20:51 +00:00
.
This commit is contained in:
@@ -1,76 +1,53 @@
|
||||
// GxEPD2_HelloWorld.ino by Jean-Marc Zingg
|
||||
//
|
||||
// Display Library example for SPI e-paper panels from Dalian Good Display and boards from Waveshare.
|
||||
// Requires HW SPI and Adafruit_GFX. Caution: the e-paper panels require 3.3V supply AND data lines!
|
||||
//
|
||||
// Display Library based on Demo Example from Good Display: https://www.good-display.com/companyfile/32/
|
||||
//
|
||||
// Author: Jean-Marc Zingg
|
||||
//
|
||||
// Version: see library.properties
|
||||
//
|
||||
// Library: https://github.com/ZinggJM/GxEPD2
|
||||
#include <Arduino.h>
|
||||
#include "ePaper.h"
|
||||
|
||||
// Supporting Arduino Forum Topics (closed, read only):
|
||||
// Good Display ePaper for Arduino: https://forum.arduino.cc/t/good-display-epaper-for-arduino/419657
|
||||
// Waveshare e-paper displays with SPI: https://forum.arduino.cc/t/waveshare-e-paper-displays-with-spi/467865
|
||||
//
|
||||
// Add new topics in https://forum.arduino.cc/c/using-arduino/displays/23 for new questions and issues
|
||||
// put function declarations here:
|
||||
void loop();
|
||||
void setup();
|
||||
|
||||
// see GxEPD2_wiring_examples.h for wiring suggestions and examples
|
||||
// if you use a different wiring, you need to adapt the constructor parameters!
|
||||
void setup() {
|
||||
|
||||
// uncomment next line to use class GFX of library GFX_Root instead of Adafruit_GFX
|
||||
//#include <GFX.h>
|
||||
pinMode(12, OUTPUT);
|
||||
|
||||
Serial.begin(115200);
|
||||
Serial.println("Running setup ...");
|
||||
|
||||
#include <GxEPD2_BW.h>
|
||||
#include <GxEPD2_3C.h>
|
||||
#include <GxEPD2_4C.h>
|
||||
#include <GxEPD2_7C.h>
|
||||
#include <Fonts/FreeMonoBold9pt7b.h>
|
||||
|
||||
// select the display class and display driver class in the following file (new style):
|
||||
#include "GxEPD2_display_selection_new_style.h"
|
||||
|
||||
// or select the display constructor line in one of the following files (old style):
|
||||
#include "GxEPD2_display_selection.h"
|
||||
#include "GxEPD2_display_selection_added.h"
|
||||
|
||||
// alternately you can copy the constructor from GxEPD2_display_selection.h or GxEPD2_display_selection_added.h to here
|
||||
// e.g. for Wemos D1 mini:
|
||||
//GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display(GxEPD2_154_D67(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDEH0154D67
|
||||
|
||||
// for handling alternative SPI pins (ESP32, RP2040) see example GxEPD2_Example.ino
|
||||
|
||||
void setup()
|
||||
{
|
||||
//display.init(115200); // default 10ms reset pulse, e.g. for bare panels with DESPI-C02
|
||||
display.init(115200, true, 2, false); // USE THIS for Waveshare boards with "clever" reset circuit, 2ms reset pulse
|
||||
helloWorld();
|
||||
display.hibernate();
|
||||
}
|
||||
|
||||
const char HelloWorld[] = "Hello World!";
|
||||
|
||||
void helloWorld()
|
||||
{
|
||||
display.setRotation(1);
|
||||
display.setFont(&FreeMonoBold9pt7b);
|
||||
// Initialize ePaper display
|
||||
display.init(115200);
|
||||
display.fillScreen(GxEPD_BLACK);
|
||||
display.update();
|
||||
display.fillScreen(GxEPD_WHITE);
|
||||
display.setTextColor(GxEPD_BLACK);
|
||||
int16_t tbx, tby; uint16_t tbw, tbh;
|
||||
display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
|
||||
// center the bounding box by transposition of the origin:
|
||||
uint16_t x = ((display.width() - tbw) / 2) - tbx;
|
||||
uint16_t y = ((display.height() - tbh) / 2) - tby;
|
||||
display.setFullWindow();
|
||||
display.firstPage();
|
||||
do
|
||||
{
|
||||
display.fillScreen(GxEPD_WHITE);
|
||||
display.setCursor(x, y);
|
||||
display.print(HelloWorld);
|
||||
display.setFont(&FreeMono9pt7b);
|
||||
//display.setCursor(205, 10);
|
||||
//display.print("ESP32_DisplayNode"); // Takes 195 pixels in width
|
||||
|
||||
display.setCursor(5, 5);
|
||||
display.setFont(&TomThumb);
|
||||
display.print("10.100.50.105");
|
||||
display.update();
|
||||
// Add UI elements
|
||||
// Draw axis: (x1,y1) @ 5, 100 and width-2*margin_x height-2*margin_y
|
||||
display.drawRect(5, 155, display.width()-10, display.height()-160, GxEPD_RED);
|
||||
display.setFont(&TomThumb);
|
||||
for (int i = 0; i < display.width()-10; i+=50) {
|
||||
display.setCursor(i, display.height());
|
||||
display.print(i);
|
||||
}
|
||||
while (display.nextPage());
|
||||
|
||||
// Calibration lines
|
||||
/*display.drawLine(0, 100, display.width(), 100, GxEPD_BLACK);
|
||||
display.drawLine(0, 200, display.width(), 200, GxEPD_BLACK);
|
||||
display.drawLine(200, 0, 200, display.height(), GxEPD_BLACK);*/
|
||||
|
||||
display.update();
|
||||
}
|
||||
|
||||
void loop() {};
|
||||
void loop() {
|
||||
Serial.println("LED ON");
|
||||
digitalWrite(12, HIGH);
|
||||
delay(750);
|
||||
Serial.println("LED OFF");
|
||||
digitalWrite(12, LOW);
|
||||
delay(750);
|
||||
}
|
Reference in New Issue
Block a user