diff options
Diffstat (limited to 'src/components/settings')
-rw-r--r-- | src/components/settings/Settings.cpp | 4 | ||||
-rw-r--r-- | src/components/settings/Settings.h | 39 |
2 files changed, 37 insertions, 6 deletions
diff --git a/src/components/settings/Settings.cpp b/src/components/settings/Settings.cpp index ef73ad1c..fee62daf 100644 --- a/src/components/settings/Settings.cpp +++ b/src/components/settings/Settings.cpp @@ -26,7 +26,7 @@ void Settings::LoadSettingsFromFile() { SettingsData bufferSettings; lfs_file_t settingsFile; - if ( fs.FileOpen(&settingsFile, "/settings.dat", LFS_O_RDWR | LFS_O_CREAT) != LFS_ERR_OK) { + if ( fs.FileOpen(&settingsFile, "/settings.dat", LFS_O_RDONLY) != LFS_ERR_OK) { return; } fs.FileRead(&settingsFile, reinterpret_cast<uint8_t*>(&bufferSettings), sizeof(settings)); @@ -39,7 +39,7 @@ void Settings::LoadSettingsFromFile() { void Settings::SaveSettingsToFile() { lfs_file_t settingsFile; - if ( fs.FileOpen(&settingsFile, "/settings.dat", LFS_O_RDWR | LFS_O_CREAT) != LFS_ERR_OK) { + if ( fs.FileOpen(&settingsFile, "/settings.dat", LFS_O_WRONLY | LFS_O_CREAT) != LFS_ERR_OK) { return; } fs.FileWrite(&settingsFile, reinterpret_cast<uint8_t*>(&settings), sizeof(settings)); diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index 8d20f067..44a1a85c 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -18,7 +18,23 @@ namespace Pinetime { Shake = 3, }; enum class Colors : uint8_t { - White, Silver, Gray, Black, Red, Maroon, Yellow, Olive, Lime, Green, Cyan, Teal, Blue, Navy, Magenta, Purple, Orange + White, + Silver, + Gray, + Black, + Red, + Maroon, + Yellow, + Olive, + Lime, + Green, + Cyan, + Teal, + Blue, + Navy, + Magenta, + Purple, + Orange }; struct PineTimeStyle { Colors ColorTime = Colors::Teal; @@ -170,18 +186,29 @@ namespace Pinetime { } settings.brightLevel = level; }; + Controllers::BrightnessController::Levels GetBrightness() const { return settings.brightLevel; }; - void SetStepsGoal( uint32_t goal ) { - if ( goal != settings.stepsGoal ) { + void SetStepsGoal(uint32_t goal) { + if (goal != settings.stepsGoal) { settingsChanged = true; } settings.stepsGoal = goal; }; - uint32_t GetStepsGoal() const { return settings.stepsGoal; }; + uint32_t GetStepsGoal() const { + return settings.stepsGoal; + }; + + void SetBleRadioEnabled(bool enabled) { + bleRadioEnabled = enabled; + }; + + bool GetBleRadioEnabled() const { + return bleRadioEnabled; + }; private: Pinetime::Controllers::FS& fs; @@ -210,6 +237,10 @@ namespace Pinetime { uint8_t appMenu = 0; uint8_t settingsMenu = 0; + /* ble state is intentionally not saved with the other watch settings and initialized + * to off (false) on every boot because we always want ble to be enabled on startup + */ + bool bleRadioEnabled = true; void LoadSettingsFromFile(); void SaveSettingsToFile(); |