mirror of https://github.com/nealey/puzzle-box.git
20 lines
302 B
C++
20 lines
302 B
C++
|
#include "pulse.h"
|
||
|
|
||
|
#include <Arduino.h>
|
||
|
|
||
|
Pulse::Pulse(unsigned long period) {
|
||
|
this->period = period;
|
||
|
this->nextEventMillis = 0;
|
||
|
}
|
||
|
|
||
|
bool Pulse::Tick() {
|
||
|
unsigned long now = millis();
|
||
|
|
||
|
if (now >= nextEventMillis) {
|
||
|
nextEventMillis = now + period;
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|