mirror of
https://github.com/WeActStudio/WeActStudio.EpaperModule.git
synced 2026-08-16 13:13:45 +02:00
64 lines
2.2 KiB
Arduino
64 lines
2.2 KiB
Arduino
|
|
// base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter, uses ~1.2k more code
|
|
// enable or disable GxEPD2_GFX base class
|
|
#define ENABLE_GxEPD2_GFX 0
|
|
|
|
#include <GxEPD2_BW.h>
|
|
#include <GxEPD2_3C.h>
|
|
#include <Fonts/FreeMonoBold9pt7b.h>
|
|
|
|
// ESP32-C3 SS=7,SCL(SCK)=4,SDA(MOSI)=6,BUSY=3,RST=2,DC=1
|
|
|
|
//GxEPD2_BW<GxEPD2_213_B74, GxEPD2_213_B74::HEIGHT> display(GxEPD2_213_B74(/*CS=5*/ SS, /*DC=*/ 1, /*RST=*/ 2, /*BUSY=*/ 3)); // GDEM0213B74 122x250, SSD1680
|
|
//GxEPD2_3C<GxEPD2_213_Z98c, GxEPD2_213_Z98c::HEIGHT> display(GxEPD2_213_Z98c(/*CS=5*/ SS, /*DC=*/ 1, /*RST=*/ 2, /*BUSY=*/ 3)); // GDEY0213Z98 122x250, SSD1680
|
|
|
|
//GxEPD2_BW<GxEPD2_290_T94, GxEPD2_290_T94::HEIGHT> display(GxEPD2_290_T94(/*CS=5*/ SS, /*DC=*/ 1, /*RST=*/ 2, /*BUSY=*/ 3)); // GDEM029T94 128x296, SSD1680
|
|
//GxEPD2_3C<GxEPD2_290_C90c, GxEPD2_290_C90c::HEIGHT> display(GxEPD2_290_C90c(/*CS=5*/ SS, /*DC=*/ 1, /*RST=*/ 2, /*BUSY=*/ 3)); // GDEM029C90 128x296, SSD1680
|
|
|
|
void setup()
|
|
{
|
|
pinMode(8, OUTPUT);
|
|
digitalWrite(8, HIGH);
|
|
|
|
display.init(115200,true,50,false);
|
|
helloWorld();
|
|
display.hibernate();
|
|
}
|
|
|
|
const char HelloWorld[] = "Hello World!";
|
|
const char HelloWeACtStudio[] = "Hello WeAct Studio!";
|
|
|
|
void helloWorld()
|
|
{
|
|
display.setRotation(1);
|
|
display.setFont(&FreeMonoBold9pt7b);
|
|
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-tbh);
|
|
display.print(HelloWorld);
|
|
display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
|
|
display.getTextBounds(HelloWeACtStudio, 0, 0, &tbx, &tby, &tbw, &tbh);
|
|
x = ((display.width() - tbw) / 2) - tbx;
|
|
display.setCursor(x, y+2*tbh);
|
|
display.print(HelloWeACtStudio);
|
|
}
|
|
while (display.nextPage());
|
|
}
|
|
|
|
void loop() {
|
|
// put your main code here, to run repeatedly:
|
|
digitalWrite(8, HIGH);
|
|
delay(1000);
|
|
digitalWrite(8, LOW);
|
|
delay(1000);
|
|
}
|