aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/timer
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/timer')
-rw-r--r--src/components/timer/TimerController.cpp15
-rw-r--r--src/components/timer/TimerController.h12
2 files changed, 3 insertions, 24 deletions
diff --git a/src/components/timer/TimerController.cpp b/src/components/timer/TimerController.cpp
index 5e7f1eed..e3aa07af 100644
--- a/src/components/timer/TimerController.cpp
+++ b/src/components/timer/TimerController.cpp
@@ -1,16 +1,9 @@
#include "components/timer/TimerController.h"
-#include "systemtask/SystemTask.h"
using namespace Pinetime::Controllers;
-void TimerCallback(TimerHandle_t xTimer) {
- auto* controller = static_cast<TimerController*>(pvTimerGetTimerID(xTimer));
- controller->OnTimerEnd();
-}
-
-void TimerController::Init(Pinetime::System::SystemTask* systemTask) {
- this->systemTask = systemTask;
- timer = xTimerCreate("Timer", 1, pdFALSE, this, TimerCallback);
+TimerController::TimerController(void* const timerData, TimerCallbackFunction_t timerCallbackFunction) {
+ timer = xTimerCreate("Timer", 1, pdFALSE, timerData, timerCallbackFunction);
}
void TimerController::StartTimer(std::chrono::milliseconds duration) {
@@ -33,7 +26,3 @@ void TimerController::StopTimer() {
bool TimerController::IsRunning() {
return (xTimerIsTimerActive(timer) == pdTRUE);
}
-
-void TimerController::OnTimerEnd() {
- systemTask->PushMessage(System::Messages::OnTimerDone);
-}
diff --git a/src/components/timer/TimerController.h b/src/components/timer/TimerController.h
index 1c2e44b6..1d2a51df 100644
--- a/src/components/timer/TimerController.h
+++ b/src/components/timer/TimerController.h
@@ -6,17 +6,10 @@
#include <chrono>
namespace Pinetime {
- namespace System {
- class SystemTask;
- }
-
namespace Controllers {
-
class TimerController {
public:
- TimerController() = default;
-
- void Init(System::SystemTask* systemTask);
+ TimerController(void* timerData, TimerCallbackFunction_t timerCallbackFunction);
void StartTimer(std::chrono::milliseconds duration);
@@ -26,10 +19,7 @@ namespace Pinetime {
bool IsRunning();
- void OnTimerEnd();
-
private:
- System::SystemTask* systemTask = nullptr;
TimerHandle_t timer;
};
}