Merge remote-tracking branch 'origin/main' into main
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include <Tactility/settings/DisplaySettings.h>
|
||||
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/file/PropertiesFile.h>
|
||||
#include <Tactility/Paths.h>
|
||||
#include <tactility/hal/Device.h>
|
||||
#include <Tactility/hal/display/DisplayDevice.h>
|
||||
|
||||
@@ -10,7 +12,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";
|
||||
@@ -110,8 +115,13 @@ static bool fromString(const std::string& str, ScreensaverType& type) {
|
||||
}
|
||||
|
||||
bool load(DisplaySettings& settings) {
|
||||
auto settings_path = getSettingsFilePath();
|
||||
if (!file::isFile(settings_path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> map;
|
||||
if (!file::loadPropertiesFile(SETTINGS_FILE, map)) {
|
||||
if (!file::loadPropertiesFile(settings_path, map)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -191,7 +201,11 @@ 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);
|
||||
auto settings_path = getSettingsFilePath();
|
||||
if (!file::findOrCreateParentDirectory(settings_path, 0755)) {
|
||||
return false;
|
||||
}
|
||||
return file::savePropertiesFile(settings_path, map);
|
||||
}
|
||||
|
||||
lv_display_rotation_t toLvglDisplayRotation(Orientation orientation) {
|
||||
|
||||
Reference in New Issue
Block a user