Files
tactility/Tactility/Source/settings/McpSettings.cpp
T
Adolfo Reyna cd921e1aa9 feat: implement MCP drawing as screensaver instead of standalone app
- Add ScreensaverType::McpScreen to DisplaySettings enum, toString/fromString
- Add 'MCP Screen' option to the Display settings screensaver dropdown
- New McpScreensaver (Screensaver subclass): creates full-screen lv_canvas on
  the overlay, allocates framebuffer in SPIRAM, registers canvas pointer in
  McpSystemState, shows 'Waiting for LLM...' until first draw command arrives
- Wire McpScreensaver into DisplayIdle::activateScreensaver() switch
- McpSystem::ensureOverrideScreen() now calls displayidle::findService()->
  startScreensaver() instead of launching McpOverrideApp — canvas appears
  automatically on any LLM draw command
- Remove McpOverrideApp (replaced by screensaver), deregister from Tactility.cpp
- Remove mcpOverrideEnabled from McpSettings — no longer needed
- Simplify McpSettingsApp: remove Screen Override toggle, update info text to
  direct users to Settings -> Display -> Screensaver -> MCP Screen
2026-06-27 09:17:50 -04:00

59 lines
1.5 KiB
C++

#include <Tactility/settings/McpSettings.h>
#include <Tactility/file/PropertiesFile.h>
#include <Tactility/file/File.h>
#include <Tactility/Logger.h>
#include <map>
#include <string>
namespace tt::settings::mcp {
static const auto LOGGER = Logger("McpSettings");
constexpr auto* SETTINGS_FILE = "/data/service/mcp/settings.properties";
constexpr auto* KEY_MCP_ENABLED = "mcpEnabled";
bool load(McpSettings& settings) {
std::map<std::string, std::string> map;
if (!file::loadPropertiesFile(SETTINGS_FILE, map)) {
return false;
}
auto mcp_enabled = map.find(KEY_MCP_ENABLED);
settings.mcpEnabled = (mcp_enabled != map.end())
? (mcp_enabled->second == "1" || mcp_enabled->second == "true")
: false;
return true;
}
McpSettings getDefault() {
return McpSettings{
.mcpEnabled = false
};
}
McpSettings loadOrGetDefault() {
McpSettings settings;
if (!load(settings)) {
settings = getDefault();
file::findOrCreateDirectory("/data/service/mcp", 0755);
save(settings);
}
return settings;
}
bool save(const McpSettings& settings) {
file::findOrCreateDirectory("/data/service/mcp", 0755);
std::map<std::string, std::string> map;
map[KEY_MCP_ENABLED] = settings.mcpEnabled ? "true" : "false";
if (!file::savePropertiesFile(SETTINGS_FILE, map)) {
LOGGER.error("Failed to save MCP settings to {}", SETTINGS_FILE);
return false;
}
return true;
}
} // namespace