Member Functions
List of all member functions with their input parameters and return types.
Constructors & Destructor
This is the simplest method to create a ptScheduler object.
Parameters :
interval_1
: Time in milliseconds. 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
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 :
_mode
: Any of the 8 supported modes.interval_1
: Time in milliseconds.
Return : Nothing
Create a task with two intervals. The interval values can be same or different. Same as before, a list will be allocated and intervalList
will be pointed to that location. intervalCount
will be 2 in this case.
Parameters :
_mode
: Any of the 8 supported modes.interval_1
: Time in milliseconds.interval_2
: Time in milliseconds.
Return : Nothing
Create a task with an arbitrary number of intervals. You first have to create an array of interval values something like below,
then pass the address to the constructor like below,
Parameters :
_mode
: Any of the 8 supported modes.listPtr
: Address of array of intervals.listLength
: Number of intervals in the array. This value should be less than or equal to the number of values in the array.
Return : Nothing
The destructor does nothing.
Parameters : None
Return : Nothing
reset()
reset()
This function resets all status variables and counters to their default values. But no user defined values will be reset, such as the intervals, iterations, skip time etc. After resetting, it will also enable the task allowing you to start fresh.
Parameters : None
Return : Nothing
enable()
enable()
This function enables a task by setting the enabled
status variable to true
. Only enabled tasks can run.
Parameters : None
Return : Nothing
disable()
disable()
This function disables a task by setting the enabled
status variable to false
. Only enabled tasks can run.
Parameters : None
Return : Nothing
suspend()
suspend()
Suspending a task means it will no longer run, but some of the counter variables will continue to increment. When a task is suspended, it is said to be in sleep. A task remains in sleep mode until we manually activate it again. In sleep mode, intervalCounter
will continue to increment for every interval passed. If you have multiple intervals, each of them will cause intervalCounter
to increment in a round-robin fashion. sleepIntervalCounter
will keep track of how many intervals have passed after entering sleep mode. You can use either of these counters to conditionally activate the task at later point using the resume()
function.
Parameters : None
Return : Nothing
resume()
resume()
Resumes a suspended task.
Parameters : None
Return : Nothing
call()
call()
This is the main task invocation function. You should enclose this function inside any conditional statements to run the block of code under it. If it is time to run a task, call()
will return true
, and otherwise false
.
Parameters : None
Return :
true
: Run the code blockfalse
: Skip the code block
setInterval()
setInterval()
Use this function if you need to change the interval after creating the object, or dynamically. If you created the object with more than one intervals, then only the first value will be updated.
Parameters :
value
: Time in milliseconds
Return :
true
: Setting interval was successful.false
: Setting interval was unsuccessful. It can only fail if theintervalCount
was 0.
This updates the first two interval values in the interval list. If the interval count is less than 2, this operation will fail.
Parameters :
value_1
: Time in millisecondsvalue_2
: Time in milliseconds
Return :
true
: Setting interval was successful.false
: Setting interval was unsuccessful. It can only fail if theintervalCount
was less than 2.
setIteration()
setIteration()
This creates an iterated task. After the specified number of iterations has executed, the task will enter to sleep. The sleep mode is determined by what you have set with setSleepMode()
.
Parameters :
value
: Number of iterations (positive integer)
Return :
true
: Setting iterations was successful.false
: Setting iteration was unsuccessful. This can only fail if the task mode is invalid.
setSkipInterval()
setSkipInterval()
This calculates the skip time from the interval values. For example, if the interval is 1000 ms, setting setSkipInterval(5)
will produce a skip time of 5 * 1000 = 5000 ms. If you have multiple intervals, each of the intervals will be added up to value
times. The final value is assigned to skipTime
and the flags skipIntervalSet
and skipTimeSet
are set to true
.
Parameters :
value
: Number of intervals to skip (positive integer)
Return :
true
: Setting skip interval was successful.false
: Setting skip interval was unsuccessful. This can only fail ifintervalCount
was 0.
setSkipIteration()
setSkipIteration()
This calculates the skip time from the iteration values. Each iteration is a set of one or more interval values. The skip time is calculated as value * (sum of intervals in the interval list)
. The final value is assigned to skipTime
and the flags skipIterationSet
and skipTimeSet
are set to true
.
Parameters :
value
: Number of iterations to skip (positive integer)
Return :
true
: Setting skip iteration was successful.false
: Setting skip iteration was unsuccessful. This can only fail ifintervalCount
was 0.
setSkipTime()
setSkipTime()
This directly sets the skipTime
and the skipTimeSet
flag.
Parameters :
value
: Time in milliseconds
Return :
true
: Setting skip time was successful.false
: Setting skip time was unsuccessful. This can only fail ifintervalCount
was 0.
setTaskMode()
setTaskMode()
Sets the task mode.
Parameters :
mode
: One of the 8 supported modes.
Return :
true
: Setting task mode was successful.false
: Setting task mode was unsuccessful. This can only fail if the input value was invalid.
setSleepMode()
setSleepMode()
Sets the sleep mode. A task enters into sleep mode after the specified number of iterations has completed. That means, sleep mode only applies to iterated tasks. The values can be, PT_SLEEP_DISABLE
for disabling the task (reset all states and counters) or PT_SLEEP_SUSPEND
for suspending the task.
Parameters :
mode
: One of the 2 supported modes –PT_SLEEP_DISABLE
,PT_SLEEP_SUSPEND
Return :
true
: Setting sleep mode was successful.false
: Setting sleep mode was unsuccessful. This can only fail if the input value was invalid.
isInputError()
isInputError()
If any of the user inputs were invalid, the inputError
flag is set. This function will return the value of inputError
and also reset it.
Parameters : None
Return :
true
:inputError
is true.false
: No input error.
printStats()
printStats()
Prints all the status variables, flags and counters to the serial port. Useful for debugging.
Parameters : None
Return : Nothing
Last updated