I haven’t encountered a device with this apparently ‘new’ e-ink display, but I may encounter one next week.
The next sketch works for my Paper that I picked up a couple of months ago:
#include <Arduino.h>
#include <GxEPD2_BW.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include "GxEPD2_display_selection_new_style.h"
#define Vext 45
void VextON() {
pinMode(Vext, OUTPUT);
digitalWrite(Vext, LOW);
}
void VextOFF() {
pinMode(Vext, OUTPUT);
digitalWrite(Vext, HIGH);
}
SPIClass hspi(HSPI);
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println("setup");
delay(2000);
VextON();
hspi.begin(3, -1, 2, 4); // remap hspi for EPD (swap pins)
display.epd2.selectSPI(hspi, SPISettings(4000000, MSBFIRST, SPI_MODE0));
display.init(115200, true, 2, false);
}
const char HelloWorld[] = "Hello World!";
const char HelloArduino[] = "Hello Arduino!";
const char HelloEpaper[] = "Hello E-Paper!";
void helloWorld() {
//Serial.println("helloWorld");
display.setRotation(1);
display.setFont(&FreeMonoBold9pt7b);
if (display.epd2.WIDTH < 104) display.setFont(0);
display.setTextColor(GxEPD_BLACK);
int16_t tbx, tby; uint16_t tbw, tbh;
display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
// center bounding box by transposition of 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);
}
while (display.nextPage());
//Serial.println("helloWorld done");
}
void loop() {
helloWorld();
delay(60000);
}
In the file GxEPD2_display_selection_new_style.h
:
- uncomment line 36, not line 40 I mentioned earlier, sorry.
- change line 130 such that it reads:
GxEPD2_DISPLAY_CLASS<GxEPD2_DRIVER_CLASS, MAX_HEIGHT(GxEPD2_DRIVER_CLASS)> display(GxEPD2_DRIVER_CLASS(/*CS=5*/ 4, /*DC=*/ 5, /*RST=*/ 6, /*BUSY=*/ 7));
If that doesn’t work, you may have the new display; please let me know. I hope to get that one going as well.