From efe1da95268d4ebb5c73088f53938b78d2b7ffa7 Mon Sep 17 00:00:00 2001 From: Dave Allie Date: Mon, 8 Dec 2025 19:44:19 +1100 Subject: [PATCH] Re-use existing buffer and write to whole screen for 'partial update' --- lib/EpdRenderer/EpdRenderer.cpp | 11 ++++++++--- lib/EpdRenderer/EpdRenderer.h | 3 ++- open-x4-sdk | 2 +- src/screens/EpubReaderScreen.cpp | 4 +++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/EpdRenderer/EpdRenderer.cpp b/lib/EpdRenderer/EpdRenderer.cpp index b8a001d..f3eca77 100644 --- a/lib/EpdRenderer/EpdRenderer.cpp +++ b/lib/EpdRenderer/EpdRenderer.cpp @@ -216,9 +216,12 @@ void EpdRenderer::flushDisplay(const EInkDisplay::RefreshMode refreshMode) const } // TODO: Support partial window update -void EpdRenderer::flushArea(const int x, const int y, const int width, const int height) const { - einkDisplay.displayBuffer(); -} +// void EpdRenderer::flushArea(const int x, const int y, const int width, const int height) const { +// const int rotatedX = y; +// const int rotatedY = EInkDisplay::DISPLAY_HEIGHT - 1 - x; +// +// einkDisplay.displayBuffer(EInkDisplay::FAST_REFRESH, rotatedX, rotatedY, height, width); +// } int EpdRenderer::getPageWidth() const { return EInkDisplay::DISPLAY_HEIGHT - marginLeft - marginRight; } @@ -230,6 +233,8 @@ int EpdRenderer::getLineHeight() const { return regularFontRenderer->fontFamily->getData(REGULAR)->advanceY * lineCompression; } +void EpdRenderer::swapBuffers() const { einkDisplay.swapBuffers(); } + void EpdRenderer::copyGrayscaleLsbBuffers() const { einkDisplay.copyGrayscaleLsbBuffers(einkDisplay.getFrameBuffer()); } void EpdRenderer::copyGrayscaleMsbBuffers() const { einkDisplay.copyGrayscaleMsbBuffers(einkDisplay.getFrameBuffer()); } diff --git a/lib/EpdRenderer/EpdRenderer.h b/lib/EpdRenderer/EpdRenderer.h index 75c1abd..a9e76d3 100644 --- a/lib/EpdRenderer/EpdRenderer.h +++ b/lib/EpdRenderer/EpdRenderer.h @@ -33,6 +33,7 @@ class EpdRenderer { void drawImage(const uint8_t bitmap[], int x, int y, int width, int height) const; void drawImageNoMargin(const uint8_t bitmap[], int x, int y, int width, int height) const; + void swapBuffers() const; void copyGrayscaleLsbBuffers() const; void copyGrayscaleMsbBuffers() const; void displayGrayBuffer() const; @@ -41,7 +42,7 @@ class EpdRenderer { void invertScreen() const; void flushDisplay(EInkDisplay::RefreshMode refreshMode = EInkDisplay::FAST_REFRESH) const; - void flushArea(int x, int y, int width, int height) const; + // void flushArea(int x, int y, int width, int height) const; int getPageWidth() const; int getPageHeight() const; diff --git a/open-x4-sdk b/open-x4-sdk index fe963b3..a126d4b 160000 --- a/open-x4-sdk +++ b/open-x4-sdk @@ -1 +1 @@ -Subproject commit fe963b32821dec7fb22abbfa22daa8fc67f286d1 +Subproject commit a126d4b0bf66cd2895d11748774f7ec2c366cc4c diff --git a/src/screens/EpubReaderScreen.cpp b/src/screens/EpubReaderScreen.cpp index 448a054..3201a0d 100644 --- a/src/screens/EpubReaderScreen.cpp +++ b/src/screens/EpubReaderScreen.cpp @@ -160,10 +160,12 @@ void EpubReaderScreen::renderScreen() { constexpr int y = 50; const int w = textWidth + margin * 2; const int h = renderer.getLineHeight() + margin * 2; + renderer.swapBuffers(); renderer.fillRect(x, y, w, h, 0); renderer.drawText(x + margin, y + margin, "Indexing..."); renderer.drawRect(x + 5, y + 5, w - 10, h - 10); - renderer.flushArea(x, y, w, h); + renderer.flushDisplay(EInkDisplay::HALF_REFRESH); + pagesUntilFullRefresh = 0; } section->setupCacheDir();