From bcda77aed5f2cf759bd2a5c80cc265aa1b14402d Mon Sep 17 00:00:00 2001 From: Eunchurn Park Date: Sat, 27 Dec 2025 19:36:05 +0900 Subject: [PATCH] fix(xtc): remove unused renderStatusBar function XTC pages have pre-rendered status bar, so the renderStatusBar function is not needed. Remove it along with unused constants and Battery.h include to fix cppcheck warnings. --- src/activities/reader/XtcReaderActivity.cpp | 61 --------------------- src/activities/reader/XtcReaderActivity.h | 1 - 2 files changed, 62 deletions(-) diff --git a/src/activities/reader/XtcReaderActivity.cpp b/src/activities/reader/XtcReaderActivity.cpp index 6a989f69..d3297529 100644 --- a/src/activities/reader/XtcReaderActivity.cpp +++ b/src/activities/reader/XtcReaderActivity.cpp @@ -11,7 +11,6 @@ #include #include -#include "Battery.h" #include "CrossPointSettings.h" #include "CrossPointState.h" #include "config.h" @@ -20,9 +19,6 @@ namespace { constexpr int pagesPerRefresh = 15; constexpr unsigned long skipPageMs = 700; constexpr unsigned long goHomeMs = 1000; -constexpr int statusBarHeight = 24; -constexpr int marginLeft = 10; -constexpr int marginRight = 10; } // namespace void XtcReaderActivity::taskTrampoline(void* param) { @@ -223,63 +219,6 @@ void XtcReaderActivity::renderPage() { Serial.printf("[%lu] [XTR] Rendered page %lu/%lu\n", millis(), currentPage + 1, xtc->getPageCount()); } -void XtcReaderActivity::renderStatusBar() const { - const int screenWidth = GfxRenderer::getScreenWidth(); - const int screenHeight = GfxRenderer::getScreenHeight(); - constexpr int textY = 776; - - // Calculate progress - const uint8_t progress = xtc->calculateProgress(currentPage); - - // Right aligned: page number and progress - const std::string progressText = std::to_string(currentPage + 1) + "/" + std::to_string(xtc->getPageCount()) + " " + - std::to_string(progress) + "%"; - const int progressTextWidth = renderer.getTextWidth(SMALL_FONT_ID, progressText.c_str()); - renderer.drawText(SMALL_FONT_ID, screenWidth - marginRight - progressTextWidth, textY, progressText.c_str()); - - // Left aligned: battery - const uint16_t percentage = battery.readPercentage(); - const std::string percentageText = std::to_string(percentage) + "%"; - const int percentageTextWidth = renderer.getTextWidth(SMALL_FONT_ID, percentageText.c_str()); - renderer.drawText(SMALL_FONT_ID, 20 + marginLeft, textY, percentageText.c_str()); - - // Battery icon - constexpr int batteryWidth = 15; - constexpr int batteryHeight = 10; - constexpr int x = marginLeft; - constexpr int y = 783; - - // Battery outline - renderer.drawLine(x, y, x + batteryWidth - 4, y); - renderer.drawLine(x, y + batteryHeight - 1, x + batteryWidth - 4, y + batteryHeight - 1); - renderer.drawLine(x, y, x, y + batteryHeight - 1); - renderer.drawLine(x + batteryWidth - 4, y, x + batteryWidth - 4, y + batteryHeight - 1); - renderer.drawLine(x + batteryWidth - 3, y + 2, x + batteryWidth - 1, y + 2); - renderer.drawLine(x + batteryWidth - 3, y + batteryHeight - 3, x + batteryWidth - 1, y + batteryHeight - 3); - renderer.drawLine(x + batteryWidth - 1, y + 2, x + batteryWidth - 1, y + batteryHeight - 3); - - // Battery fill - int filledWidth = percentage * (batteryWidth - 5) / 100 + 1; - if (filledWidth > batteryWidth - 5) { - filledWidth = batteryWidth - 5; - } - renderer.fillRect(x + 1, y + 1, filledWidth, batteryHeight - 2); - - // Center: book title - const int titleMarginLeft = 20 + percentageTextWidth + 30 + marginLeft; - const int titleMarginRight = progressTextWidth + 30 + marginRight; - const int availableTextWidth = screenWidth - titleMarginLeft - titleMarginRight; - - std::string title = xtc->getTitle(); - int titleWidth = renderer.getTextWidth(SMALL_FONT_ID, title.c_str()); - while (titleWidth > availableTextWidth && title.length() > 11) { - title.replace(title.length() - 8, 8, "..."); - titleWidth = renderer.getTextWidth(SMALL_FONT_ID, title.c_str()); - } - - renderer.drawText(SMALL_FONT_ID, titleMarginLeft + (availableTextWidth - titleWidth) / 2, textY, title.c_str()); -} - void XtcReaderActivity::saveProgress() const { File f; if (FsHelpers::openFileForWrite("XTR", xtc->getCachePath() + "/progress.bin", f)) { diff --git a/src/activities/reader/XtcReaderActivity.h b/src/activities/reader/XtcReaderActivity.h index a751c255..f923d8ad 100644 --- a/src/activities/reader/XtcReaderActivity.h +++ b/src/activities/reader/XtcReaderActivity.h @@ -28,7 +28,6 @@ class XtcReaderActivity final : public Activity { [[noreturn]] void displayTaskLoop(); void renderScreen(); void renderPage(); - void renderStatusBar() const; void saveProgress() const; void loadProgress();