feat: add custom sleep timer picker (#2206)
## Summary * **What is the goal of this PR?** Mainly fixes #2196, but also allows users to set a sleep time of 1~30 min or to never sleep. * **What changes are included?** 1. Revert changes from #1948 and #2137 (Sorry @Uri-Tauber) 2. Cherrypick changes from https://github.com/uxjulia/CrossInk/commit/0cb91c3dd1c63f0559d4392fadc4a8340af5bdde and https://github.com/uxjulia/CrossInk/commit/4e6bd634b6ede51ff1a7107ba3e8efcd152bc6ee for a timeout interval picker UI, the custom sleep time feature, and migrate the existing setting in v1.3.0, `sleepTimeout`, to `sleepTimeoutMinutes` (Thanks! @uxjulia) 3. Add a "Never" at the far right of the timeout interval picker --- ### 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**_ --------- Co-authored-by: Julia <julia@uxj.io>
This commit is contained in:
@@ -115,11 +115,10 @@ class CrossPointSettings {
|
||||
// Auto-sleep timeout options (in minutes)
|
||||
enum SLEEP_TIMEOUT {
|
||||
SLEEP_1_MIN = 0,
|
||||
SLEEP_3_MIN = 1,
|
||||
SLEEP_5_MIN = 2,
|
||||
SLEEP_10_MIN = 3,
|
||||
SLEEP_15_MIN = 4,
|
||||
SLEEP_30_MIN = 5,
|
||||
SLEEP_5_MIN = 1,
|
||||
SLEEP_10_MIN = 2,
|
||||
SLEEP_15_MIN = 3,
|
||||
SLEEP_30_MIN = 4,
|
||||
SLEEP_TIMEOUT_COUNT
|
||||
};
|
||||
|
||||
@@ -210,8 +209,8 @@ class CrossPointSettings {
|
||||
uint8_t fontSize = MEDIUM;
|
||||
uint8_t lineSpacing = NORMAL;
|
||||
uint8_t paragraphAlignment = JUSTIFIED;
|
||||
// Auto-sleep timeout setting (default 10 minutes)
|
||||
uint8_t sleepTimeout = SLEEP_10_MIN;
|
||||
// Auto-sleep timeout setting (default 10 minutes). Legacy sleepTimeout enum values are migration-only.
|
||||
uint8_t sleepTimeoutMinutes = 10;
|
||||
// E-ink refresh frequency (default 15 pages)
|
||||
uint8_t refreshFrequency = REFRESH_15;
|
||||
uint8_t hyphenationEnabled = 0;
|
||||
@@ -256,6 +255,10 @@ class CrossPointSettings {
|
||||
// Get singleton instance
|
||||
static CrossPointSettings& getInstance() { return instance; }
|
||||
|
||||
static constexpr uint8_t MIN_SLEEP_TIMEOUT_MINUTES = 1;
|
||||
static constexpr uint8_t SLEEP_TIMEOUT_NEVER_MINUTES = 31;
|
||||
static constexpr uint8_t MAX_SLEEP_TIMEOUT_MINUTES = SLEEP_TIMEOUT_NEVER_MINUTES;
|
||||
|
||||
// Callback to resolve SD card font IDs. Set by SdCardFontSystem::begin().
|
||||
// Returns font ID or 0 if not found.
|
||||
using SdFontIdResolver = int (*)(void* ctx, const char* familyName, uint8_t fontSize);
|
||||
@@ -274,6 +277,7 @@ class CrossPointSettings {
|
||||
bool loadFromFile();
|
||||
|
||||
static void validateFrontButtonMapping(CrossPointSettings& settings);
|
||||
static uint8_t sleepTimeoutEnumToMinutes(uint8_t legacyValue);
|
||||
|
||||
private:
|
||||
bool loadFromBinaryFile();
|
||||
|
||||
Reference in New Issue
Block a user