feat: wakeup target detection#731
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements wakeup target detection to improve the user experience when waking from sleep. The device now tracks whether it went to sleep from the reader view and uses this information to determine the appropriate wakeup destination.
Changes:
- Added
lastSleepFromReaderboolean flag to track sleep origin - Introduced
isReaderActivity()virtual method to identify reader activities - Modified wakeup logic to consider both the presence of an open book and the sleep origin
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/CrossPointState.h | Added lastSleepFromReader boolean field to state |
| src/CrossPointState.cpp | Bumped state file version to 4, added serialization for lastSleepFromReader with backward compatibility |
| src/activities/Activity.h | Added virtual isReaderActivity() method returning false by default |
| src/activities/reader/ReaderActivity.h | Overrode isReaderActivity() to return true for reader activities |
| src/main.cpp | Set lastSleepFromReader on sleep, added it to wakeup condition check |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Could this be extended to effectively implement deep sleep during reading? As in a flow of:
It would effectively save a lot of battery life for the use case of reading |
Yeah, I thought of something similar. But the only way to wake up from deepsleep is the power button, that's how the device is wired. And waking up can take up to a second, not really suitable for reading |
lukestein
left a comment
There was a problem hiding this comment.
No code review conducted, but tested on device, and seems to work exactly as expected.
Thank you! 🎉 A nice little bit of UX polish.
jdk2pq
left a comment
There was a problem hiding this comment.
LGTM! I left one minor, non-blocking comment for consideration, but I'm totally fine with resolving it as is too. Great job!
| // Enter deep sleep mode | ||
| void enterDeepSleep() { | ||
| APP_STATE.lastSleepFromReader = currentActivity && currentActivity->isReaderActivity(); | ||
| APP_STATE.saveToFile(); |
There was a problem hiding this comment.
minor, non-blocking: saveToFile() returns a bool that could be checked and have some kind of Serial debug statement about not being able to save the APP_STATE. But that's not currently a pattern we follow anywhere else saveToFile or loadFromFile gets called, so I'm completely fine with leaving this as is too.
## Summary * If going to sleep was from the Reader view, wake up to the same book. Otherwise, wakeup to the Home view
## Summary * If going to sleep was from the Reader view, wake up to the same book. Otherwise, wakeup to the Home view
## Summary * If going to sleep was from the Reader view, wake up to the same book. Otherwise, wakeup to the Home view
## Summary * If going to sleep was from the Reader view, wake up to the same book. Otherwise, wakeup to the Home view
…king-space * master: feat: Add percentage support to CSS properties (crosspoint-reader#738) Use GITHUB_REF_NAME over GITHUB_HEAD_REF in release candidate workflow Add release candidate workflow fix: Allow OTA update from RC build to full release (crosspoint-reader#778) fix(ui): Add Back label in KOReader Sync screen (crosspoint-reader#770) fix: Add EPUB 3 cover image detection (crosspoint-reader#760) feat: A web editor for settings (crosspoint-reader#667) feat: add HalStorage (crosspoint-reader#656) perf: optimize drawPixel() (crosspoint-reader#748) feat: wakeup target detection (crosspoint-reader#731) fix: Scrolling page items calculation (crosspoint-reader#716) refactor: Rename "Embedded Style" to "Book's Embedded Style" (crosspoint-reader#746) feat: optimize fillRectDither (crosspoint-reader#737)
## Summary * If going to sleep was from the Reader view, wake up to the same book. Otherwise, wakeup to the Home view
…king-space * master: feat: use natural sort in file browser (crosspoint-reader#722) fix: issue if book href are absolute url and not relative to server (crosspoint-reader#741) feat: unify navigation handling with system-wide continuous navigation (crosspoint-reader#600) feat: Add Italian hyphenation support (crosspoint-reader#584) feat: Add percentage support to CSS properties (crosspoint-reader#738) Use GITHUB_REF_NAME over GITHUB_HEAD_REF in release candidate workflow Move release candidate workflow to manual dispatch fix: Allow OTA update from RC build to full release (crosspoint-reader#778) refactor: Rename "Embedded Style" to "Book's Embedded Style" (crosspoint-reader#746) perf: optimize drawPixel() (crosspoint-reader#748) feat: wakeup target detection (crosspoint-reader#731) fix: Scrolling page items calculation (crosspoint-reader#716) feat: optimize fillRectDither (crosspoint-reader#737) fix: increase lyra sideButtonHintsWidth to 30 (crosspoint-reader#727) fix: Remove separations after style changes (crosspoint-reader#720) fix: Lag before displaying covers on home screen (crosspoint-reader#721) feat: Add Settings for toggling CSS on or off (crosspoint-reader#717) Use GITHUB_HEAD_REF release: 1.0.0
* master: (25 commits) fix: Reduce MIN_SIZE_FOR_POPUP to 10KB (crosspoint-reader#809) docs: Update USER_GUIDE.md (crosspoint-reader#817) fix: Prevent sleeping when in OPDS browser / downloading books (crosspoint-reader#818) feat: Extend python debugging monitor functionality (keyword filter / suppress) (crosspoint-reader#810) docs: Update USER_GUIDE.md (crosspoint-reader#808) feat: Connect to last wifi by default (crosspoint-reader#752) feat: use natural sort in file browser (crosspoint-reader#722) fix: issue if book href are absolute url and not relative to server (crosspoint-reader#741) feat: unify navigation handling with system-wide continuous navigation (crosspoint-reader#600) feat: Add Italian hyphenation support (crosspoint-reader#584) feat: Add percentage support to CSS properties (crosspoint-reader#738) Use GITHUB_REF_NAME over GITHUB_HEAD_REF in release candidate workflow Move release candidate workflow to manual dispatch fix: Allow OTA update from RC build to full release (crosspoint-reader#778) refactor: Rename "Embedded Style" to "Book's Embedded Style" (crosspoint-reader#746) perf: optimize drawPixel() (crosspoint-reader#748) feat: wakeup target detection (crosspoint-reader#731) fix: Scrolling page items calculation (crosspoint-reader#716) feat: optimize fillRectDither (crosspoint-reader#737) fix: increase lyra sideButtonHintsWidth to 30 (crosspoint-reader#727) ...
## Summary * If going to sleep was from the Reader view, wake up to the same book. Otherwise, wakeup to the Home view
## Summary * If going to sleep was from the Reader view, wake up to the same book. Otherwise, wakeup to the Home view
Summary