A simple class for an elapsed timer, primarily for use with Arduinos.
Creates a timer object (constructor). Creating a timer does NOT start it, you must call the start method.
- unsigned long dur: duration in milliseconds. Default is 1000 milliseconds.
- bool autoRestart: if true, the timer will auto-restart when the method timedOut is called and the result is true. Default is false.
Starts (activates) the timer with an optional duration.
- unsigned long dur: duration in milliseconds. If none is provided (e.g., duration = 0), the previous duration is used.
Stops (deactivates) the timer.
Returns the current state of the timer, true = active, false = inactive.
Returns whether the timer has timed out (true) or not (false). When a timer times out, if the timer object was created with autoRestart set to true, then the timer is automatically restarted, otherwise the timer is stopped (deactivated).
Returns the number of milliseconds before the timer times out.