Skip to content

Call SleepMethod with minimal time to next task. Use it to sleep.

Notifications You must be signed in to change notification settings

xvedra/TaskScheduler-custom-sleep-method

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

Arduino TaskScheduler-custom-sleep-method

Use the SleepMethod to minimize the time between tasks and put the board to sleep.

To implement it, add or modify the following code in bool Scheduler::execute():


....

unsigned long tu, mtu;

....

mtu = 0xFFFFFFFF;


while (!iPaused && iCurrent) {


if(!iCurrent->canceled())

{

  tu = (long) iCurrent->iDelay - ( (long) ((_TASK_TIME_FUNCTION() - iCurrent->iPreviousMillis)) );
  
  if(tu < mtu) mtu = tu;
  
}    

....

//(*iSleepMethod)( tFinish-tStart );

(*iSleepMethod)(mtu);

....

Now, the board can sleep for all the time between tasks.

If your sleep method stops time like millis(), remember to use external_millis() in all software, including external libraries.

About

Call SleepMethod with minimal time to next task. Use it to sleep.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages