Advertisement
T3N0N

Arduino - Waveshare epaper SPI Test Example

Jul 17th, 2025
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 1.05 KB | Software | 0 0
  1. // Working Test-Code via SPI for epaper - Waveshare 2.9 V2
  2.  
  3. #include <SPI.h>
  4. #include <GxEPD2_BW.h>
  5. #include <Fonts/FreeMonoBold9pt7b.h>
  6.  
  7. GxEPD2_BW<GxEPD2_290_T94_V2, GxEPD2_290_T94_V2::HEIGHT> display(
  8.   GxEPD2_290_T94_V2(5, 17, 16, 4)
  9. );
  10. int i = 0;
  11. void setup() {
  12.  
  13.   Serial.begin(115200);
  14.   SPI.begin(18, 19, 23);  // SCK, MISO, MOSI
  15.   display.init(115200, true, 2, false);
  16. }
  17.  
  18. void loop() {
  19.   const char text[] = "Hello World!";
  20.   i = i + 1;
  21.   display.setRotation(1);
  22.   display.setFont(&FreeMonoBold9pt7b);
  23.   display.setTextColor(GxEPD_BLACK);
  24.  
  25.   int16_t tbx, tby; uint16_t tbw, tbh;
  26.   display.getTextBounds(text, 0, 0, &tbx, &tby, &tbw, &tbh);
  27.   uint16_t x = ((display.width() - tbw) / 2) - tbx;
  28.   uint16_t y = ((display.height() - tbh) / 2) - tby;
  29.  
  30.   display.setFullWindow();
  31.   display.firstPage();
  32.   do {
  33.     display.fillScreen(GxEPD_WHITE);
  34.     display.setCursor(x, y);
  35.     display.print(String(text) + String(i));
  36.   } while (display.nextPage());
  37.   Serial.println("Refresh done! Waiting for next one...");
  38.   delay(20000);
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement