libpropeller
Making PropellerGCC Easier
|
A pollable timer to help schedule events. More...
#include <scheduler.h>
Public Member Functions | |
Scheduler (const int deci_hz) | |
Create a schedule keeper that returns true with the specified frequency. More... | |
bool | Run (void) |
Check to see if the time period has passed yet. More... | |
Static Public Member Functions | |
static unsigned int | GetTicksPerPeriod (const int deci_hz) |
Calculates how many clock cycles are in each period. More... | |
A pollable timer to help schedule events.
|
inline |
Create a schedule keeper that returns true with the specified frequency.
The frequency is specified in units of 0.1Hz. So, to create a scheduler with a frequency of 150Hz you pass in 1500. To make a scheduler with a frequency of 0.5Hz (once every two seconds), you pass in 5 (0.1Hz * 5 = 0.5Hz). A scheduler with a frequency of 1Hz takes a parameter of 10.
deci_hz | The frequency (in 10x true return values per second). |
|
inlinestatic |
Calculates how many clock cycles are in each period.
For testing only!
deci_hz | The frequency is deci-hz (hz * 10) |
|
inline |
Check to see if the time period has passed yet.
This function is not blocking. This class keeps an internal state that watches the system counter, and if the next "period" has begun returns true the next time that this function is called. It then returns false for the rest of the current period.
This function is useful for scheduling reseting watchdog timers, determining when to poll external sensors, and so on.
The function returns true for each time period, so if it is not called for multiple time periods it returns true for each (up to hz times).