Integrate upstream #1392 by adriancaruana

This commit is contained in:
jpirnay
2026-04-28 10:00:22 +02:00
parent ac96d89f83
commit aa9fae16d9
29 changed files with 3083 additions and 77 deletions
+15
View File
@@ -189,6 +189,13 @@ bool JsonSettingsIO::saveSettings(const CrossPointSettings& s, const char* path)
doc["frontButtonLeft"] = s.frontButtonLeft;
doc["frontButtonRight"] = s.frontButtonRight;
// Font family uses a DynamicEnumCtx in SettingsList (no valuePtr) so the generic
// loop above skips it. Save manually.
doc["fontFamily"] = s.fontFamily;
if (s.sdFontFamilyName[0] != '\0') {
doc["sdFontFamilyName"] = s.sdFontFamilyName;
}
String json;
serializeJson(doc, json);
return Storage.writeFile(path, json);
@@ -268,6 +275,14 @@ bool JsonSettingsIO::loadSettings(CrossPointSettings& s, const char* json, bool*
clamp(doc["frontButtonRight"] | (uint8_t)S::FRONT_HW_RIGHT, S::FRONT_BUTTON_HARDWARE_COUNT, S::FRONT_HW_RIGHT);
CrossPointSettings::validateFrontButtonMapping(s);
// Font family uses a DynamicEnumCtx in SettingsList (no valuePtr) so the generic
// loop above skips it. Load manually.
s.fontFamily = clamp(doc["fontFamily"] | (uint8_t)CrossPointSettings::BOOKERLY,
CrossPointSettings::BUILTIN_FONT_COUNT, CrossPointSettings::BOOKERLY);
const char* sfn = doc["sdFontFamilyName"] | "";
strncpy(s.sdFontFamilyName, sfn, sizeof(s.sdFontFamilyName) - 1);
s.sdFontFamilyName[sizeof(s.sdFontFamilyName) - 1] = '\0';
LOG_DBG("CPS", "Settings loaded from file");
return true;