Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Working Test-Code via SPI for epaper - Waveshare 2.9 V2
- #include <SPI.h>
- #include <GxEPD2_BW.h>
- #include <Fonts/FreeMonoBold9pt7b.h>
- GxEPD2_BW<GxEPD2_290_T94_V2, GxEPD2_290_T94_V2::HEIGHT> display(
- GxEPD2_290_T94_V2(5, 17, 16, 4)
- );
- int i = 0;
- void setup() {
- Serial.begin(115200);
- SPI.begin(18, 19, 23); // SCK, MISO, MOSI
- display.init(115200, true, 2, false);
- }
- void loop() {
- const char text[] = "Hello World!";
- i = i + 1;
- display.setRotation(1);
- display.setFont(&FreeMonoBold9pt7b);
- display.setTextColor(GxEPD_BLACK);
- int16_t tbx, tby; uint16_t tbw, tbh;
- display.getTextBounds(text, 0, 0, &tbx, &tby, &tbw, &tbh);
- 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(String(text) + String(i));
- } while (display.nextPage());
- Serial.println("Refresh done! Waiting for next one...");
- delay(20000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement