diff options
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/motor/MotorController.cpp | 37 | ||||
-rw-r--r-- | src/components/motor/MotorController.h | 7 | ||||
-rw-r--r-- | src/components/settings/Settings.h | 43 |
3 files changed, 74 insertions, 13 deletions
diff --git a/src/components/motor/MotorController.cpp b/src/components/motor/MotorController.cpp index 3afa0ced..b25e6bc8 100644 --- a/src/components/motor/MotorController.cpp +++ b/src/components/motor/MotorController.cpp @@ -3,7 +3,8 @@ #include "systemtask/SystemTask.h" #include "app_timer.h" -APP_TIMER_DEF(vibTimer); +APP_TIMER_DEF(shortVibTimer); +APP_TIMER_DEF(longVibTimer); using namespace Pinetime::Controllers; @@ -13,19 +14,39 @@ MotorController::MotorController(Controllers::Settings& settingsController) : se void MotorController::Init() { nrf_gpio_cfg_output(pinMotor); nrf_gpio_pin_set(pinMotor); - app_timer_create(&vibTimer, APP_TIMER_MODE_SINGLE_SHOT, vibrate); + app_timer_init(); + + app_timer_create(&shortVibTimer, APP_TIMER_MODE_SINGLE_SHOT, StopMotor); + app_timer_create(&longVibTimer, APP_TIMER_MODE_REPEATED, Ring); } -void MotorController::SetDuration(uint8_t motorDuration) { +void MotorController::Ring(void* p_context) { + auto* motorController = static_cast<MotorController*>(p_context); + motorController->RunForDuration(50); +} - if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF) +void MotorController::RunForDuration(uint8_t motorDuration) { + if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF) { return; + } nrf_gpio_pin_clear(pinMotor); - /* Start timer for motorDuration miliseconds and timer triggers vibrate() when it finishes*/ - app_timer_start(vibTimer, APP_TIMER_TICKS(motorDuration), NULL); + app_timer_start(shortVibTimer, APP_TIMER_TICKS(motorDuration), nullptr); +} + +void MotorController::StartRinging() { + if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF) { + return; + } + Ring(this); + app_timer_start(longVibTimer, APP_TIMER_TICKS(1000), this); } -void MotorController::vibrate(void* p_context) { +void MotorController::StopRinging() { + app_timer_stop(longVibTimer); nrf_gpio_pin_set(pinMotor); -}
\ No newline at end of file +} + +void MotorController::StopMotor(void* p_context) { + nrf_gpio_pin_set(pinMotor); +} diff --git a/src/components/motor/MotorController.h b/src/components/motor/MotorController.h index df61af78..d2c9fe5f 100644 --- a/src/components/motor/MotorController.h +++ b/src/components/motor/MotorController.h @@ -12,11 +12,14 @@ namespace Pinetime { public: MotorController(Controllers::Settings& settingsController); void Init(); - void SetDuration(uint8_t motorDuration); + void RunForDuration(uint8_t motorDuration); + void StartRinging(); + static void StopRinging(); private: + static void Ring(void* p_context); Controllers::Settings& settingsController; - static void vibrate(void* p_context); + static void StopMotor(void* p_context); }; } } diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index 93d6d217..a294ab78 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -17,6 +17,14 @@ namespace Pinetime { DoubleTap = 1, RaiseWrist = 2, }; + enum class Colors : uint8_t { + White, Silver, Gray, Black, Red, Maroon, Yellow, Olive, Lime, Green, Cyan, Teal, Blue, Navy, Magenta, Purple, Orange + }; + struct PineTimeStyle { + Colors ColorTime = Colors::Teal; + Colors ColorBar = Colors::Teal; + Colors ColorBG = Colors::Black; + }; Settings(Pinetime::Controllers::FS& fs); @@ -33,10 +41,38 @@ namespace Pinetime { return settings.clockFace; }; + void SetPTSColorTime(Colors colorTime) { + if (colorTime != settings.PTS.ColorTime) + settingsChanged = true; + settings.PTS.ColorTime = colorTime; + }; + Colors GetPTSColorTime() const { + return settings.PTS.ColorTime; + }; + + void SetPTSColorBar(Colors colorBar) { + if (colorBar != settings.PTS.ColorBar) + settingsChanged = true; + settings.PTS.ColorBar = colorBar; + }; + Colors GetPTSColorBar() const { + return settings.PTS.ColorBar; + }; + + void SetPTSColorBG(Colors colorBG) { + if (colorBG != settings.PTS.ColorBG) + settingsChanged = true; + settings.PTS.ColorBG = colorBG; + }; + Colors GetPTSColorBG() const { + return settings.PTS.ColorBG; + }; + void SetAppMenu(uint8_t menu) { appMenu = menu; }; - uint8_t GetAppMenu() { + + uint8_t GetAppMenu() const { return appMenu; }; @@ -127,9 +163,8 @@ namespace Pinetime { private: Pinetime::Controllers::FS& fs; - static constexpr uint32_t settingsVersion = 0x0001; + static constexpr uint32_t settingsVersion = 0x0002; struct SettingsData { - uint32_t version = settingsVersion; uint32_t stepsGoal = 10000; uint32_t screenTimeOut = 15000; @@ -139,6 +174,8 @@ namespace Pinetime { uint8_t clockFace = 0; + PineTimeStyle PTS; + std::bitset<3> wakeUpMode {0}; Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium; |