fabriceo / SCoop

Simple Cooperative Scheduler for Arduino and Teensy ARM and AVR
126 stars 82 forks source link

scoop-sleep(ms) #9

Closed waynekuowayne closed 11 months ago

waynekuowayne commented 12 months ago

sorry my english is not well , thanks for share scoop lib , it's really useful , my question is function "sleep" is millisecond, can it use microsecond??

thank you so much

fabriceo commented 11 months ago

Hello, I m pleased that you find it useful :)

as you can see in scoop.h, the class ScoopTask contains a ScoopDelay Timer definition at the bottom. Just change this to ScoopDelayUs and the sleep will request microseconds instead of seconds.

the original reason to choose millisecond was related to the 328p capacity. the basic integer are 16 bits, and usually the yield() takes several microseconds so I thought Milliseconds was more appropriate.

you could also duplicate the timer with ScoopDelayUs TimerUs and then create a new spell function just copy pasting the previous one but with name SleepUs

hope this help best regards