49 lines
631 B
C++

/*
* Timer.cpp
*
* Created on: Jun 7, 2024
* Author: Carst
*/
#include "Timer.hpp"
namespace ElektronischeLast
{
Timer::Timer()
{
this->isRunning = false;
}
void Timer::start(uint32_t durationMs)
{
this->timerValue = durationMs;
this->isRunning = true;
}
void Timer::stop(void)
{
this->isRunning = false;
}
bool Timer::elapsed(void)
{
return !this->isRunning;
}
void Timer::tick(void)
{
if (this->isRunning)
{
if (this->timerValue > 0)
{
this->timerValue--;
}
else
{
this-> isRunning = false;
}
}
}
}