feat: restore MCP settings and board customizations

This commit is contained in:
Adolfo Reyna
2026-09-10 21:15:10 -04:00
parent c8ee763f3d
commit 61fc67cf4c
26 changed files with 5551 additions and 9 deletions
@@ -20,6 +20,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";
@@ -73,6 +74,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;
@@ -86,6 +115,8 @@ static std::string toString(ScreensaverType type) {
return "MatrixRain";
case StackChan:
return "StackChan";
case McpScreen:
return "McpScreen";
default:
std::unreachable();
}
@@ -107,6 +138,9 @@ static bool fromString(const std::string& str, ScreensaverType& type) {
} else if (str == "StackChan") {
type = ScreensaverType::StackChan;
return true;
} else if (str == "McpScreen") {
type = ScreensaverType::McpScreen;
return true;
} else {
return false;
}
@@ -129,6 +163,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()) {
@@ -163,6 +203,7 @@ bool load(DisplaySettings& settings) {
}
settings.orientation = orientation;
settings.fontSize = font_size;
settings.gammaCurve = gamma_curve;
settings.backlightDuty = backlight_duty;
settings.backlightTimeoutEnabled = timeout_enabled;
@@ -175,6 +216,7 @@ bool load(DisplaySettings& settings) {
DisplaySettings getDefault() {
return DisplaySettings {
.orientation = getDefaultOrientation(),
.fontSize = FontSize::Default,
.gammaCurve = 1,
.backlightDuty = 200,
.backlightTimeoutEnabled = false,
@@ -196,6 +238,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);