LilyGo-LoRa-Series/lib/GxEPD/examples/PagedDisplayForSmallRam/PagedDisplayForSmallRam.ino
2024-01-16 15:42:50 +08:00

112 lines
4.4 KiB
C++

// According to the board, cancel the corresponding macro definition
// #define LILYGO_T5_V213
// #define LILYGO_T5_V22
// #define LILYGO_T5_V24
// #define LILYGO_T5_V28
// #define LILYGO_T5_V102
// #define LILYGO_T5_V266
// #define LILYGO_EPD_DISPLAY_102 //Depend https://github.com/adafruit/Adafruit_NeoPixel
// #define LILYGO_EPD_DISPLAY_154
#include <boards.h>
#include <GxEPD.h>
#include <SD.h>
#include <FS.h>
#if defined(LILYGO_T5_V102) || defined(LILYGO_EPD_DISPLAY_102)
#include <GxGDGDEW0102T4/GxGDGDEW0102T4.h> //1.02" b/w
#include <Adafruit_NeoPixel.h> //Depend https://github.com/adafruit/Adafruit_NeoPixel
#elif defined(LILYGO_T5_V266)
#include <GxDEPG0266BN/GxDEPG0266BN.h> // 2.66" b/w form DKE GROUP
#elif defined(LILYGO_T5_V213)
#include <GxDEPG0213BN/GxDEPG0213BN.h> // 2.13" b/w form DKE GROUP
#else
// #include <GxDEPG0097BW/GxDEPG0097BW.h> // 0.97" b/w form DKE GROUP
// #include <GxGDGDEW0102T4/GxGDGDEW0102T4.h> //1.02" b/w
// #include <GxGDEW0154Z04/GxGDEW0154Z04.h> // 1.54" b/w/r 200x200
// #include <GxGDEW0154Z17/GxGDEW0154Z17.h> // 1.54" b/w/r 152x152
// #include <GxGDEH0154D67/GxGDEH0154D67.h> // 1.54" b/w
// #include <GxDEPG0150BN/GxDEPG0150BN.h> // 1.51" b/w form DKE GROUP
// #include <GxDEPG0266BN/GxDEPG0266BN.h> // 2.66" b/w form DKE GROUP
// #include <GxDEPG0290R/GxDEPG0290R.h> // 2.9" b/w/r form DKE GROUP
// #include <GxDEPG0290B/GxDEPG0290B.h> // 2.9" b/w form DKE GROUP
// #include <GxGDEW029Z10/GxGDEW029Z10.h> // 2.9" b/w/r form GoodDisplay
// #include <GxGDEW0213Z16/GxGDEW0213Z16.h> // 2.13" b/w/r form GoodDisplay
// #include <GxGDE0213B1/GxGDE0213B1.h> // 2.13" b/w old panel , form GoodDisplay
// #include <GxGDEH0213B72/GxGDEH0213B72.h> // 2.13" b/w old panel , form GoodDisplay
// #include <GxGDEH0213B73/GxGDEH0213B73.h> // 2.13" b/w old panel , form GoodDisplay
// #include <GxGDEM0213B74/GxGDEM0213B74.h> // 2.13" b/w form GoodDisplay 4-color
// #include <GxGDEW0213M21/GxGDEW0213M21.h> // 2.13" b/w Ultra wide temperature , form GoodDisplay
// #include <GxDEPG0213BN/GxDEPG0213BN.h> // 2.13" b/w form DKE GROUP
// #include <GxGDEW027W3/GxGDEW027W3.h> // 2.7" b/w form GoodDisplay
// #include <GxGDEW027C44/GxGDEW027C44.h> // 2.7" b/w/r form GoodDisplay
// #include <GxGDEH029A1/GxGDEH029A1.h> // 2.9" b/w form GoodDisplay
// #include <GxDEPG0750BN/GxDEPG0750BN.h> // 7.5" b/w form DKE GROUP
#endif
#include <GxIO/GxIO_SPI/GxIO_SPI.h>
#include <GxIO/GxIO.h>
// FreeFonts from Adafruit_GFX
#include <Fonts/FreeMonoBold9pt7b.h>
#include GxEPD_BitmapExamples
#define USING_SOFT_SPI
#if defined(USING_SOFT_SPI)
GxIO_Class io(EPD_SCLK, EPD_MISO, EPD_MOSI, EPD_CS, EPD_DC, EPD_RSET);
#else
GxIO_Class io(SPI, EPD_CS, EPD_DC, EPD_RSET);
#endif
GxEPD_Class display(io, EPD_RSET, EPD_BUSY);
//#define DEMO_DELAY 3*60 // seconds
//#define DEMO_DELAY 1*60 // seconds
#define DEMO_DELAY 10
void setup(void)
{
Serial.begin(115200);
Serial.println();
Serial.println("setup");
display.init(115200); // enable diagnostic output on Serial
Serial.println("setup done");
}
void loop()
{
#if defined(_GxGDEW0154Z04_H_) || defined(_GxGDEW0213Z16_H_) || defined(_GxGDEW029Z10_H_) || defined(_GxGDEW027C44_H_)
display.drawExamplePicture(BitmapExample1, BitmapExample2, sizeof(BitmapExample1), sizeof(BitmapExample2));
#elif !defined(__AVR) && defined(_GxGDEW042Z15_H_)
display.drawExamplePicture(BitmapExample1, BitmapExample2, sizeof(BitmapExample1), sizeof(BitmapExample2));
#else
display.drawExampleBitmap(BitmapExample1, sizeof(BitmapExample1));
#endif
delay(DEMO_DELAY * 1000);
display.drawPaged(showFontCallback);
delay(DEMO_DELAY * 1000);
}
void showFontCallback()
{
const char *name = "FreeMonoBold9pt7b";
const GFXfont *f = &FreeMonoBold9pt7b;
display.fillScreen(GxEPD_WHITE);
display.setTextColor(GxEPD_BLACK);
display.setFont(f);
display.setCursor(0, 0);
display.println();
display.println(name);
display.println(" !\"#$%&'()*+,-./");
display.println("0123456789:;<=>?");
display.println("@ABCDEFGHIJKLMNO");
display.println("PQRSTUVWXYZ[\\]^_");
#if defined(_GxGDEW0154Z04_H_) || defined(_GxGDEW0213Z16_H_) || defined(_GxGDEW029Z10_H_) || defined(_GxGDEW027C44_H_) || defined(_GxGDEW042Z15_H_) || defined(_GxGDEW075Z09_H_) || defined(_GxGDEW075Z08_H_)
display.setTextColor(GxEPD_RED);
#endif
display.println("`abcdefghijklmno");
display.println("pqrstuvwxyz{|}~ ");
}