fix: restore preferred orientation settings and long-press sub-menu

Re-add DynamicEnum entries for preferredPortrait/preferredLandscape in
Settings with JSON persistence. Restore long-press Confirm on the
reader menu's orientation toggle to open an inline sub-menu with all
4 orientation options.

Made-with: Cursor
This commit is contained in:
cottongin
2026-03-08 06:18:17 -04:00
parent 5ca72ef231
commit 0d8a3fdbdd
4 changed files with 115 additions and 9 deletions

View File

@@ -124,6 +124,10 @@ bool JsonSettingsIO::saveSettings(const CrossPointSettings& s, const char* path)
// Mod: timezone offset is int8_t, not uint8_t — handled separately
doc["timezoneOffsetHours"] = s.timezoneOffsetHours;
// Preferred orientations for portrait/landscape toggle (DynamicEnum, not in generic loop)
doc["preferredPortrait"] = s.preferredPortrait;
doc["preferredLandscape"] = s.preferredLandscape;
String json;
serializeJson(doc, json);
return Storage.writeFile(path, json);
@@ -208,6 +212,14 @@ bool JsonSettingsIO::loadSettings(CrossPointSettings& s, const char* json, bool*
if (s.timezoneOffsetHours < -12) s.timezoneOffsetHours = -12;
if (s.timezoneOffsetHours > 14) s.timezoneOffsetHours = 14;
// Preferred orientations for portrait/landscape toggle (DynamicEnum, not in generic loop)
auto isValidPortrait = [](uint8_t v) { return v == S::PORTRAIT || v == S::INVERTED; };
auto isValidLandscape = [](uint8_t v) { return v == S::LANDSCAPE_CW || v == S::LANDSCAPE_CCW; };
uint8_t pp = doc["preferredPortrait"] | s.preferredPortrait;
s.preferredPortrait = isValidPortrait(pp) ? pp : S::PORTRAIT;
uint8_t pl = doc["preferredLandscape"] | s.preferredLandscape;
s.preferredLandscape = isValidLandscape(pl) ? pl : S::LANDSCAPE_CW;
LOG_DBG("CPS", "Settings loaded from file");
return true;