25 Metro(
unsigned long interval_millis, uint8_t autoreset = 0);
34 void interval(
unsigned long interval_millis);
66 unsigned long previous_millis;
67 unsigned long interval_millis;
70inline Metro::Metro(
unsigned long interval_millis, uint8_t autoreset)
72 this->autoreset = autoreset;
79 this->interval_millis = interval_millis;
92 if (millis() - this->previous_millis >= this->interval_millis)
100 if (this->interval_millis <= 0 || this->autoreset)
102 this->previous_millis = millis();
106 this->previous_millis += this->interval_millis;
117 if (millis() - this->previous_millis >= this->interval_millis)
127 this->previous_millis = millis();
Our own implementation of Metro class.
void reset()
Resets the timer to the current time.
bool checkWithoutReset() const
Checks if the interval has passed without resetting the timer.
Metro(unsigned long interval_millis, uint8_t autoreset=0)
Constructor to initialize the timer with a given interval and autoreset behavior.
bool check()
Checks if the interval has passed and resets the timer if true.
void interval(unsigned long interval_millis)
Sets a new interval for the timer.