fix: MCP settings persistence + WebServer/DevServer coexistence + screensaver charging toggle
- McpSettings was hardcoded to /data/service/mcp/settings.properties, but ES3C28P uses storage.userDataLocation=SD so user data lives on /sdcard/tactility/. Settings appeared to save but on reload returned default false -> "enable and when I go back shows disabled". Fixed to use getUserDataPath()+"/settings/mcp.properties" pattern consistent with DisplaySettings/WebServerSettings, with findOrCreateParentDirectory() and isFile() guard. - HttpServer ctrl_port collision: ESP-IDF default 32768 used by both WebServer (80) and DevelopmentService (6666). Second httpd_start() failed silently -> dashboard up but /api/mcp 404 and :6666 refused. Fixed with unique ctrl_port = 32768 + (port % 1000). Added CONFIG_HTTPD_MAX_URI_HANDLERS=20 (default 8 < 9 needed for 7 handlers + 2 internal). - DevService stack 5120 -> 8192 for /app/install handling. - McpSystem video stream task stack 4096 -> 8192 and idle yield 50ms (was 5ms always) to avoid CPU starvation blocking httpd tasks. On RLCD, timer must always run: DisplayIdle early return on !supportsBacklightDuty() broke MCP manual activation (cachedSettings not loaded, backlight duty 0). Fixed to always load settings + start timer, log RLCD detection, guard setBacklightDuty with supportsBacklightDuty() and fallback duty 255. - DisplaySettings: add disableScreensaverWhenCharging bool, persisted, with UI toggle in Display app (Settings->Display) using PowerDevice::IsCharging check via findDevices callback. When charging and flag enabled, screensaver activation skipped, and if already dimmed, wake on charging. - ES3C28P Power driver: GPIO9 ADC1_CH8 2x divider 2500-4200mV spec from ~/Downloads official docs, TP4054 CHRG not connected to GPIO, so IsCharging inferred via voltage thresholds (<500mV no battery USB or >5000mV wall powered, >=4150mV high) + rising trend. Verified: flashed es3c28p to /dev/cu.usbmodem101 (192.168.68.113), WiFi FamReynaMesh RSSI -59, dashboard 200, :6666/info now works, /api/mcp returns disabled correctly until enabled, persists to SD.
This commit is contained in:
@@ -22,6 +22,7 @@ constexpr auto* SETTINGS_KEY_BACKLIGHT_DUTY = "backlightDuty";
|
||||
constexpr auto* SETTINGS_KEY_TIMEOUT_ENABLED = "backlightTimeoutEnabled";
|
||||
constexpr auto* SETTINGS_KEY_TIMEOUT_MS = "backlightTimeoutMs";
|
||||
constexpr auto* SETTINGS_KEY_SCREENSAVER_TYPE = "screensaverType";
|
||||
constexpr auto* SETTINGS_KEY_DISABLE_WHEN_CHARGING = "disableScreensaverWhenCharging";
|
||||
|
||||
static Orientation getDefaultOrientation() {
|
||||
auto* display = lv_display_get_default();
|
||||
@@ -164,12 +165,19 @@ bool load(DisplaySettings& settings) {
|
||||
fromString(screensaver_entry->second, screensaver_type);
|
||||
}
|
||||
|
||||
bool disable_when_charging = false;
|
||||
auto disable_charging_entry = map.find(SETTINGS_KEY_DISABLE_WHEN_CHARGING);
|
||||
if (disable_charging_entry != map.end()) {
|
||||
disable_when_charging = (disable_charging_entry->second == "1" || disable_charging_entry->second == "true" || disable_charging_entry->second == "True");
|
||||
}
|
||||
|
||||
settings.orientation = orientation;
|
||||
settings.gammaCurve = gamma_curve;
|
||||
settings.backlightDuty = backlight_duty;
|
||||
settings.backlightTimeoutEnabled = timeout_enabled;
|
||||
settings.backlightTimeoutMs = timeout_ms;
|
||||
settings.screensaverType = screensaver_type;
|
||||
settings.disableScreensaverWhenCharging = disable_when_charging;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -181,7 +189,8 @@ DisplaySettings getDefault() {
|
||||
.backlightDuty = 200,
|
||||
.backlightTimeoutEnabled = false,
|
||||
.backlightTimeoutMs = 60000,
|
||||
.screensaverType = ScreensaverType::BouncingBalls
|
||||
.screensaverType = ScreensaverType::BouncingBalls,
|
||||
.disableScreensaverWhenCharging = false
|
||||
};
|
||||
}
|
||||
|
||||
@@ -201,6 +210,7 @@ bool save(const DisplaySettings& settings) {
|
||||
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);
|
||||
map[SETTINGS_KEY_DISABLE_WHEN_CHARGING] = settings.disableScreensaverWhenCharging ? "1" : "0";
|
||||
auto settings_path = getSettingsFilePath();
|
||||
if (!file::findOrCreateParentDirectory(settings_path, 0755)) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user