Hello @ZinggJM and thank you for your time!
My "3 color" display, to begin with, was advertised by the vendor as two colors, and learn about it being able to display 3 by using the adafruit library. Also the board isn't a waveshare, i looked everywhere. Alas, using the class you suggested, the behaviour is as expected: i now get the output i want, altought the refresh rate is a bit on the slow side, around 3spf. Partial refresh doesn't work as expected with the following code: With all 3 methods, even with 60 seconds delays added between each other, the whole screen refreshes anyway after the partial refresh, making it useless. Am i getting something wrong?
Edit: this was a senseless message since i forgot to add the code i found for testing
#include <GxEPD2_3C.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include "FreeMonoBoldOblique24pt7b.h"
#include "bitmaps/Bitmaps3c128x296.h"
#define ENABLE_GxEPD2_GFX 0
// Connections for e.g. LOLIN D32
static const uint8_t EPD_BUSY = 4; // to EPD BUSY
static const uint8_t EPD_CS = 5; // to EPD CS
static const uint8_t EPD_RST = 16; // to EPD RST
static const uint8_t EPD_DC = 17; // to EPD DC
static const uint8_t EPD_SCK = 18; // to EPD CLK
static const uint8_t EPD_MISO = -1; // Master-In Slave-Out not used, as no data from display
static const uint8_t EPD_MOSI = 23; // to EPD DIN
static const bool hasPartialUpdate = true;
static const bool usePartialUpdateWindow = false; // set false for better image
static const bool hasFastPartialUpdate = true;
// Define the display class and driver
GxEPD2_3C<GxEPD2_290_C90c, GxEPD2_290_C90c::HEIGHT> display(GxEPD2_290_C90c(EPD_CS, EPD_DC, EPD_RST, EPD_BUSY));
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println("setup");
delay(100);
display.init(115200); // default 10ms reset pulse, e.g. for bare panels with DESPI-C02
//display.init(115200, true, 2, false); // USE THIS for Waveshare boards with "clever" reset circuit, 2ms reset pulse
//display.init(115200, true, 10, false, SPI0, SPISettings(4000000, MSBFIRST, SPI_MODE0)); // extended init method with SPI channel and/or settings selection
// first update should be full refresh
helloWorld();
delay(1000);
// partial refresh mode can be used to full screen,
// effective if display panel hasFastPartialUpdate
helloFullScreenPartialMode();
delay(1000);
//stripeTest(); return; // GDEH029Z13 issue
helloArduino();
delay(1000);
helloEpaper();
delay(1000);
}
void loop()
{
}
const char HelloWorld[] = "Hello World!";
const char HelloArduino[] = "Hello Arduino!";
const char HelloEpaper[] = "Hello E-Paper!";
const int16_t rotation = 1;
void helloWorld()
{
Serial.println("helloWorld");
//display.setRotation(1);
display.setRotation(rotation);
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 helloFullScreenPartialMode()
{
Serial.println("helloFullScreenPartialMode");
const char fullscreen[] = "full screen update";
const char fpm[] = "fast partial mode";
const char spm[] = "slow partial mode";
const char npm[] = "no partial mode";
display.setPartialWindow(0, 0, display.width(), display.height());
//display.setRotation(1);
display.setRotation(rotation);
display.setFont(&FreeMonoBold9pt7b);
if (display.epd2.WIDTH < 104) display.setFont(0);
//display.setTextColor(GxEPD_BLACK);
display.setTextColor(GxEPD_WHITE);
const char* updatemode;
if (display.epd2.hasFastPartialUpdate)
{
updatemode = fpm;
}
else if (display.epd2.hasPartialUpdate)
{
updatemode = spm;
}
else
{
updatemode = npm;
}
// do this outside of the loop
int16_t tbx, tby; uint16_t tbw, tbh;
// center update text
display.getTextBounds(fullscreen, 0, 0, &tbx, &tby, &tbw, &tbh);
uint16_t utx = ((display.width() - tbw) / 2) - tbx;
uint16_t uty = ((display.height() / 4) - tbh / 2) - tby;
// center update mode
display.getTextBounds(updatemode, 0, 0, &tbx, &tby, &tbw, &tbh);
uint16_t umx = ((display.width() - tbw) / 2) - tbx;
uint16_t umy = ((display.height() * 3 / 4) - tbh / 2) - tby;
// center HelloWorld
display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
uint16_t hwx = ((display.width() - tbw) / 2) - tbx;
uint16_t hwy = ((display.height() - tbh) / 2) - tby;
display.firstPage();
do
{
//display.fillScreen(GxEPD_WHITE);
display.fillScreen(GxEPD_BLACK);
display.setCursor(hwx, hwy);
display.print(HelloWorld);
display.setCursor(utx, uty);
display.print(fullscreen);
display.setCursor(umx, umy);
display.print(updatemode);
}
while (display.nextPage());
//Serial.println("helloFullScreenPartialMode done");
}
void helloArduino()
{
Serial.println("helloArduino");
//display.setRotation(1);
display.setRotation(rotation);
display.setFont(&FreeMonoBold9pt7b);
if (display.epd2.WIDTH < 104) display.setFont(0);
display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
int16_t tbx, tby; uint16_t tbw, tbh;
// align with centered HelloWorld
display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
uint16_t x = ((display.width() - tbw) / 2) - tbx;
// height might be different
display.getTextBounds(HelloArduino, 0, 0, &tbx, &tby, &tbw, &tbh);
uint16_t y = ((display.height() / 4) - tbh / 2) - tby; // y is base line!
// make the window big enough to cover (overwrite) descenders of previous text
uint16_t wh = FreeMonoBold9pt7b.yAdvance;
uint16_t wy = (display.height() / 4) - wh / 2;
display.setPartialWindow(0, wy, display.width(), wh);
display.firstPage();
do
{
display.fillScreen(GxEPD_WHITE);
//display.drawRect(x, y - tbh, tbw, tbh, GxEPD_BLACK);
display.setCursor(x, y);
display.print(HelloArduino);
}
while (display.nextPage());
delay(1000);
//Serial.println("helloArduino done");
}
void helloEpaper()
{
Serial.println("helloEpaper");
//display.setRotation(1);
display.setRotation(rotation);
display.setFont(&FreeMonoBold9pt7b);
if (display.epd2.WIDTH < 104) display.setFont(0);
display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK);
int16_t tbx, tby; uint16_t tbw, tbh;
// align with centered HelloWorld
display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
uint16_t x = ((display.width() - tbw) / 2) - tbx;
// height might be different
display.getTextBounds(HelloEpaper, 0, 0, &tbx, &tby, &tbw, &tbh);
uint16_t y = ((display.height() * 3 / 4) - tbh / 2) - tby; // y is base line!
// make the window big enough to cover (overwrite) descenders of previous text
uint16_t wh = FreeMonoBold9pt7b.yAdvance;
uint16_t wy = (display.height() * 3 / 4) - wh / 2;
display.setPartialWindow(0, wy, display.width(), wh);
display.firstPage();
do
{
display.fillScreen(GxEPD_WHITE);
display.setCursor(x, y);
display.print(HelloEpaper);
}
while (display.nextPage());
//Serial.println("helloEpaper done");
}
-Lorenzo