diff options
| author | Michele Bini <michele.bini@gmail.com> | 2022-04-16 22:18:31 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-04-16 23:38:29 (GMT) |
| commit | 3e5fddede322814c2fea7634c1bf0d5f93bae315 (patch) | |
| tree | 17cf617a024a079c3baa98c590d16d58636236d8 | |
| parent | ef830123ba6144ed253b4cf9fa8ec18c1b19c99a (diff) | |
Make Init methods more uniform among timer and alarm controllers
| -rw-r--r-- | src/components/alarm/AlarmController.cpp | 2 | ||||
| -rw-r--r-- | src/components/alarm/AlarmController.h | 2 | ||||
| -rw-r--r-- | src/components/timer/TimerController.cpp | 7 | ||||
| -rw-r--r-- | src/components/timer/TimerController.h | 6 | ||||
| -rw-r--r-- | src/systemtask/SystemTask.cpp | 3 |
5 files changed, 8 insertions, 12 deletions
diff --git a/src/components/alarm/AlarmController.cpp b/src/components/alarm/AlarmController.cpp index ca288cf..4d20c51 100644 --- a/src/components/alarm/AlarmController.cpp +++ b/src/components/alarm/AlarmController.cpp @@ -35,8 +35,8 @@ namespace { } void AlarmController::Init(System::SystemTask* systemTask) { - alarmAppTimer = xTimerCreate("alarmAppTm", 1, pdFALSE, this, SetOffAlarm); this->systemTask = systemTask; + alarmAppTimer = xTimerCreate("alarmAppTm", 1, pdFALSE, this, SetOffAlarm); } void AlarmController::SetAlarmTime(uint8_t alarmHr, uint8_t alarmMin) { diff --git a/src/components/alarm/AlarmController.h b/src/components/alarm/AlarmController.h index f4bfdd3..6ad220f 100644 --- a/src/components/alarm/AlarmController.h +++ b/src/components/alarm/AlarmController.h @@ -31,7 +31,6 @@ namespace Pinetime { public: AlarmController(Controllers::DateTime& dateTimeController); - void Init(System::SystemTask* systemTask); void SetAlarmTime(uint8_t alarmHr, uint8_t alarmMin); void ScheduleAlarm(); void OnAdjustTime(); @@ -59,6 +58,7 @@ namespace Pinetime { protected: friend class Pinetime::System::SystemTask; + void Init(System::SystemTask* systemTask); void OnStopRinging(); private: diff --git a/src/components/timer/TimerController.cpp b/src/components/timer/TimerController.cpp index 35e3512..fa00d3c 100644 --- a/src/components/timer/TimerController.cpp +++ b/src/components/timer/TimerController.cpp @@ -15,7 +15,8 @@ namespace { } } -void TimerController::Init() { +void Init(System::SystemTask* systemTask) { + this->systemTask = systemTask; timerAppTimer = xTimerCreate("timerAppTm", 1, pdFALSE, this, TimerEnd); } @@ -59,7 +60,3 @@ void TimerController::OnTimerEnd() { systemTask->PushMessage(System::Messages::OnTimerDone); } } - -void TimerController::Register(Pinetime::System::SystemTask* systemTask) { - this->systemTask = systemTask; -} diff --git a/src/components/timer/TimerController.h b/src/components/timer/TimerController.h index 8542987..cdd78ec 100644 --- a/src/components/timer/TimerController.h +++ b/src/components/timer/TimerController.h @@ -16,7 +16,6 @@ namespace Pinetime { public: TimerController() = default; - void Init(); void StartTimer(uint32_t duration); void StopTimer(); void StopAlerting(); @@ -29,8 +28,9 @@ namespace Pinetime { } void OnTimerEnd(); - - void Register(System::SystemTask* systemTask); + protected: + friend class Pinetime::System::SystemTask; + void Init(System::SystemTask* systemTask); private: System::SystemTask* systemTask = nullptr; diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 1fdb597..5a0a99d 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -157,8 +157,7 @@ void SystemTask::Work() { batteryController.Register(this); motorController.Init(); motionSensor.SoftReset(); - timerController.Register(this); - timerController.Init(); + timerController.Init(this); alarmController.Init(this); // Reset the TWI device because the motion sensor chip most probably crashed it... |
