AsyncDelay¶
A simple abstraction for implementing delays and timeouts in Arduino sketches.
Licence¶
Released under the GNU Lesser General Public License, version 2.1. See https://github.com/stevemarple/AsyncDelay/blob/master/LICENSE.txt
Examples¶
AsyncDelay_example
Demonstrate the use of start(), isExpired() and repeat().
OneShotExample
Demonstrate how to use timers in ‘one-shot’ mode.
ReadA0
Read the A0 input and print the value at regular values using an AsyncDelay timer.
Class Documentation¶
-
class
AsyncDelay¶ A timer implementation safe from the effects of rollover.
The AsyncDelay class conveniently encapsulates the behaviour described at http://arduino.cc/playground/Code/TimingRollover
- Author
Steve Marple
Public Types
Public Functions
-
AsyncDelay(void)¶ Default AsyncDelay constructor.
Initializes the delay to zero. The timer will always be expired until
start()is called.
-
AsyncDelay(unsigned long delay, units_t unit)¶ Construct a new Async Delay object.
- Parameters
delay: The duration the timer should wait forunit: The time unit for the delay
-
bool
isExpired(void) const¶ Test if the timer has expired.
- Return
true if the timer has expired, false if not
-
bool
isExpired(void) volatile const¶ Test if the timer has expired.
- Return
true if the timer has expired, false if not
-
void
start(unsigned long delay, units_t unit)¶ Start a timer.
- Parameters
delay: The duration the timer should wait forunit: The time unit for the delay
-
void
start(unsigned long delay, units_t unit) volatile¶ Start a timer.
- Parameters
delay: The duration the timer should wait forunit: The time unit for the delay
-
void
repeat(void)¶ Start the timer from when it expired.
-
void
repeat(void) volatile¶ Start the timer from when it expired.
-
void
restart(void)¶ Restart the timer from now.
-
void
restart(void) volatile¶ Restart the timer from now.
-
void
expire(void)¶ Force a timer to become expired.
-
void
expire(void) volatile¶ Force a timer to become expired.
-
unsigned long
getDelay(void) const¶ Get the delay.
- Return
unsigned long The delay in whatever unit was set
-
unsigned long
getDelay(void) volatile const¶ Get the delay.
- Return
unsigned long The delay in whatever unit was set
-
void
getDelay(unsigned long &delay, units_t &unit) const¶ Get the delay and unit.
- Parameters
delay: Reference to where delay is to be savedunit: Reference to where unit is to be saved
-
void
getDelay(unsigned long &delay, units_t &unit) volatile const¶ Get the delay and unit.
- Parameters
delay: Reference to where delay is to be savedunit: Reference to where unit is to be saved
-
unsigned long
getExpiry(void) const¶ Get the time when the timer expires.
- Return
unsigned long Time in selected units
-
unsigned long
getExpiry(void) volatile const¶ Get the time when the timer expires.
- Return
unsigned long Time in seelcted units
-
unsigned long
getDuration(void) const¶ Get the duration since the timer was started.
- Return
unsigned long Duration in selected units
-
unsigned long
getDuration(void) volatile const¶ Get the duration since the timer was started.
- Return
unsigned long Duration in selected units
This documentation was built using ArduinoDocs.