/* * Timer.cpp * * Created on: Jun 7, 2024 * Author: Carst */ #include "stm32G071KBT6.hpp" #include "Timer.hpp" namespace ElektronischeLast { Timer::Timer() { this->isRunning = false; } void Timer::start(uint32_t durationMs) { this->timeout = durationMs; this->timer_start = systick; this->isRunning = true; } void Timer::restart(void) { this->timer_start = systick; this->isRunning = true; } void Timer::stop(void) { this->isRunning = false; } bool Timer::elapsed(void) { bool elapsed = false; if(this->isRunning) { if((systick - this->timer_start) >= this->timeout) { elapsed = true; } } return elapsed; } bool Timer::is_running(void) { return this->isRunning; } }