Scheduler
DUELink Engine includes a scheduler to help execute tasks repeatedly. Use SStart to start scheduling a function. The arguments are SStart(func, time, count), where 'func' is the function to schedule, time is the delay between executions, and finally count is for the scheduler repeat count.
Things to consider:
- Schedulers only run if there is a running program. Terminating the main program will automatically stop schedulers.
- Set
countto0to run forever. - The scheduler triggers
funcfunction with no passed arguments. Only usefuncwith no arguments.
You can check the current status of a scheduler using SStat(func). The returned value shows remaining count for the scheduler, a value of -1 means the scheduler is running forever.
It is possible to abort a schedule at any time using SAbort(func).
_i=0
_c = 0
SStart("Blink", 1000, 5)
# Main program loop
while 1
PrintLn("stat: ", SStat("Blink"), " - Count: ", _c)
_c=_c+1
end
wait(100)
# You can for example use a button SAbort("Blink")
wend
fn Blink()
Println("Go Scheduler! - ", _i)
_i=_i+1
fend