summaryrefslogtreecommitdiff
path: root/src/components/settings/Settings.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/settings/Settings.h')
-rw-r--r--src/components/settings/Settings.h58
1 files changed, 28 insertions, 30 deletions
diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h
index 69e28e5b..28cfe775 100644
--- a/src/components/settings/Settings.h
+++ b/src/components/settings/Settings.h
@@ -2,25 +2,26 @@
#include <cstdint>
#include "components/datetime/DateTimeController.h"
#include "components/brightness/BrightnessController.h"
-#include "drivers/SpiNorFlash.h"
+#include "components/fs/FS.h"
#include "drivers/Cst816s.h"
namespace Pinetime {
namespace Controllers {
class Settings {
public:
- enum class ClockType { H24, H12 };
- enum class Vibration { ON, OFF };
- enum class WakeUpMode { None, SingleTap, DoubleTap, RaiseWrist };
+ enum class ClockType : uint8_t { H24, H12 };
+ enum class Vibration : uint8_t { ON, OFF };
+ enum class WakeUpMode : uint8_t { None, SingleTap, DoubleTap, RaiseWrist };
- Settings(Pinetime::Drivers::SpiNorFlash& spiNorFlash);
+ Settings(Pinetime::Controllers::FS& fs);
void Init();
void SaveSettings();
void SetClockFace(uint8_t face) {
- if (face != settings.clockFace)
+ if (face != settings.clockFace) {
settingsChanged = true;
+ }
settings.clockFace = face;
};
uint8_t GetClockFace() const {
@@ -69,8 +70,9 @@ namespace Pinetime {
};
void SetClockType(ClockType clocktype) {
- if (clocktype != settings.clockType)
+ if (clocktype != settings.clockType) {
settingsChanged = true;
+ }
settings.clockType = clocktype;
};
ClockType GetClockType() const {
@@ -78,8 +80,9 @@ namespace Pinetime {
};
void SetVibrationStatus(Vibration status) {
- if (status != settings.vibrationStatus)
+ if (status != settings.vibrationStatus) {
settingsChanged = true;
+ }
settings.vibrationStatus = status;
};
Vibration GetVibrationStatus() const {
@@ -87,8 +90,9 @@ namespace Pinetime {
};
void SetScreenTimeOut(uint32_t timeout) {
- if (timeout != settings.screenTimeOut)
+ if (timeout != settings.screenTimeOut) {
settingsChanged = true;
+ }
settings.screenTimeOut = timeout;
};
uint32_t GetScreenTimeOut() const {
@@ -96,8 +100,9 @@ namespace Pinetime {
};
void setWakeUpMode(WakeUpMode wakeUp) {
- if (wakeUp != settings.wakeUpMode)
+ if (wakeUp != settings.wakeUpMode) {
settingsChanged = true;
+ }
settings.wakeUpMode = wakeUp;
};
WakeUpMode getWakeUpMode() const {
@@ -105,8 +110,9 @@ namespace Pinetime {
};
void SetBrightness(Controllers::BrightnessController::Levels level) {
- if (level != settings.brightLevel)
+ if (level != settings.brightLevel) {
settingsChanged = true;
+ }
settings.brightLevel = level;
};
Controllers::BrightnessController::Levels GetBrightness() const {
@@ -114,17 +120,24 @@ namespace Pinetime {
};
void SetStepsGoal( uint32_t goal ) {
- if ( goal != settings.stepsGoal )
+ if ( goal != settings.stepsGoal ) {
settingsChanged = true;
+ }
settings.stepsGoal = goal;
};
uint32_t GetStepsGoal() const { return settings.stepsGoal; };
private:
- Pinetime::Drivers::SpiNorFlash& spiNorFlash;
+ Pinetime::Controllers::FS& fs;
+
+ static constexpr uint32_t settingsVersion = 0x0001;
struct SettingsData {
+ uint32_t version = settingsVersion;
+ uint32_t stepsGoal = 10000;
+ uint32_t screenTimeOut = 15000;
+
ClockType clockType = ClockType::H24;
Vibration vibrationStatus = Vibration::ON;
@@ -134,9 +147,6 @@ namespace Pinetime {
uint8_t PTSColorBar = 11;
uint8_t PTSColorBG = 3;
- uint32_t stepsGoal = 10000;
- uint32_t screenTimeOut = 15000;
-
WakeUpMode wakeUpMode = WakeUpMode::None;
Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium;
@@ -148,20 +158,8 @@ namespace Pinetime {
uint8_t appMenu = 0;
uint8_t settingsMenu = 0;
- // There are 10 blocks of reserved flash to save settings
- // to minimize wear, the recording is done in a rotating way by the 10 blocks
- uint8_t settingsFlashBlock = 99; // default to indicate it needs to find the active block
-
- static constexpr uint32_t settingsBaseAddr = 0x3F6000; // Flash Settings Location
- static constexpr uint16_t settingsVersion = 0x0100; // Flash Settings Version
-
- bool FindHeader();
- void ReadSettingsData();
- void EraseBlock();
- void SetHeader(bool state);
- void SaveSettingsData();
- void LoadSettingsFromFlash();
- void SaveSettingsToFlash();
+ void LoadSettingsFromFile();
+ void SaveSettingsToFile();
};
}
} \ No newline at end of file