-
-
Notifications
You must be signed in to change notification settings - Fork 4
Reference
Vishnu Mohanan edited this page Dec 5, 2020
·
12 revisions
Here we have all the modes and constants defined.
#define debugSerial Serial //for debugging
//task modes
#define PT_MODE_EPO 1 //Equal, Periodic, Oneshot
#define PT_MODE_EIO 2 //Equal, Iterated, Oneshot
#define PT_MODE_UPO 3 //Unequal, Periodic, Oneshot
#define PT_MODE_UIO 4 //Unequal, Iterated, Oneshot
#define PT_MODE_EPS 5 //Equal, Periodic, Spanning
#define PT_MODE_EIS 6 //Equal, Iterated, Spanning
#define PT_MODE_UPS 7 //Unequal, Periodic, Spanning
#define PT_MODE_UIS 8 //Unequal, Iterated, Spanning
//sleep modes
#define PT_SLEEP_DISABLE 1 //self-disable mode
#define PT_SLEEP_SUSPEND 2 //self-suspend mode
typedef int64_t time_ms_t; //time in milliseconds
There is only one custom type defined. time_ms_t
is for storing millisecond values.
class ptScheduler;
There's only class that wraps all the functions, state variables and counters for every task.
ptScheduler (time_ms_t interval_1); //sets the initial interval for the task
ptScheduler (uint8_t _mode, time_ms_t interval_1);
ptScheduler (uint8_t _mode, time_ms_t interval_1, time_ms_t interval_2);
ptScheduler (uint8_t _mode, time_ms_t* listPtr, uint8_t listLength);
~ptScheduler();
void reset(); //disable + enable
void enable(); //enabling a task to run at each intervals
void disable(); //block a task from running and reset all state variables and counters
void suspend(); //block a task from running but without resetting anything. interval counter will still run.
void resume(); //resume a suspended task
bool call(); //the task invokation call
bool setInterval (time_ms_t value); //dynamically set task interval
bool setInterval (time_ms_t value_1, time_ms_t value_2); //update two interval values. only for tasks instantiated with >= intervals
bool setIteration (int32_t value); //no. of iterations you want to execute for each activation
bool setSkipInterval (uint32_t value); //intervals to wait before executing the task
bool setSkipIteration (uint32_t value); //iterations to wait before executing the task
bool setSkipTime (time_ms_t value); //time to wait before executing the task
bool setTaskMode (uint8_t mode); //set execution mode
bool setSleepMode (uint8_t mode); //set what happens after an iteration is complete
bool isInputError();
void printStats(); //prints all the statuses and counter to debug port
ptScheduler (time_ms_t interval_1);
This is the simplest method to create a ptScheduler object.
Parameters :
- Time in milliseconds. Negative values will be automatically converted to positive values using
abs()
method. The task mode will be set toPT_MODE_EPO
and other values to their defaults. An array will be dynamically allocated to hold the interval value and the pointerintervalList
is updated with the address of this location.intervalLength
will be set to 1.
Return : Nothing
ptScheduler (uint8_t _mode, time_ms_t interval_1);
This is the same as the previous one but we can explicitly specify the task mode here. For a single interval, only PT_MODE_EPO
, PT_MODE_EIO
, PT_MODE_EPS
and PT_MODE_EIS
modes are supported.
Parameters :