LoRa_APRS_iGate/lib/System/Timer.cpp
Peter Buchegger 2c78a002ab big update:
- display update
- timer changed to ms
- allow connections just when connected
2021-03-27 22:02:43 +01:00

29 lines
478 B
C++

#include "Timer.h"
Timer::Timer() : _timeout_ms(0), _nextTimeout(0) {
}
void Timer::setTimeout(const uint32_t timeout_ms) {
_timeout_ms = timeout_ms;
}
time_t Timer::getTriggerTimeInSec() const {
return (_nextTimeout - millis()) / 1000;
}
bool Timer::isActive() const {
return _nextTimeout != 0;
}
void Timer::reset() {
_nextTimeout = 0;
}
bool Timer::check() {
return millis() > _nextTimeout;
}
void Timer::start() {
_nextTimeout = millis() + _timeout_ms;
}