Hello,
I'm using GDEY042T81 (Waveshare 4.2 BW v2.2) with Wemos D1 Pro (with 3.3k pull-down on CS and 1k pull-up on RST).
I would like to use the partial update feature and I've reduced the code from GxEPD2_NotPagedExample example - what I'm seeing is that I get a garbage output only on first pass and first partial "box", all successive partial updates are just fine.
Changing display.displayWindow(box_x, box_y, box_w, box_h); to display.display(true); makes no difference.
After trial and error I've noticed that everything is fixed if I call display.display(true); just after initial non-partial update (e.g. put it between helloWorld(); and showPartialUpdate();). It also seems that I need to call the display.display(true); after each display.display(false); to fix any partial update issues.
Am I doing something wrong?
Thank you,
Best Regards,
Sample code:
#define ENABLE_GxEPD2_GFX 0
#include <GxEPD2_BW.h>
#include <Fonts/FreeMonoBold18pt7b.h>
#define GxEPD2_DISPLAY_CLASS GxEPD2_BW
static const uint8_t EPD_BUSY = D1;
static const uint8_t EPD_CS = D8;
static const uint8_t EPD_RST = D4;
static const uint8_t EPD_DC = D2;
static const uint8_t EPD_SCK = D5;
static const uint8_t EPD_MISO = -1;
static const uint8_t EPD_MOSI = D7;
#define GxEPD2_DRIVER_CLASS GxEPD2_420_GDEY042T81 // GDEY042T81 400x300, SSD1683 (no inking)
GxEPD2_BW<GxEPD2_DRIVER_CLASS, GxEPD2_DRIVER_CLASS::HEIGHT> display(GxEPD2_DRIVER_CLASS(/*CS=D8*/ EPD_CS, /*DC=D3*/ EPD_DC, /*RST=D4*/ EPD_RST, /*BUSY=D2*/ EPD_BUSY));
void setup()
{
display.init(115200, true, 2, false);
helloWorld();
//display.displayWindow(0, 0, 400, 300);
//display.display(true);
showPartialUpdate();
display.powerOff();
}
void loop()
{
}
const char HelloWorld[] = "Hello World!";
void helloWorld()
{
display.setRotation(0);
display.setFont(&FreeMonoBold18pt7b);
display.setTextColor(GxEPD_BLACK);
int16_t tbx, tby; uint16_t tbw, tbh;
display.getTextBounds(HelloWorld, 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.fillScreen(GxEPD_WHITE);
display.setCursor(x, y);
display.print(HelloWorld);
display.display(false);
}
void showPartialUpdate()
{
uint16_t box_x = 10;
uint16_t box_y = 15;
uint16_t box_w = 150;
uint16_t box_h = 30;
uint16_t cursor_y = box_y + box_h - 6;
float value = 13.95;
display.setFont(&FreeMonoBold18pt7b);
display.setTextColor(GxEPD_BLACK);
for (uint16_t pass = 0; pass < 2; pass++)
{
for (uint16_t r = 0; r < 4; r++)
{
display.setRotation(r);
for (uint16_t i = 1; i <= 10; i += 1)
{
display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
display.setCursor(box_x, cursor_y);
display.print(value * i, 2);
display.displayWindow(box_x, box_y, box_w, box_h);
//display.display(true);
delay(500);
}
delay(1000);
display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
display.displayWindow(box_x, box_y, box_w, box_h);
//display.display(true);
delay(1000);
}
}
}