From 9c11f3e4a26762fc13c2ebadd131ca91abf5d646 Mon Sep 17 00:00:00 2001 From: bdeshi Date: Mon, 13 Apr 2026 01:31:26 +0600 Subject: [PATCH] feat: enable manual screen refresh on power button short press (#1626) ## Summary Adds an option to allow manual screen refresh on power button short press. ## Additional Context there's an option to refresh the screen after a set number of pages. but sometimes a manual refresh is needed to clear up stale ink pixels. this works everywhere both in and out of reading mode. resolves #550 --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**PARTIALLY**_, to understand the project structure. --- lib/I18n/translations/english.yaml | 1 + src/CrossPointSettings.h | 2 +- src/SettingsList.h | 4 ++-- src/main.cpp | 10 +++++++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/I18n/translations/english.yaml b/lib/I18n/translations/english.yaml index b741a85d0..a948ea5a8 100644 --- a/lib/I18n/translations/english.yaml +++ b/lib/I18n/translations/english.yaml @@ -127,6 +127,7 @@ STR_ALWAYS: "Always" STR_IGNORE: "Ignore" STR_SLEEP: "Sleep" STR_PAGE_TURN: "Page Turn" +STR_FORCE_REFRESH: "Refresh Screen" STR_PORTRAIT: "Portrait" STR_LANDSCAPE_CW: "Landscape CW" STR_INVERTED: "Inverted" diff --git a/src/CrossPointSettings.h b/src/CrossPointSettings.h index 9a0e298b0..43dbcba6b 100644 --- a/src/CrossPointSettings.h +++ b/src/CrossPointSettings.h @@ -126,7 +126,7 @@ class CrossPointSettings { }; // Short power button press actions - enum SHORT_PWRBTN { IGNORE = 0, SLEEP = 1, PAGE_TURN = 2, SHORT_PWRBTN_COUNT }; + enum SHORT_PWRBTN { IGNORE = 0, SLEEP = 1, PAGE_TURN = 2, FORCE_REFRESH = 3, SHORT_PWRBTN_COUNT }; // Hide battery percentage enum HIDE_BATTERY_PERCENTAGE { HIDE_NEVER = 0, HIDE_READER = 1, HIDE_ALWAYS = 2, HIDE_BATTERY_PERCENTAGE_COUNT }; diff --git a/src/SettingsList.h b/src/SettingsList.h index cdbee372c..50225c467 100644 --- a/src/SettingsList.h +++ b/src/SettingsList.h @@ -71,8 +71,8 @@ inline const std::vector& getSettingsList() { SettingInfo::Toggle(StrId::STR_LONG_PRESS_SKIP, &CrossPointSettings::longPressChapterSkip, "longPressChapterSkip", StrId::STR_CAT_CONTROLS), SettingInfo::Enum(StrId::STR_SHORT_PWR_BTN, &CrossPointSettings::shortPwrBtn, - {StrId::STR_IGNORE, StrId::STR_SLEEP, StrId::STR_PAGE_TURN}, "shortPwrBtn", - StrId::STR_CAT_CONTROLS), + {StrId::STR_IGNORE, StrId::STR_SLEEP, StrId::STR_PAGE_TURN, StrId::STR_FORCE_REFRESH}, + "shortPwrBtn", StrId::STR_CAT_CONTROLS), // --- System --- SettingInfo::Enum(StrId::STR_TIME_TO_SLEEP, &CrossPointSettings::sleepTimeout, diff --git a/src/main.cpp b/src/main.cpp index 5ba58cbcb..e77e8ba6f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -379,6 +379,14 @@ void loop() { return; } + // Refresh screen when power button is short-pressed with FORCE_REFRESH setting. + if (SETTINGS.shortPwrBtn == CrossPointSettings::SHORT_PWRBTN::FORCE_REFRESH && + mappedInputManager.wasReleased(MappedInputManager::Button::Power)) { + LOG_DBG("MAIN", "Manual screen refresh triggered"); + RenderLock lock; + renderer.displayBuffer(HalDisplay::HALF_REFRESH); + } + // Refresh the battery icon when USB is plugged or unplugged. // Placed after sleep guards so we never queue a render that won't be processed. if (gpio.wasUsbStateChanged()) { @@ -413,4 +421,4 @@ void loop() { delay(10); } } -} \ No newline at end of file +}