From fd111fbf98ff074cade26a5908d9561cfc4cbd01 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Fri, 1 May 2026 16:07:48 +0200 Subject: [PATCH] Fix screenshot button bleed through --- lib/I18n/translations/english.yaml | 3 ++- src/CrossPointSettings.h | 1 + src/SettingsList.h | 14 +++++++------- src/main.cpp | 15 ++++++++++++++- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/lib/I18n/translations/english.yaml b/lib/I18n/translations/english.yaml index c214eb27..ac81a192 100644 --- a/lib/I18n/translations/english.yaml +++ b/lib/I18n/translations/english.yaml @@ -574,6 +574,7 @@ STR_BTN_ACT_PAGE_BACK_10: "Skip 10 Pages Back" STR_BTN_ACT_GO_HOME: "Go Home" STR_BTN_ACT_SLEEP: "Sleep" STR_BTN_ACT_FORCE_REFRESH: "Refresh Screen" +STR_BTN_ACT_FORCE_FAST_REFRESH: "Fast Refresh Screen" STR_BTN_ACT_OPEN_TOC: "Open Table of Contents" STR_BTN_ACT_OPEN_BOOKMARKS: "Open Bookmarks" STR_BTN_ACT_STAR_PAGE: "Star Page" @@ -599,4 +600,4 @@ STR_KB_HINT_UPPER_SECONDARY: "Hold SELECT for UPPERCASE or secondary char" STR_KB_HINT_LOWER_SECONDARY: "Hold SELECT for lowercase or secondary char" STR_KB_HINT_URL_SNIPPETS: "Press URL for snippets" STR_BIONIC_READING: "Bionic Reading" -STR_BTN_ACT_TOGGLE_BIONIC_READING: "Toggle Bionic Reading" \ No newline at end of file +STR_BTN_ACT_TOGGLE_BIONIC_READING: "Toggle Bionic Reading" diff --git a/src/CrossPointSettings.h b/src/CrossPointSettings.h index d970db53..1ae575d3 100644 --- a/src/CrossPointSettings.h +++ b/src/CrossPointSettings.h @@ -278,6 +278,7 @@ class CrossPointSettings { BTN_GO_HOME, BTN_SLEEP, BTN_FORCE_REFRESH, + BTN_FORCE_FAST_REFRESH, BTN_OPEN_TOC, BTN_OPEN_BOOKMARKS, BTN_STAR_PAGE, diff --git a/src/SettingsList.h b/src/SettingsList.h index ed1c4269..75d10ac2 100644 --- a/src/SettingsList.h +++ b/src/SettingsList.h @@ -141,13 +141,13 @@ inline const std::vector list = { // All entries share the same ordered action-label list; the submenu groups them behind // a single placeholder row in the device UI. // Shared action options (everything except the first "default" entry). -#define BTN_ACT_OPTIONS \ - StrId::STR_BTN_ACT_PAGE_FORWARD, StrId::STR_BTN_ACT_PAGE_BACK, StrId::STR_BTN_ACT_PAGE_FORWARD_10, \ - StrId::STR_BTN_ACT_PAGE_BACK_10, StrId::STR_BTN_ACT_GO_HOME, StrId::STR_BTN_ACT_SLEEP, \ - StrId::STR_BTN_ACT_FORCE_REFRESH, StrId::STR_BTN_ACT_OPEN_TOC, StrId::STR_BTN_ACT_OPEN_BOOKMARKS, \ - StrId::STR_BTN_ACT_STAR_PAGE, StrId::STR_BTN_ACT_FOOTNOTES, StrId::STR_BTN_ACT_NEXT_SECTION, \ - StrId::STR_BTN_ACT_PREV_SECTION, StrId::STR_BTN_ACT_EXIT_READER, StrId::STR_BTN_ACT_READER_MENU, \ - StrId::STR_BTN_ACT_TOGGLE_BIONIC_READING, StrId::STR_BTN_ACT_KOREADER_SYNC +#define BTN_ACT_OPTIONS \ + StrId::STR_BTN_ACT_PAGE_FORWARD, StrId::STR_BTN_ACT_PAGE_BACK, StrId::STR_BTN_ACT_PAGE_FORWARD_10, \ + StrId::STR_BTN_ACT_PAGE_BACK_10, StrId::STR_BTN_ACT_GO_HOME, StrId::STR_BTN_ACT_SLEEP, \ + StrId::STR_BTN_ACT_FORCE_REFRESH, StrId::STR_BTN_ACT_FORCE_FAST_REFRESH, StrId::STR_BTN_ACT_OPEN_TOC, \ + StrId::STR_BTN_ACT_OPEN_BOOKMARKS, StrId::STR_BTN_ACT_STAR_PAGE, StrId::STR_BTN_ACT_FOOTNOTES, \ + StrId::STR_BTN_ACT_NEXT_SECTION, StrId::STR_BTN_ACT_PREV_SECTION, StrId::STR_BTN_ACT_EXIT_READER, \ + StrId::STR_BTN_ACT_READER_MENU, StrId::STR_BTN_ACT_TOGGLE_BIONIC_READING, StrId::STR_BTN_ACT_KOREADER_SYNC // Back button: short=exit reader, double=ignore, long=go home SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortBack, {StrId::STR_BTN_DEF_EXIT_READER}, diff --git a/src/main.cpp b/src/main.cpp index d84a64e4..382b71d9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -337,6 +337,11 @@ void loop() { powerManager.setPowerSaving(false); // Restore normal CPU frequency on user activity } + // Power-hold timer for sleep. Hoisted above the screenshot block so the + // screenshot path can clear it and avoid a stale POWER press triggering sleep + // after the screenshot completes. + static unsigned long powerHoldStart = 0; + static bool screenshotButtonsReleased = true; if (gpio.isPressed(HalGPIO::BTN_POWER) && gpio.isPressed(HalGPIO::BTN_DOWN)) { if (screenshotButtonsReleased) { @@ -345,6 +350,10 @@ void loop() { RenderLock lock; ScreenshotUtil::takeScreenshot(renderer); } + // Discard the POWER+DOWN presses so they don't fire Short/Long events + // (e.g. page turn, sleep) once the user releases the combo. + buttonEventManager.drain(); + powerHoldStart = 0; } return; } else { @@ -364,7 +373,6 @@ void loop() { // (wake-up press) is never misinterpreted as a "go to sleep" press. // The power button long-press is not user-remappable, so this path always owns it. // Sleep mapped to other buttons is handled by the dispatcher's BTN_SLEEP case below. - static unsigned long powerHoldStart = 0; if (gpio.wasPressed(HalGPIO::BTN_POWER)) { powerHoldStart = millis(); LOG_DBG("MAIN", "loop: power button press detected (fresh edge)"); @@ -513,6 +521,11 @@ void loop() { renderer.displayBuffer(HalDisplay::HALF_REFRESH); break; } + case BA::BTN_FORCE_FAST_REFRESH: { + RenderLock lock; + renderer.displayBuffer(HalDisplay::FAST_REFRESH); + break; + } case BA::BTN_OPEN_TOC: activityManager.dispatchButtonAction(BA::BTN_OPEN_TOC); break;