feat: Extend high contrast mode to entire UI
- Add global high contrast mode flag in BitmapHelpers - Modify quantization thresholds for high contrast rendering - Update ditherer classes (Atkinson, Floyd-Steinberg) for contrast mode - Add displayContrast setting with persistence - Add "High Contrast" toggle in display settings - Apply high contrast mode on startup from saved settings
This commit is contained in:
@@ -23,7 +23,7 @@ void readAndValidate(FsFile& file, uint8_t& member, const uint8_t maxValue) {
|
||||
namespace {
|
||||
constexpr uint8_t SETTINGS_FILE_VERSION = 1;
|
||||
// Increment this when adding new persisted settings fields
|
||||
constexpr uint8_t SETTINGS_COUNT = 26; // 25 + sleepScreenCoverFilter
|
||||
constexpr uint8_t SETTINGS_COUNT = 27; // 26 + displayContrast
|
||||
constexpr char SETTINGS_FILE[] = "/.crosspoint/settings.bin";
|
||||
} // namespace
|
||||
|
||||
@@ -66,6 +66,8 @@ bool CrossPointSettings::saveToFile() const {
|
||||
serialization::writeString(outputFile, std::string(opdsPassword));
|
||||
// PR #476: B&W filter for cover images
|
||||
serialization::writePod(outputFile, sleepScreenCoverFilter);
|
||||
// System-wide display contrast
|
||||
serialization::writePod(outputFile, displayContrast);
|
||||
// New fields added at end for backward compatibility
|
||||
outputFile.close();
|
||||
|
||||
@@ -167,6 +169,9 @@ bool CrossPointSettings::loadFromFile() {
|
||||
// PR #476: B&W filter for cover images
|
||||
readAndValidate(inputFile, sleepScreenCoverFilter, SLEEP_SCREEN_COVER_FILTER_COUNT);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
// System-wide display contrast (0 = normal, 1 = high)
|
||||
serialization::readPod(inputFile, displayContrast);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
// New fields added at end for backward compatibility
|
||||
} while (false);
|
||||
|
||||
|
||||
@@ -133,6 +133,8 @@ class CrossPointSettings {
|
||||
uint8_t hideBatteryPercentage = HIDE_NEVER;
|
||||
// Long-press chapter skip on side buttons
|
||||
uint8_t longPressChapterSkip = 1;
|
||||
// System-wide display contrast (0 = normal, 1 = high)
|
||||
uint8_t displayContrast = 0;
|
||||
|
||||
// Pinned list name (empty = none pinned)
|
||||
char pinnedListName[64] = "";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "CategorySettingsActivity.h"
|
||||
|
||||
#include <BitmapHelpers.h>
|
||||
#include <GfxRenderer.h>
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
@@ -115,6 +116,11 @@ void CategorySettingsActivity::toggleCurrentSetting() {
|
||||
// Toggle the boolean value using the member pointer
|
||||
const bool currentValue = SETTINGS.*(setting.valuePtr);
|
||||
SETTINGS.*(setting.valuePtr) = !currentValue;
|
||||
|
||||
// Handle side effects for specific settings
|
||||
if (setting.valuePtr == &CrossPointSettings::displayContrast) {
|
||||
setHighContrastMode(SETTINGS.displayContrast == 1);
|
||||
}
|
||||
} else if (setting.type == SettingType::ENUM && setting.valuePtr != nullptr) {
|
||||
const uint8_t currentValue = SETTINGS.*(setting.valuePtr);
|
||||
SETTINGS.*(setting.valuePtr) = (currentValue + 1) % static_cast<uint8_t>(setting.enumValues.size());
|
||||
|
||||
@@ -19,6 +19,7 @@ const SettingInfo displaySettings[displaySettingsCount] = {
|
||||
SettingInfo::Enum("Sleep Screen Cover Mode", &CrossPointSettings::sleepScreenCoverMode, {"Fit", "Crop", "Actual"}),
|
||||
SettingInfo::Enum("Sleep Screen Cover Filter", &CrossPointSettings::sleepScreenCoverFilter,
|
||||
{"None", "Contrast", "Inverted"}),
|
||||
SettingInfo::Toggle("High Contrast", &CrossPointSettings::displayContrast),
|
||||
SettingInfo::Enum("Status Bar", &CrossPointSettings::statusBar,
|
||||
{"None", "No Progress", "Full w/ Percentage", "Full w/ Progress Bar", "Progress Bar"}),
|
||||
SettingInfo::Enum("Hide Battery %", &CrossPointSettings::hideBatteryPercentage, {"Never", "In Reader", "Always"}),
|
||||
|
||||
@@ -6,9 +6,12 @@
|
||||
#include <SDCardManager.h>
|
||||
#include <SPI.h>
|
||||
#include <builtinFonts/all.h>
|
||||
#include <esp_heap_caps.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <BitmapHelpers.h>
|
||||
|
||||
#include "Battery.h"
|
||||
#include "BookListStore.h"
|
||||
#include "CrossPointSettings.h"
|
||||
@@ -470,6 +473,8 @@ void setup() {
|
||||
}
|
||||
|
||||
SETTINGS.loadFromFile();
|
||||
// Apply high contrast mode from settings
|
||||
setHighContrastMode(SETTINGS.displayContrast == 1);
|
||||
|
||||
if (isWakeupByPowerButton()) {
|
||||
// For normal wakeups, verify power button press duration
|
||||
|
||||
Reference in New Issue
Block a user