I'm using GxEPD2 on an ESP32-C3, driving a 2.13" red/black/white GDEY0213Z98.
Getting the first image on to the screen worked a treat. But I'm having a lot of trouble changing it without resetting the ESP. The black updates as expected, but the red always ends up everywhere there's not a black pixel. So it looks like the background is solid red.
My MRE essentially looks like this:
GxEPD2_3C<GxEPD2_213_Z98c,
GxEPD2_213_Z98c::HEIGHT> gDisplay(GxEPD2_213_Z98c(PIN_CS, PIN_DC, PIN_RES, PIN_BUSY));
int main()
{
//set up pins and SPI
gDisplay.init(115200);
gDisplay.setRotation(1);
gDisplay.setFullWindow();
gDisplay.fillScreen(GxEPD_WHITE);
gDisplay.drawXBitmap(0, 0, IMG_BLACK, IMG_WIDTH, IMG_HEIGHT, GxEPD_BLACK);
gDisplay.drawXBitmap(0, 0, IMG_RED, IMG_WIDTH, IMG_HEIGHT, GxEPD_RED);
gDisplay.display(false); //after ~15s, screen looks good
//optionally hibernate, doesn't matter
delay(5000);
//optionally do more drawing, doesn't matter
gDisplay.display(false); //background goes red.
}
After a lot of investigation I found that writeScreenBuffer() needs to be called every time. In other words, if I change GxEPD2_213_Z98c:73 from:
void GxEPD2_213_Z98c::writeImage(const uint8_t* black, const uint8_t* color, int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
{
if (_initial_write) writeScreenBuffer(); // initial full screen buffer clean
delay(1); // yield() to avoid WDT on ESP8266 and ESP32
to
void GxEPD2_213_Z98c::writeImage(const uint8_t* black, const uint8_t* color, int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
{
/*if (_initial_write)*/ writeScreenBuffer(); // initial full screen buffer clean
delay(1); // yield() to avoid WDT on ESP8266 and ESP32
then it works.
Is this expected behaviour? Do I have to call init() again after every display(false)?
By the way, I wonder if this has something to do this display being fairly unusual in that it is a small, colour display with partial refresh. To be clear, I'm not attempting to use partial refresh yet, but I recall at some point you could assume three colour displays don't support partial refresh.