From 7d49feea1895a9f95fb5ccd3c12ea0687887573d Mon Sep 17 00:00:00 2001 From: Baris Albayrak Date: Thu, 22 Jan 2026 23:17:41 +1100 Subject: [PATCH 1/2] Feat: Implement reading rotation via long-press confirm button --- src/activities/reader/EpubReaderActivity.cpp | 49 +++++++++++++++++++- src/activities/reader/EpubReaderActivity.h | 1 + 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index 6ff39c5e..506b6e5e 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -17,6 +17,7 @@ namespace { // pagesPerRefresh now comes from SETTINGS.getRefreshFrequency() constexpr unsigned long skipChapterMs = 700; constexpr unsigned long goHomeMs = 1000; +constexpr unsigned long rotateScreenMs = 1000; constexpr int statusBarMargin = 19; } // namespace @@ -116,8 +117,14 @@ void EpubReaderActivity::loop() { return; } + // Long press CONFIRM (1s+) rotates the screen + if (mappedInput.wasReleased(MappedInputManager::Button::Confirm) && mappedInput.getHeldTime() >= rotateScreenMs) { + rotateScreen(); + return; + } + // Enter chapter selection activity - if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) { + if (mappedInput.wasReleased(MappedInputManager::Button::Confirm) && mappedInput.getHeldTime() < rotateScreenMs) { // Don't start activity transition while rendering xSemaphoreTake(renderingMutex, portMAX_DELAY); const int currentPage = section ? section->currentPage : 0; @@ -500,3 +507,43 @@ void EpubReaderActivity::renderStatusBar(const int orientedMarginRight, const in title.c_str()); } } + +void EpubReaderActivity::rotateScreen() { + // We don't want to change orientation mid-render, so grab the semaphore + xSemaphoreTake(renderingMutex, portMAX_DELAY); + + // + // Cycle to next orientation + // + uint8_t newOrientation = (SETTINGS.orientation + 1) % 4; + SETTINGS.orientation = newOrientation; + SETTINGS.saveToFile(); + + // + // Apply orientation to renderer + // + switch (SETTINGS.orientation) { + case CrossPointSettings::ORIENTATION::PORTRAIT: + renderer.setOrientation(GfxRenderer::Orientation::Portrait); + break; + case CrossPointSettings::ORIENTATION::LANDSCAPE_CW: + renderer.setOrientation(GfxRenderer::Orientation::LandscapeClockwise); + break; + case CrossPointSettings::ORIENTATION::INVERTED: + renderer.setOrientation(GfxRenderer::Orientation::PortraitInverted); + break; + case CrossPointSettings::ORIENTATION::LANDSCAPE_CCW: + renderer.setOrientation(GfxRenderer::Orientation::LandscapeCounterClockwise); + break; + default: + break; + } + + // + // Force a redraw + // + section.reset(); + updateRequired = true; + + xSemaphoreGive(renderingMutex); +} diff --git a/src/activities/reader/EpubReaderActivity.h b/src/activities/reader/EpubReaderActivity.h index 63d48872..9b4c3b37 100644 --- a/src/activities/reader/EpubReaderActivity.h +++ b/src/activities/reader/EpubReaderActivity.h @@ -25,6 +25,7 @@ class EpubReaderActivity final : public ActivityWithSubactivity { void renderContents(std::unique_ptr page, int orientedMarginTop, int orientedMarginRight, int orientedMarginBottom, int orientedMarginLeft); void renderStatusBar(int orientedMarginRight, int orientedMarginBottom, int orientedMarginLeft) const; + void rotateScreen(); public: explicit EpubReaderActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, std::unique_ptr epub, From 616619d0d3f8df485d2d9b30b782dd1460d904e2 Mon Sep 17 00:00:00 2001 From: Baris Albayrak Date: Fri, 23 Jan 2026 00:01:29 +1100 Subject: [PATCH 2/2] Fix: Preserve page number when rotating screen Previously, rotating the screen would reset the reading position to the beginning of the chapter. This change ensures the current page number is stored and restored after the view re-renders. --- src/activities/reader/EpubReaderActivity.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index 506b6e5e..162c9d53 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -512,6 +512,11 @@ void EpubReaderActivity::rotateScreen() { // We don't want to change orientation mid-render, so grab the semaphore xSemaphoreTake(renderingMutex, portMAX_DELAY); + // If a section is loaded, preserve the current page number + if (section) { + nextPageNumber = section->currentPage; + } + // // Cycle to next orientation //