From beeab0ff55fab3ff5c25757232abd10fbc70592b Mon Sep 17 00:00:00 2001 From: jpirnay Date: Fri, 13 Mar 2026 21:15:05 +0100 Subject: [PATCH 1/2] cast currentpage --- src/activities/boot_sleep/SleepActivity.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/activities/boot_sleep/SleepActivity.cpp b/src/activities/boot_sleep/SleepActivity.cpp index c1667bad..4da0e560 100644 --- a/src/activities/boot_sleep/SleepActivity.cpp +++ b/src/activities/boot_sleep/SleepActivity.cpp @@ -144,7 +144,10 @@ std::string SleepActivity::getBookOverlayText(const std::string& bookPath) const if (Storage.openFileForRead("SLP", xtc.getCachePath() + "/progress.bin", f)) { uint8_t data[4]; if (f.read(data, 4) == 4) { - uint32_t currentPage = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); + uint32_t currentPage = static_cast(data[0]) | + (static_cast(data[1]) << 8) | + (static_cast(data[2]) << 16) | + (static_cast(data[3]) << 24); uint32_t totalPages = xtc.getPageCount(); float progress = xtc.calculateProgress(currentPage) * 100.0f; char progressStr[32]; From 7144450934d68dc980292fa3d958f3c68a60bfc7 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Wed, 18 Mar 2026 12:38:08 +0100 Subject: [PATCH 2/2] Fix information box --- src/activities/boot_sleep/SleepActivity.cpp | 26 +++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/activities/boot_sleep/SleepActivity.cpp b/src/activities/boot_sleep/SleepActivity.cpp index 4da0e560..d0842973 100644 --- a/src/activities/boot_sleep/SleepActivity.cpp +++ b/src/activities/boot_sleep/SleepActivity.cpp @@ -144,10 +144,8 @@ std::string SleepActivity::getBookOverlayText(const std::string& bookPath) const if (Storage.openFileForRead("SLP", xtc.getCachePath() + "/progress.bin", f)) { uint8_t data[4]; if (f.read(data, 4) == 4) { - uint32_t currentPage = static_cast(data[0]) | - (static_cast(data[1]) << 8) | - (static_cast(data[2]) << 16) | - (static_cast(data[3]) << 24); + uint32_t currentPage = static_cast(data[0]) | (static_cast(data[1]) << 8) | + (static_cast(data[2]) << 16) | (static_cast(data[3]) << 24); uint32_t totalPages = xtc.getPageCount(); float progress = xtc.calculateProgress(currentPage) * 100.0f; char progressStr[32]; @@ -326,19 +324,23 @@ void SleepActivity::renderBitmapSleepScreen(const Bitmap& bitmap) const { line1 = renderer.truncatedText(UI_10_FONT_ID, line1.c_str(), pageWidth - 20); line2 = renderer.truncatedText(UI_10_FONT_ID, line2.c_str(), pageWidth - 20); - // Draw white background rectangle at the bottom (taller for two lines) - const int overlayHeight = 50; - const int overlayY = pageHeight - overlayHeight - 20; // Position 20 pixels higher from bottom + // Compute overlay height to exactly fit the text lines with equal top/bottom padding + const int lineHeight = renderer.getLineHeight(UI_10_FONT_ID); + constexpr int lineSpacing = 4; + constexpr int overlayPadding = 10; + const int numLines = line2.empty() ? 1 : 2; + const int textBlockHeight = numLines * lineHeight + (numLines - 1) * lineSpacing; + const int overlayHeight = textBlockHeight + overlayPadding * 2; + const int overlayY = pageHeight - overlayHeight - 20; renderer.fillRect(0, overlayY, pageWidth, overlayHeight, false); // White background - // First line - positioned higher in the overlay - const int line1Y = overlayY + 18; // Position higher up + // Center text block vertically in the overlay rectangle + const int textStartY = overlayY + (overlayHeight - textBlockHeight) / 2; const int textX1 = (pageWidth - renderer.getTextWidth(UI_10_FONT_ID, line1.c_str())) / 2; - renderer.drawText(UI_10_FONT_ID, textX1, line1Y, line1.c_str(), true); // Black text + renderer.drawText(UI_10_FONT_ID, textX1, textStartY, line1.c_str(), true); // Black text - // Second line - positioned lower in the overlay if (!line2.empty()) { - const int line2Y = overlayY + 38; // Position lower down with more space + const int line2Y = textStartY + lineHeight + lineSpacing; const int textX2 = (pageWidth - renderer.getTextWidth(UI_10_FONT_ID, line2.c_str())) / 2; renderer.drawText(UI_10_FONT_ID, textX2, line2Y, line2.c_str(), true); // Black text }