From e08bac2e10bffc761a70ec6ecaad79db1186bc77 Mon Sep 17 00:00:00 2001 From: Dave Allie Date: Fri, 5 Dec 2025 21:12:15 +1100 Subject: [PATCH] Show indexing text when indexing --- lib/EpdFontRenderer/EpdFontRenderer.hpp | 2 +- lib/EpdRenderer/EpdRenderer.cpp | 5 ++--- src/screens/EpubReaderScreen.cpp | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/EpdFontRenderer/EpdFontRenderer.hpp b/lib/EpdFontRenderer/EpdFontRenderer.hpp index b9c3437..647ab7c 100644 --- a/lib/EpdFontRenderer/EpdFontRenderer.hpp +++ b/lib/EpdFontRenderer/EpdFontRenderer.hpp @@ -89,7 +89,7 @@ void EpdFontRenderer::renderChar(const uint32_t cp, int* x, const in if (font->data->compressed) { auto* tmpBitmap = static_cast(malloc(bitmapSize)); if (tmpBitmap == nullptr && bitmapSize) { - // ESP_LOGE("font", "malloc failed."); + Serial.println("Failed to allocate memory for decompression buffer"); return; } diff --git a/lib/EpdRenderer/EpdRenderer.cpp b/lib/EpdRenderer/EpdRenderer.cpp index 3180304..455d367 100644 --- a/lib/EpdRenderer/EpdRenderer.cpp +++ b/lib/EpdRenderer/EpdRenderer.cpp @@ -120,9 +120,8 @@ void EpdRenderer::clearScreen(const bool black) const { void EpdRenderer::flushDisplay(const bool partialUpdate) const { display->display(partialUpdate); } -void EpdRenderer::flushArea(int x, int y, int width, int height) const { - // TODO: Fix - display->display(true); +void EpdRenderer::flushArea(const int x, const int y, const int width, const int height) const { + display->displayWindow(x, y, width, height); } int EpdRenderer::getPageWidth() const { return display->width() - marginLeft - marginRight; } diff --git a/src/screens/EpubReaderScreen.cpp b/src/screens/EpubReaderScreen.cpp index d19950d..a75e89d 100644 --- a/src/screens/EpubReaderScreen.cpp +++ b/src/screens/EpubReaderScreen.cpp @@ -123,6 +123,20 @@ void EpubReaderScreen::renderPage() { section = new Section(epub, currentSpineIndex, renderer); if (!section->hasCache()) { Serial.println("Cache not found, building..."); + + { + const int textWidth = renderer->getTextWidth("Indexing..."); + constexpr int margin = 20; + const int x = (renderer->getPageWidth() - textWidth - margin * 2) / 2; + constexpr int y = 50; + const int w = textWidth + margin * 2; + const int h = renderer->getLineHeight() + margin * 2; + renderer->fillRect(x, y, w, h, 0); + renderer->drawText(x + margin, y + margin, "Indexing..."); + renderer->drawRect(x + 5, y + 5, w - 10, h - 10, 1); + renderer->flushArea(x - 20, y - 20, w + 40, h + 40); + } + section->setupCacheDir(); if (!section->persistPageDataToSD()) { Serial.println("Failed to persist page data to SD");