VariableTimedAction
1.2.2
This is a library used for scheduling events written specifically for the Arduino community.
|
This class is used as an interface to create a timed loop to perform repetitive actions. More...
#include <VariableTimedAction.h>
Public Member Functions | |
void | start (unsigned long startInterval, bool startNow=true) |
Starts the timer and sets the interval that the #run method should be called. More... | |
void | toggleRunning () |
Toggles the timer on and off. More... | |
bool | isRunning () |
Returns current status of the timer. More... | |
void | stop () |
Stops the timer, removing it from the list of actions. More... | |
Static Public Member Functions | |
static void | updateActions () |
Iterates through all actions and calls the #run method on actions whose interval has passed. More... | |
This class is used as an interface to create a timed loop to perform repetitive actions.
The implementing class must override the pure virtual function #run, which will be called every interval. However, the user specified interval defines the minimum length of time which can be passed before the action is executed.
Created on December 14, 2016, 4:43 PM
|
inline |
Returns current status of the timer.
void VariableTimedAction::start | ( | unsigned long | startInterval, |
bool | startNow = true |
||
) |
Starts the timer and sets the interval that the #run method should be called.
This method can be called whether the timer is stopped or paused. If it is stopped or has never been started, it will be started. If it is paused, then it will resume using the new interval.
startInterval | The interval to wait between calls to #run. |
startNow | If true, the timer will execute #run right away and then wait until the next interval. Otherwise, the timer will execute after the interval has passed. |
void VariableTimedAction::stop | ( | ) |
Stops the timer, removing it from the list of actions.
If the timer has to be started again, then use start as it will need to be added into the list of actions.
void VariableTimedAction::toggleRunning | ( | ) |
Toggles the timer on and off.
This is faster than stopping and starting the timer every time.
|
static |
Iterates through all actions and calls the #run method on actions whose interval has passed.
This method should be called frequently in the #loop method. In timing-intensive applications, this method should be the only thing in the loop method.