add settings for reader screen margin

This commit is contained in:
Dave ID 2026-01-03 12:55:46 +01:00
parent 04ad4e5aa4
commit 36abff1b62
4 changed files with 16 additions and 5 deletions

View File

@ -12,7 +12,7 @@ CrossPointSettings CrossPointSettings::instance;
namespace {
constexpr uint8_t SETTINGS_FILE_VERSION = 1;
// Increment this when adding new persisted settings fields
constexpr uint8_t SETTINGS_COUNT = 10;
constexpr uint8_t SETTINGS_COUNT = 11;
constexpr char SETTINGS_FILE[] = "/.crosspoint/settings.bin";
} // namespace
@ -37,6 +37,7 @@ bool CrossPointSettings::saveToFile() const {
serialization::writePod(outputFile, fontFamily);
serialization::writePod(outputFile, fontSize);
serialization::writePod(outputFile, lineSpacing);
serialization::writePod(outputFile, screenMargin);
outputFile.close();
Serial.printf("[%lu] [CPS] Settings saved to file\n", millis());
@ -83,6 +84,8 @@ bool CrossPointSettings::loadFromFile() {
if (++settingsRead >= fileSettingsCount) break;
serialization::readPod(inputFile, lineSpacing);
if (++settingsRead >= fileSettingsCount) break;
serialization::readPod(inputFile, screenMargin);
if (++settingsRead >= fileSettingsCount) break;
} while (false);
inputFile.close();

View File

@ -44,6 +44,10 @@ class CrossPointSettings {
enum FONT_SIZE { SMALL = 0, MEDIUM = 1, LARGE = 2, EXTRA_LARGE = 3 };
enum LINE_COMPRESSION { TIGHT = 0, NORMAL = 1, WIDE = 2 };
// Reader screen margin options
enum SCREEN_MARGIN { S = 5, M = 10, L = 20, XL = 30 };
// Sleep screen settings
uint8_t sleepScreen = DARK;
// Status bar settings
@ -63,6 +67,9 @@ class CrossPointSettings {
uint8_t fontSize = MEDIUM;
uint8_t lineSpacing = NORMAL;
// Reader screen margin settings
uint8_t screenMargin = M;
~CrossPointSettings() = default;
// Get singleton instance

View File

@ -253,9 +253,9 @@ void EpubReaderActivity::renderScreen() {
int orientedMarginTop, orientedMarginRight, orientedMarginBottom, orientedMarginLeft;
renderer.getOrientedViewableTRBL(&orientedMarginTop, &orientedMarginRight, &orientedMarginBottom,
&orientedMarginLeft);
orientedMarginTop += topPadding;
orientedMarginLeft += horizontalPadding;
orientedMarginRight += horizontalPadding;
orientedMarginTop += SETTINGS.screenMargin;
orientedMarginLeft += SETTINGS.screenMargin;
orientedMarginRight += SETTINGS.screenMargin;
orientedMarginBottom += statusBarMargin;
if (!section) {

View File

@ -9,7 +9,7 @@
// Define the static settings list
namespace {
constexpr int settingsCount = 11;
constexpr int settingsCount = 12;
const SettingInfo settingsList[settingsCount] = {
// Should match with SLEEP_SCREEN_MODE
{"Sleep Screen", SettingType::ENUM, &CrossPointSettings::sleepScreen, {"Dark", "Light", "Custom", "Cover"}},
@ -34,6 +34,7 @@ const SettingInfo settingsList[settingsCount] = {
{"Bookerly", "Noto Sans", "Open Dyslexic"}},
{"Reader Font Size", SettingType::ENUM, &CrossPointSettings::fontSize, {"Small", "Medium", "Large", "X Large"}},
{"Reader Line Spacing", SettingType::ENUM, &CrossPointSettings::lineSpacing, {"Tight", "Normal", "Wide"}},
{"Reader Screen Margin", SettingType::ENUM, &CrossPointSettings::screenMargin, {"S", "M", "L", "XL"}},
{"Check for updates", SettingType::ACTION, nullptr, {}},
};
} // namespace