diff --git a/USER_GUIDE.md b/USER_GUIDE.md index d670abb7..0e52ef90 100644 --- a/USER_GUIDE.md +++ b/USER_GUIDE.md @@ -90,6 +90,7 @@ The Settings screen allows you to configure the device's behavior. There are a f - "Custom" - Custom images from the SD card; see [Sleep Screen](#36-sleep-screen) below for more information - "Cover" - The book cover image (Note: this is experimental and may not work as expected) - "None" - A blank screen + - "Last" - Preserve the last content displayed on the screen - **Sleep Screen Cover Mode**: How to display the book cover when "Cover" sleep screen is selected: - "Fit" (default) - Scale the image down to fit centered on the screen, padding with white borders as necessary - "Crop" - Scale the image down and crop as necessary to try to to fill the screen (Note: this is experimental and may not work as expected) diff --git a/src/CrossPointSettings.h b/src/CrossPointSettings.h index 8ce32a2c..4097835a 100644 --- a/src/CrossPointSettings.h +++ b/src/CrossPointSettings.h @@ -16,7 +16,7 @@ class CrossPointSettings { CrossPointSettings& operator=(const CrossPointSettings&) = delete; // Should match with SettingsActivity text - enum SLEEP_SCREEN_MODE { DARK = 0, LIGHT = 1, CUSTOM = 2, COVER = 3, BLANK = 4 }; + enum SLEEP_SCREEN_MODE { DARK = 0, LIGHT = 1, CUSTOM = 2, COVER = 3, BLANK = 4, LAST = 5 }; enum SLEEP_SCREEN_COVER_MODE { FIT = 0, CROP = 1 }; // Status bar display type enum diff --git a/src/activities/boot_sleep/SleepActivity.cpp b/src/activities/boot_sleep/SleepActivity.cpp index c0d6844f..c93add90 100644 --- a/src/activities/boot_sleep/SleepActivity.cpp +++ b/src/activities/boot_sleep/SleepActivity.cpp @@ -14,6 +14,11 @@ void SleepActivity::onEnter() { Activity::onEnter(); + + if (SETTINGS.sleepScreen == CrossPointSettings::SLEEP_SCREEN_MODE::LAST) { + return renderLastSleepScreen(); + } + renderPopup("Entering Sleep..."); if (SETTINGS.sleepScreen == CrossPointSettings::SLEEP_SCREEN_MODE::BLANK) { @@ -272,3 +277,16 @@ void SleepActivity::renderBlankSleepScreen() const { renderer.clearScreen(); renderer.displayBuffer(EInkDisplay::HALF_REFRESH); } + +void SleepActivity::renderLastSleepScreen() const { + const char * text = "SLEEPING"; + const int textWidth = renderer.getTextWidth(UI_10_FONT_ID, text, EpdFontFamily::BOLD); + constexpr int margin = 5; + const int x = (renderer.getScreenWidth() - textWidth - margin * 2) / 2; + const int y = (renderer.getScreenHeight() - renderer.getLineHeight(UI_10_FONT_ID) - 20); + const int w = textWidth + margin * 2; + const int h = renderer.getLineHeight(UI_10_FONT_ID) + margin * 2; + renderer.fillRect(x, y, w, h, true); + renderer.drawText(UI_10_FONT_ID, x + margin, y + margin, text, false, EpdFontFamily::BOLD); + renderer.displayBuffer(); +} diff --git a/src/activities/boot_sleep/SleepActivity.h b/src/activities/boot_sleep/SleepActivity.h index 283220ce..98555055 100644 --- a/src/activities/boot_sleep/SleepActivity.h +++ b/src/activities/boot_sleep/SleepActivity.h @@ -16,4 +16,5 @@ class SleepActivity final : public Activity { void renderCoverSleepScreen() const; void renderBitmapSleepScreen(const Bitmap& bitmap) const; void renderBlankSleepScreen() const; + void renderLastSleepScreen() const; }; diff --git a/src/activities/settings/SettingsActivity.cpp b/src/activities/settings/SettingsActivity.cpp index 943fdb4c..a4681135 100644 --- a/src/activities/settings/SettingsActivity.cpp +++ b/src/activities/settings/SettingsActivity.cpp @@ -14,7 +14,7 @@ namespace { constexpr int displaySettingsCount = 5; const SettingInfo displaySettings[displaySettingsCount] = { // Should match with SLEEP_SCREEN_MODE - SettingInfo::Enum("Sleep Screen", &CrossPointSettings::sleepScreen, {"Dark", "Light", "Custom", "Cover", "None"}), + SettingInfo::Enum("Sleep Screen", &CrossPointSettings::sleepScreen, {"Dark", "Light", "Custom", "Cover", "None", "Last"}), SettingInfo::Enum("Sleep Screen Cover Mode", &CrossPointSettings::sleepScreenCoverMode, {"Fit", "Crop"}), SettingInfo::Enum("Status Bar", &CrossPointSettings::statusBar, {"None", "No Progress", "Full"}), SettingInfo::Enum("Hide Battery %", &CrossPointSettings::hideBatteryPercentage, {"Never", "In Reader", "Always"}),