Require SD card or >4MB flash (#545)
This commit is contained in:
committed by
GitHub
parent
90afba647e
commit
05720821f8
@@ -7,7 +7,6 @@
|
||||
#include <Tactility/Paths.h>
|
||||
#include <format>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace tt::settings {
|
||||
|
||||
@@ -18,14 +17,7 @@ constexpr auto* PROPERTIES_KEY_LAUNCHER_APP_ID = "launcherAppId";
|
||||
constexpr auto* PROPERTIES_KEY_AUTO_START_APP_ID = "autoStartAppId";
|
||||
|
||||
static std::string getPropertiesFilePath() {
|
||||
std::string sdcard_path;
|
||||
if (findFirstMountedSdCardPath(sdcard_path)) {
|
||||
std::string path = std::format(PROPERTIES_FILE_FORMAT, sdcard_path);
|
||||
if (file::isFile(path)) {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
return std::format(PROPERTIES_FILE_FORMAT, file::MOUNT_POINT_DATA);
|
||||
return std::format(PROPERTIES_FILE_FORMAT, getUserDataPath());
|
||||
}
|
||||
|
||||
bool loadBootSettings(BootSettings& properties) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <Tactility/settings/DisplaySettings.h>
|
||||
|
||||
#include <Tactility/file/PropertiesFile.h>
|
||||
#include <Tactility/Paths.h>
|
||||
#include <tactility/hal/Device.h>
|
||||
#include <Tactility/hal/display/DisplayDevice.h>
|
||||
|
||||
@@ -10,7 +11,10 @@
|
||||
|
||||
namespace tt::settings::display {
|
||||
|
||||
constexpr auto* SETTINGS_FILE = "/data/settings/display.properties";
|
||||
static std::string getSettingsFilePath() {
|
||||
return getUserDataPath() + "/settings/display.properties";
|
||||
}
|
||||
|
||||
constexpr auto* SETTINGS_KEY_ORIENTATION = "orientation";
|
||||
constexpr auto* SETTINGS_KEY_GAMMA_CURVE = "gammaCurve";
|
||||
constexpr auto* SETTINGS_KEY_BACKLIGHT_DUTY = "backlightDuty";
|
||||
@@ -106,7 +110,7 @@ static bool fromString(const std::string& str, ScreensaverType& type) {
|
||||
|
||||
bool load(DisplaySettings& settings) {
|
||||
std::map<std::string, std::string> map;
|
||||
if (!file::loadPropertiesFile(SETTINGS_FILE, map)) {
|
||||
if (!file::loadPropertiesFile(getSettingsFilePath(), map)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -186,7 +190,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);
|
||||
return file::savePropertiesFile(SETTINGS_FILE, map);
|
||||
return file::savePropertiesFile(getSettingsFilePath(), map);
|
||||
}
|
||||
|
||||
lv_display_rotation_t toLvglDisplayRotation(Orientation orientation) {
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
#include <Tactility/settings/KeyboardSettings.h>
|
||||
#include <Tactility/file/PropertiesFile.h>
|
||||
#include <Tactility/Paths.h>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace tt::settings::keyboard {
|
||||
|
||||
constexpr auto* SETTINGS_FILE = "/data/settings/keyboard.properties";
|
||||
static std::string getSettingsFilePath() {
|
||||
return getUserDataPath() + "/settings/keyboard.properties";
|
||||
}
|
||||
|
||||
constexpr auto* KEY_BACKLIGHT_ENABLED = "backlightEnabled";
|
||||
constexpr auto* KEY_BACKLIGHT_BRIGHTNESS = "backlightBrightness";
|
||||
constexpr auto* KEY_BACKLIGHT_TIMEOUT_ENABLED = "backlightTimeoutEnabled";
|
||||
@@ -14,7 +18,7 @@ constexpr auto* KEY_BACKLIGHT_TIMEOUT_MS = "backlightTimeoutMs";
|
||||
|
||||
bool load(KeyboardSettings& settings) {
|
||||
std::map<std::string, std::string> map;
|
||||
if (!file::loadPropertiesFile(SETTINGS_FILE, map)) {
|
||||
if (!file::loadPropertiesFile(getSettingsFilePath(), map)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -54,7 +58,7 @@ bool save(const KeyboardSettings& settings) {
|
||||
map[KEY_BACKLIGHT_BRIGHTNESS] = std::to_string(settings.backlightBrightness);
|
||||
map[KEY_BACKLIGHT_TIMEOUT_ENABLED] = settings.backlightTimeoutEnabled ? "1" : "0";
|
||||
map[KEY_BACKLIGHT_TIMEOUT_MS] = std::to_string(settings.backlightTimeoutMs);
|
||||
return file::savePropertiesFile(SETTINGS_FILE, map);
|
||||
return file::savePropertiesFile(getSettingsFilePath(), map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/MountPoints.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/file/FileLock.h>
|
||||
#include <Tactility/file/PropertiesFile.h>
|
||||
#include <Tactility/settings/Language.h>
|
||||
#include <Tactility/settings/SystemSettings.h>
|
||||
|
||||
#include "Tactility/Paths.h"
|
||||
|
||||
#include <format>
|
||||
|
||||
namespace tt::settings {
|
||||
@@ -17,12 +19,16 @@ constexpr auto* FILE_PATH_FORMAT = "{}/settings/system.properties";
|
||||
static bool cached = false;
|
||||
static SystemSettings cachedSettings;
|
||||
|
||||
static bool hasSystemSettingsFile() {
|
||||
auto file_path = std::format(FILE_PATH_FORMAT, getUserDataPath());
|
||||
return file::isFile(file_path);
|
||||
}
|
||||
|
||||
static bool loadSystemSettingsFromFile(SystemSettings& properties) {
|
||||
auto file_path = std::format(FILE_PATH_FORMAT, file::MOUNT_POINT_DATA);
|
||||
auto file_path = std::format(FILE_PATH_FORMAT, getUserDataPath());
|
||||
LOGGER.info("System settings loading from {}", file_path);
|
||||
std::map<std::string, std::string> map;
|
||||
if (!file::loadPropertiesFile(file_path, map)) {
|
||||
LOGGER.error("Failed to load {}", file_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -55,11 +61,12 @@ static bool loadSystemSettingsFromFile(SystemSettings& properties) {
|
||||
}
|
||||
|
||||
bool loadSystemSettings(SystemSettings& properties) {
|
||||
if (!cached) {
|
||||
if (!loadSystemSettingsFromFile(cachedSettings)) {
|
||||
return false;
|
||||
if (!cached && hasSystemSettingsFile()) {
|
||||
if (loadSystemSettingsFromFile(cachedSettings)) {
|
||||
cached = true;
|
||||
} else {
|
||||
LOGGER.error("Failed to load");
|
||||
}
|
||||
cached = true;
|
||||
}
|
||||
|
||||
properties = cachedSettings;
|
||||
@@ -67,7 +74,7 @@ bool loadSystemSettings(SystemSettings& properties) {
|
||||
}
|
||||
|
||||
bool saveSystemSettings(const SystemSettings& properties) {
|
||||
auto file_path = std::format(FILE_PATH_FORMAT, file::MOUNT_POINT_DATA);
|
||||
auto file_path = std::format(FILE_PATH_FORMAT, getUserDataPath());
|
||||
std::map<std::string, std::string> map;
|
||||
map["language"] = toString(properties.language);
|
||||
map["timeFormat24h"] = properties.timeFormat24h ? "true" : "false";
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <Tactility/file/PropertiesFile.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/Paths.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
@@ -12,7 +13,10 @@
|
||||
|
||||
namespace tt::settings::touch {
|
||||
|
||||
constexpr auto* SETTINGS_FILE = "/data/settings/touch-calibration.properties";
|
||||
static std::string getSettingsFilePath() {
|
||||
return getUserDataPath() + "/settings/touch-calibration.properties";
|
||||
}
|
||||
|
||||
constexpr auto* SETTINGS_KEY_ENABLED = "enabled";
|
||||
constexpr auto* SETTINGS_KEY_X_MIN = "xMin";
|
||||
constexpr auto* SETTINGS_KEY_X_MAX = "xMax";
|
||||
@@ -61,7 +65,7 @@ bool isValid(const TouchCalibrationSettings& settings) {
|
||||
|
||||
bool load(TouchCalibrationSettings& settings) {
|
||||
std::map<std::string, std::string> map;
|
||||
if (!file::loadPropertiesFile(SETTINGS_FILE, map)) {
|
||||
if (!file::loadPropertiesFile(getSettingsFilePath(), map)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -112,7 +116,7 @@ bool save(const TouchCalibrationSettings& settings) {
|
||||
map[SETTINGS_KEY_Y_MIN] = std::to_string(settings.yMin);
|
||||
map[SETTINGS_KEY_Y_MAX] = std::to_string(settings.yMax);
|
||||
|
||||
if (!file::savePropertiesFile(SETTINGS_FILE, map)) {
|
||||
if (!file::savePropertiesFile(getSettingsFilePath(), map)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <Tactility/settings/TrackballSettings.h>
|
||||
#include <Tactility/file/PropertiesFile.h>
|
||||
#include <Tactility/Paths.h>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
@@ -7,7 +8,10 @@
|
||||
|
||||
namespace tt::settings::trackball {
|
||||
|
||||
constexpr auto* SETTINGS_FILE = "/data/settings/trackball.properties";
|
||||
static std::string getSettingsFilePath() {
|
||||
return getUserDataPath() + "/settings/trackball.properties";
|
||||
}
|
||||
|
||||
constexpr auto* KEY_TRACKBALL_ENABLED = "trackballEnabled";
|
||||
constexpr auto* KEY_TRACKBALL_MODE = "trackballMode";
|
||||
constexpr auto* KEY_ENCODER_SENSITIVITY = "encoderSensitivity";
|
||||
@@ -20,7 +24,7 @@ constexpr uint8_t MAX_POINTER_SENSITIVITY = 10;
|
||||
|
||||
bool load(TrackballSettings& settings) {
|
||||
std::map<std::string, std::string> map;
|
||||
if (!file::loadPropertiesFile(SETTINGS_FILE, map)) {
|
||||
if (!file::loadPropertiesFile(getSettingsFilePath(), map)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -80,7 +84,7 @@ bool save(const TrackballSettings& settings) {
|
||||
map[KEY_TRACKBALL_MODE] = (settings.trackballMode == TrackballMode::Pointer) ? "1" : "0";
|
||||
map[KEY_ENCODER_SENSITIVITY] = std::to_string(std::clamp(settings.encoderSensitivity, MIN_ENCODER_SENSITIVITY, MAX_ENCODER_SENSITIVITY));
|
||||
map[KEY_POINTER_SENSITIVITY] = std::to_string(std::clamp(settings.pointerSensitivity, MIN_POINTER_SENSITIVITY, MAX_POINTER_SENSITIVITY));
|
||||
return file::savePropertiesFile(SETTINGS_FILE, map);
|
||||
return file::savePropertiesFile(getSettingsFilePath(), map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <Tactility/file/PropertiesFile.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/Paths.h>
|
||||
|
||||
#include <charconv>
|
||||
#include <map>
|
||||
@@ -17,8 +18,11 @@
|
||||
|
||||
namespace tt::settings::webserver {
|
||||
|
||||
static const auto LOGGER = tt::Logger("WebServerSettings");
|
||||
constexpr auto* SETTINGS_FILE = "/data/service/webserver/settings.properties";
|
||||
static const auto LOGGER = Logger("WebServerSettings");
|
||||
|
||||
static std::string getSettingsFilePath() {
|
||||
return getUserDataPath() + "/settings/webserver.properties";
|
||||
}
|
||||
|
||||
// Property keys
|
||||
constexpr auto* KEY_WIFI_ENABLED = "wifiEnabled";
|
||||
@@ -87,7 +91,7 @@ static bool isEmptyCredential(const std::string& value) {
|
||||
|
||||
bool load(WebServerSettings& settings) {
|
||||
std::map<std::string, std::string> map;
|
||||
if (!file::loadPropertiesFile(SETTINGS_FILE, map)) {
|
||||
if (!file::loadPropertiesFile(getSettingsFilePath(), map)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -146,7 +150,7 @@ bool load(WebServerSettings& settings) {
|
||||
|
||||
// Persist the generated password immediately
|
||||
map[KEY_AP_PASSWORD] = settings.apPassword;
|
||||
if (file::savePropertiesFile(SETTINGS_FILE, map)) {
|
||||
if (file::savePropertiesFile(getSettingsFilePath(), map)) {
|
||||
LOGGER.info("Generated and saved new secure AP password");
|
||||
} else {
|
||||
LOGGER.error("Failed to save generated AP password");
|
||||
@@ -187,7 +191,7 @@ bool load(WebServerSettings& settings) {
|
||||
// We need to save these to the file so they're consistent across reboots
|
||||
map[KEY_WEBSERVER_USERNAME] = settings.webServerUsername;
|
||||
map[KEY_WEBSERVER_PASSWORD] = settings.webServerPassword;
|
||||
if (file::savePropertiesFile(SETTINGS_FILE, map)) {
|
||||
if (file::savePropertiesFile(getSettingsFilePath(), map)) {
|
||||
LOGGER.info("Generated and saved new secure credentials");
|
||||
} else {
|
||||
LOGGER.error("Failed to save generated credentials - auth may be inconsistent across reboots");
|
||||
@@ -253,8 +257,7 @@ bool save(const WebServerSettings& settings) {
|
||||
map[KEY_WEBSERVER_USERNAME] = settings.webServerUsername;
|
||||
map[KEY_WEBSERVER_PASSWORD] = settings.webServerPassword;
|
||||
|
||||
// Save to flash storage only (no SD backup - settings sync at boot handles restore)
|
||||
return file::savePropertiesFile(SETTINGS_FILE, map);
|
||||
return file::savePropertiesFile(getSettingsFilePath(), map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user