2021-02-24 19:40:24 +00:00
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
2021-04-04 02:08:51 +00:00
|
|
|
#include "components/datetime/DateTimeController.h"
|
|
|
|
#include "components/brightness/BrightnessController.h"
|
2021-07-11 13:06:06 +00:00
|
|
|
#include "components/fs/FS.h"
|
2021-04-04 02:08:51 +00:00
|
|
|
#include "drivers/Cst816s.h"
|
2021-02-24 19:40:24 +00:00
|
|
|
|
|
|
|
namespace Pinetime {
|
|
|
|
namespace Controllers {
|
|
|
|
class Settings {
|
2021-04-24 09:00:45 +00:00
|
|
|
public:
|
2021-07-11 13:06:06 +00:00
|
|
|
enum class ClockType : uint8_t { H24, H12 };
|
|
|
|
enum class Vibration : uint8_t { ON, OFF };
|
|
|
|
enum class WakeUpMode : uint8_t { None, SingleTap, DoubleTap, RaiseWrist };
|
2021-04-18 17:28:14 +00:00
|
|
|
|
2021-07-11 13:06:06 +00:00
|
|
|
Settings(Pinetime::Controllers::FS& fs);
|
2021-04-18 17:28:14 +00:00
|
|
|
|
|
|
|
void Init();
|
|
|
|
void SaveSettings();
|
|
|
|
|
|
|
|
void SetClockFace(uint8_t face) {
|
2021-07-11 13:06:06 +00:00
|
|
|
if (face != settings.clockFace) {
|
2021-04-18 17:28:14 +00:00
|
|
|
settingsChanged = true;
|
2021-07-11 13:06:06 +00:00
|
|
|
}
|
2021-04-18 17:28:14 +00:00
|
|
|
settings.clockFace = face;
|
|
|
|
};
|
|
|
|
uint8_t GetClockFace() const {
|
|
|
|
return settings.clockFace;
|
|
|
|
};
|
|
|
|
|
|
|
|
void SetAppMenu(uint8_t menu) {
|
|
|
|
appMenu = menu;
|
|
|
|
};
|
|
|
|
uint8_t GetAppMenu() {
|
|
|
|
return appMenu;
|
|
|
|
};
|
|
|
|
|
|
|
|
void SetSettingsMenu(uint8_t menu) {
|
|
|
|
settingsMenu = menu;
|
|
|
|
};
|
|
|
|
uint8_t GetSettingsMenu() const {
|
|
|
|
return settingsMenu;
|
|
|
|
};
|
|
|
|
|
|
|
|
void SetClockType(ClockType clocktype) {
|
2021-07-11 13:06:06 +00:00
|
|
|
if (clocktype != settings.clockType) {
|
2021-04-18 17:28:14 +00:00
|
|
|
settingsChanged = true;
|
2021-07-11 13:06:06 +00:00
|
|
|
}
|
2021-04-18 17:28:14 +00:00
|
|
|
settings.clockType = clocktype;
|
|
|
|
};
|
|
|
|
ClockType GetClockType() const {
|
|
|
|
return settings.clockType;
|
|
|
|
};
|
|
|
|
|
|
|
|
void SetVibrationStatus(Vibration status) {
|
2021-07-11 13:06:06 +00:00
|
|
|
if (status != settings.vibrationStatus) {
|
2021-04-18 17:28:14 +00:00
|
|
|
settingsChanged = true;
|
2021-07-11 13:06:06 +00:00
|
|
|
}
|
2021-04-18 17:28:14 +00:00
|
|
|
settings.vibrationStatus = status;
|
|
|
|
};
|
|
|
|
Vibration GetVibrationStatus() const {
|
|
|
|
return settings.vibrationStatus;
|
|
|
|
};
|
|
|
|
|
|
|
|
void SetScreenTimeOut(uint32_t timeout) {
|
2021-07-11 13:06:06 +00:00
|
|
|
if (timeout != settings.screenTimeOut) {
|
2021-04-18 17:28:14 +00:00
|
|
|
settingsChanged = true;
|
2021-07-11 13:06:06 +00:00
|
|
|
}
|
2021-04-18 17:28:14 +00:00
|
|
|
settings.screenTimeOut = timeout;
|
|
|
|
};
|
|
|
|
uint32_t GetScreenTimeOut() const {
|
|
|
|
return settings.screenTimeOut;
|
|
|
|
};
|
|
|
|
|
|
|
|
void setWakeUpMode(WakeUpMode wakeUp) {
|
2021-07-11 13:06:06 +00:00
|
|
|
if (wakeUp != settings.wakeUpMode) {
|
2021-04-18 17:28:14 +00:00
|
|
|
settingsChanged = true;
|
2021-07-11 13:06:06 +00:00
|
|
|
}
|
2021-04-18 17:28:14 +00:00
|
|
|
settings.wakeUpMode = wakeUp;
|
|
|
|
};
|
|
|
|
WakeUpMode getWakeUpMode() const {
|
|
|
|
return settings.wakeUpMode;
|
|
|
|
};
|
|
|
|
|
|
|
|
void SetBrightness(Controllers::BrightnessController::Levels level) {
|
2021-07-11 13:06:06 +00:00
|
|
|
if (level != settings.brightLevel) {
|
2021-04-18 17:28:14 +00:00
|
|
|
settingsChanged = true;
|
2021-07-11 13:06:06 +00:00
|
|
|
}
|
2021-04-18 17:28:14 +00:00
|
|
|
settings.brightLevel = level;
|
|
|
|
};
|
|
|
|
Controllers::BrightnessController::Levels GetBrightness() const {
|
|
|
|
return settings.brightLevel;
|
|
|
|
};
|
|
|
|
|
2021-04-26 20:29:48 +00:00
|
|
|
void SetStepsGoal( uint32_t goal ) {
|
2021-07-11 13:06:06 +00:00
|
|
|
if ( goal != settings.stepsGoal ) {
|
2021-04-26 20:29:48 +00:00
|
|
|
settingsChanged = true;
|
2021-07-11 13:06:06 +00:00
|
|
|
}
|
2021-04-26 20:29:48 +00:00
|
|
|
settings.stepsGoal = goal;
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32_t GetStepsGoal() const { return settings.stepsGoal; };
|
|
|
|
|
2021-04-24 09:00:45 +00:00
|
|
|
private:
|
2021-07-11 13:06:06 +00:00
|
|
|
Pinetime::Controllers::FS& fs;
|
|
|
|
|
|
|
|
static constexpr uint32_t settingsVersion = 0x0001;
|
2021-04-18 17:28:14 +00:00
|
|
|
struct SettingsData {
|
|
|
|
|
2021-07-11 13:06:06 +00:00
|
|
|
uint32_t version = settingsVersion;
|
|
|
|
uint32_t stepsGoal = 10000;
|
|
|
|
uint32_t screenTimeOut = 15000;
|
|
|
|
|
2021-04-18 17:28:14 +00:00
|
|
|
ClockType clockType = ClockType::H24;
|
|
|
|
Vibration vibrationStatus = Vibration::ON;
|
|
|
|
|
|
|
|
uint8_t clockFace = 0;
|
|
|
|
|
|
|
|
WakeUpMode wakeUpMode = WakeUpMode::None;
|
|
|
|
|
|
|
|
Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium;
|
|
|
|
};
|
|
|
|
|
|
|
|
SettingsData settings;
|
|
|
|
bool settingsChanged = false;
|
|
|
|
|
|
|
|
uint8_t appMenu = 0;
|
|
|
|
uint8_t settingsMenu = 0;
|
|
|
|
|
2021-07-11 13:06:06 +00:00
|
|
|
void LoadSettingsFromFile();
|
|
|
|
void SaveSettingsToFile();
|
2021-02-24 19:40:24 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|