From 40f7e1c7be6882e01058b5ccf64d5005c6105346 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Tue, 11 Apr 2023 12:18:49 +0300 Subject: TimerController: Rename to Timer --- src/components/timer/Timer.cpp | 28 ++++++++++++++++++++++++++++ src/components/timer/Timer.h | 26 ++++++++++++++++++++++++++ src/components/timer/TimerController.cpp | 28 ---------------------------- src/components/timer/TimerController.h | 26 -------------------------- 4 files changed, 54 insertions(+), 54 deletions(-) create mode 100644 src/components/timer/Timer.cpp create mode 100644 src/components/timer/Timer.h delete mode 100644 src/components/timer/TimerController.cpp delete mode 100644 src/components/timer/TimerController.h (limited to 'src/components/timer') diff --git a/src/components/timer/Timer.cpp b/src/components/timer/Timer.cpp new file mode 100644 index 00000000..279178cd --- /dev/null +++ b/src/components/timer/Timer.cpp @@ -0,0 +1,28 @@ +#include "components/timer/Timer.h" + +using namespace Pinetime::Controllers; + +Timer::Timer(void* const timerData, TimerCallbackFunction_t timerCallbackFunction) { + timer = xTimerCreate("Timer", 1, pdFALSE, timerData, timerCallbackFunction); +} + +void Timer::StartTimer(std::chrono::milliseconds duration) { + xTimerChangePeriod(timer, pdMS_TO_TICKS(duration.count()), 0); + xTimerStart(timer, 0); +} + +std::chrono::milliseconds Timer::GetTimeRemaining() { + if (IsRunning()) { + TickType_t remainingTime = xTimerGetExpiryTime(timer) - xTaskGetTickCount(); + return std::chrono::milliseconds(remainingTime * 1000 / configTICK_RATE_HZ); + } + return std::chrono::milliseconds(0); +} + +void Timer::StopTimer() { + xTimerStop(timer, 0); +} + +bool Timer::IsRunning() { + return (xTimerIsTimerActive(timer) == pdTRUE); +} diff --git a/src/components/timer/Timer.h b/src/components/timer/Timer.h new file mode 100644 index 00000000..2469666f --- /dev/null +++ b/src/components/timer/Timer.h @@ -0,0 +1,26 @@ +#pragma once + +#include +#include + +#include + +namespace Pinetime { + namespace Controllers { + class Timer { + public: + Timer(void* timerData, TimerCallbackFunction_t timerCallbackFunction); + + void StartTimer(std::chrono::milliseconds duration); + + void StopTimer(); + + std::chrono::milliseconds GetTimeRemaining(); + + bool IsRunning(); + + private: + TimerHandle_t timer; + }; + } +} diff --git a/src/components/timer/TimerController.cpp b/src/components/timer/TimerController.cpp deleted file mode 100644 index e3aa07af..00000000 --- a/src/components/timer/TimerController.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "components/timer/TimerController.h" - -using namespace Pinetime::Controllers; - -TimerController::TimerController(void* const timerData, TimerCallbackFunction_t timerCallbackFunction) { - timer = xTimerCreate("Timer", 1, pdFALSE, timerData, timerCallbackFunction); -} - -void TimerController::StartTimer(std::chrono::milliseconds duration) { - xTimerChangePeriod(timer, pdMS_TO_TICKS(duration.count()), 0); - xTimerStart(timer, 0); -} - -std::chrono::milliseconds TimerController::GetTimeRemaining() { - if (IsRunning()) { - TickType_t remainingTime = xTimerGetExpiryTime(timer) - xTaskGetTickCount(); - return std::chrono::milliseconds(remainingTime * 1000 / configTICK_RATE_HZ); - } - return std::chrono::milliseconds(0); -} - -void TimerController::StopTimer() { - xTimerStop(timer, 0); -} - -bool TimerController::IsRunning() { - return (xTimerIsTimerActive(timer) == pdTRUE); -} diff --git a/src/components/timer/TimerController.h b/src/components/timer/TimerController.h deleted file mode 100644 index 1d2a51df..00000000 --- a/src/components/timer/TimerController.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include -#include - -#include - -namespace Pinetime { - namespace Controllers { - class TimerController { - public: - TimerController(void* timerData, TimerCallbackFunction_t timerCallbackFunction); - - void StartTimer(std::chrono::milliseconds duration); - - void StopTimer(); - - std::chrono::milliseconds GetTimeRemaining(); - - bool IsRunning(); - - private: - TimerHandle_t timer; - }; - } -} -- cgit v1.2.3-70-g09d2