added some utility to timer module
This commit is contained in:
parent
b2c102b2c1
commit
6073abb12d
@ -27,6 +27,7 @@ int Timer::setTimer(uint32_t intervalMs) {
|
||||
timer.it_value.tv_nsec = (intervalMs * 1000000) % (1000000000);
|
||||
timer.it_interval.tv_sec = 0;
|
||||
timer.it_interval.tv_nsec = 0;
|
||||
set = true;
|
||||
return timer_settime(timerId, 0, &timer, NULL);
|
||||
}
|
||||
|
||||
@ -43,3 +44,14 @@ int Timer::getTimer(uint32_t* remainingTimeMs){
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
bool Timer::isSet() const {
|
||||
return this->set;
|
||||
}
|
||||
|
||||
void Timer::resetTimer() {
|
||||
if(not this->set) {
|
||||
set = false;
|
||||
}
|
||||
setTimer(0);
|
||||
}
|
||||
|
@ -38,7 +38,11 @@ public:
|
||||
*/
|
||||
int getTimer(uint32_t* remainingTimeMs);
|
||||
|
||||
bool isSet() const;
|
||||
void resetTimer();
|
||||
|
||||
private:
|
||||
bool set = true;
|
||||
timer_t timerId;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user