A non-blocking replacement for Arduino's delay() function. More...
#include <EventDelay.h>
A non-blocking replacement for Arduino's delay() function.
EventDelay can be set() to a number of milliseconds, then after calling start(), ready() will return true when the time is up.
Alternatively, start(milliseconds) will call set() and start() together.
Definition at line 20 of file EventDelay.h.
Public Member Functions | |
EventDelay (unsigned int delay_milliseconds=0) | |
Constructor. More... | |
void | set (unsigned int delay_milliseconds) |
Set the delay time. More... | |
void | start () |
Start the delay. More... | |
void | start (unsigned int delay_milliseconds) |
Set the delay time and start the delay. More... | |
bool | ready () |
Call this in updateControl() or updateAudio() to check if the delay time is up. More... | |
Protected Attributes | |
unsigned long | deadline |
unsigned long | ticks |
|
inline |
Constructor.
Declare an EventDelay object.
delay_milliseconds | how long until ready() returns true, after calling start(). Defaults to 0 if no parameter is supplied. |
Definition at line 29 of file EventDelay.h.
|
inline |
Call this in updateControl() or updateAudio() to check if the delay time is up.
Definition at line 73 of file EventDelay.h.
|
inline |
Set the delay time.
This setting is persistent, until you change it by using set() again.
delay_milliseconds | delay time in milliseconds. |
Definition at line 40 of file EventDelay.h.
|
inline |
Start the delay.
Definition at line 51 of file EventDelay.h.
|
inline |
Set the delay time and start the delay.
delay_milliseconds | delay time in milliseconds. |
Definition at line 61 of file EventDelay.h.