LoRa_APRS_iGate/lib/TaskManager/Timer.cpp

29 lines
426 B
C++
Raw Normal View History

2021-03-12 20:01:47 +01:00
#include "Timer.h"
Timer::Timer() : _timeout_sec(0), _timeout(0) {
2021-03-12 20:01:47 +01:00
}
void Timer::setTimeout(const time_t timeout_sec) {
_timeout_sec = timeout_sec;
2021-03-12 20:01:47 +01:00
}
time_t Timer::getTriggerTime() const {
return _timeout;
2021-03-12 20:01:47 +01:00
}
bool Timer::isActive() const {
return _timeout != 0;
2021-03-12 20:01:47 +01:00
}
void Timer::reset() {
_timeout = 0;
2021-03-12 20:01:47 +01:00
}
bool Timer::check() {
return now() > _timeout;
2021-03-12 20:01:47 +01:00
}
void Timer::start() {
_timeout = now() + _timeout_sec;
2021-03-12 20:01:47 +01:00
}