From 95cf1dcfc390f4de46757ce14f99b5c05f651ae9 Mon Sep 17 00:00:00 2001 From: Jonas Diemer Date: Fri, 19 Dec 2025 12:40:43 +0100 Subject: [PATCH] Added popup to notify we're going to sleep (loading image takes time). Skip files starting with '.' --- src/activities/boot_sleep/SleepActivity.cpp | 21 +++++++++++++++++++++ src/activities/boot_sleep/SleepActivity.h | 1 + 2 files changed, 22 insertions(+) diff --git a/src/activities/boot_sleep/SleepActivity.cpp b/src/activities/boot_sleep/SleepActivity.cpp index 53f1cf63..2be87bda 100644 --- a/src/activities/boot_sleep/SleepActivity.cpp +++ b/src/activities/boot_sleep/SleepActivity.cpp @@ -10,6 +10,7 @@ #include "images/CrossLarge.h" void SleepActivity::onEnter() { + renderPopup("Entering Sleep..."); // Check if we have a /sleep directory auto dir = SD.open("/sleep"); if (dir && dir.isDirectory()) { @@ -21,6 +22,11 @@ void SleepActivity::onEnter() { continue; } auto filename = std::string(file.name()); + if (filename[0] == '.') { + file.close(); + continue; + } + if (filename.substr(filename.length() - 4) != ".bmp") { Serial.printf("[%lu] [Slp] Skipping non-.bmp file name: %s\n", millis(), file.name()); file.close(); @@ -70,6 +76,21 @@ void SleepActivity::onEnter() { renderDefaultSleepScreen(); } +void SleepActivity::renderPopup(const char* message) const { + const int textWidth = renderer.getTextWidth(READER_FONT_ID, message); + constexpr int margin = 20; + // Round all coordinates to 8 pixel boundaries + const int x = ((GfxRenderer::getScreenWidth() - textWidth - margin * 2) / 2 + 7) / 8 * 8; + constexpr int y = 56; + const int w = (textWidth + margin * 2 + 7) / 8 * 8; + const int h = (renderer.getLineHeight(READER_FONT_ID) + margin * 2 + 7) / 8 * 8; + // renderer.clearScreen(); + renderer.fillRect(x + 5, y + 5, w - 10, h - 10, false); + renderer.drawText(READER_FONT_ID, x + margin, y + margin, message); + renderer.drawRect(x + 5, y + 5, w - 10, h - 10); + renderer.displayBuffer(); +} + void SleepActivity::renderDefaultSleepScreen() const { const auto pageWidth = GfxRenderer::getScreenWidth(); const auto pageHeight = GfxRenderer::getScreenHeight(); diff --git a/src/activities/boot_sleep/SleepActivity.h b/src/activities/boot_sleep/SleepActivity.h index 9d4a7c4d..defc1d5e 100644 --- a/src/activities/boot_sleep/SleepActivity.h +++ b/src/activities/boot_sleep/SleepActivity.h @@ -11,4 +11,5 @@ class SleepActivity final : public Activity { private: void renderDefaultSleepScreen() const; void renderCustomSleepScreen(const Bitmap& bitmap) const; + void renderPopup(const char* message) const; };