Add firmware font size setting

This commit is contained in:
Adolfo Reyna
2026-07-24 21:28:24 -04:00
parent 56bbd6a90e
commit d8c5a55fe8
9 changed files with 200 additions and 3 deletions
@@ -17,6 +17,7 @@ static std::string getSettingsFilePath() {
}
constexpr auto* SETTINGS_KEY_ORIENTATION = "orientation";
constexpr auto* SETTINGS_KEY_FONT_SIZE = "fontSize";
constexpr auto* SETTINGS_KEY_GAMMA_CURVE = "gammaCurve";
constexpr auto* SETTINGS_KEY_BACKLIGHT_DUTY = "backlightDuty";
constexpr auto* SETTINGS_KEY_TIMEOUT_ENABLED = "backlightTimeoutEnabled";
@@ -71,6 +72,34 @@ static bool fromString(const std::string& str, Orientation& orientation) {
}
}
static std::string toString(FontSize font_size) {
switch (font_size) {
using enum FontSize;
case Small:
return "Small";
case Default:
return "Default";
case Large:
return "Large";
default:
std::unreachable();
}
}
static bool fromString(const std::string& str, FontSize& font_size) {
if (str == "Small") {
font_size = FontSize::Small;
return true;
} else if (str == "Default") {
font_size = FontSize::Default;
return true;
} else if (str == "Large") {
font_size = FontSize::Large;
return true;
}
return false;
}
static std::string toString(ScreensaverType type) {
switch (type) {
using enum ScreensaverType;
@@ -132,6 +161,12 @@ bool load(DisplaySettings& settings) {
orientation = getDefaultOrientation();
}
auto font_size_entry = map.find(SETTINGS_KEY_FONT_SIZE);
FontSize font_size = FontSize::Default;
if (font_size_entry != map.end()) {
fromString(font_size_entry->second, font_size);
}
auto gamma_entry = map.find(SETTINGS_KEY_GAMMA_CURVE);
int gamma_curve = 0;
if (gamma_entry != map.end()) {
@@ -172,6 +207,7 @@ bool load(DisplaySettings& settings) {
}
settings.orientation = orientation;
settings.fontSize = font_size;
settings.gammaCurve = gamma_curve;
settings.backlightDuty = backlight_duty;
settings.backlightTimeoutEnabled = timeout_enabled;
@@ -185,6 +221,7 @@ bool load(DisplaySettings& settings) {
DisplaySettings getDefault() {
return DisplaySettings {
.orientation = getDefaultOrientation(),
.fontSize = FontSize::Default,
.gammaCurve = 1,
.backlightDuty = 200,
.backlightTimeoutEnabled = false,
@@ -207,6 +244,7 @@ bool save(const DisplaySettings& settings) {
map[SETTINGS_KEY_BACKLIGHT_DUTY] = std::to_string(settings.backlightDuty);
map[SETTINGS_KEY_GAMMA_CURVE] = std::to_string(settings.gammaCurve);
map[SETTINGS_KEY_ORIENTATION] = toString(settings.orientation);
map[SETTINGS_KEY_FONT_SIZE] = toString(settings.fontSize);
map[SETTINGS_KEY_TIMEOUT_ENABLED] = settings.backlightTimeoutEnabled ? "1" : "0";
map[SETTINGS_KEY_TIMEOUT_MS] = std::to_string(settings.backlightTimeoutMs);
map[SETTINGS_KEY_SCREENSAVER_TYPE] = toString(settings.screensaverType);