mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-31 12:29:14 +03:00
global cleaning, restructure
This commit is contained in:
32
include/UptimeInterval.h
Normal file
32
include/UptimeInterval.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
class UptimeInterval {
|
||||
public:
|
||||
UptimeInterval(unsigned long interval, boolean postpone = true) : _interval{interval} {
|
||||
reset(postpone);
|
||||
}
|
||||
|
||||
boolean check() {
|
||||
if (_next <= get()) {
|
||||
_next += _interval;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void reset(bool postpone = true) {
|
||||
_next = (postpone ? _uptime_seconds + _interval : _uptime_seconds);
|
||||
}
|
||||
|
||||
static unsigned long get() {
|
||||
unsigned long _uptime_seconds = millis() / 1000;
|
||||
return _uptime_seconds;
|
||||
};
|
||||
|
||||
static unsigned long _uptime_seconds;
|
||||
|
||||
private:
|
||||
unsigned long _interval, _next;
|
||||
};
|
||||
Reference in New Issue
Block a user