TimerController: Make TimerController reusable
TimerController instance was moved to DisplayApp.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
@@ -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;
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user