How to correctly use bc_scheduler?


I have read the SDK, but it is not so clear for me… I would like to clarify how to correctly use “bc_scheduler” functions.

“bc_scheduler_register” - it is function for “timing” the next run of some function. I specify script name, parameters and tick when it starts (actual tick + some time in miliseconds)

BUT… when the time comes, it runs the specified function and? It finish forever or I need to use “bc_scheduler_unregister”? I thought, that it runs only once and it is unregistered automatically when it finish.

I am sorry, but I didn’t find any documentation for this, just only SDK and I am not sure If I am using SDK correctly, but there is not so much information for me to understand it. I am using it as I have seen in the examples, but I am just guessing how it works by method of trying and errors :grinning:

I am also not sure about these topics:

  • what difference is between relative and absolute scheduling? (relative is just number of miliseconds from now? and absolute is some number of tick?)
  • why to use “bc_scheduler_plan_current_from_now” instead of calling some function directly?
  • what is difference between “bc_scheduler_plan_current_from_now” and “bc_scheduler_plan_current_relative”? (current spin is not same as current time?)
  • what difference is between “bc_tick_get” and “bc_scheduler_get_spin_tick”?
  • is it possible to schedule something for forever? Or I need to reschedule the task at the end of the task for next run?

Thanks for clarification. I hope it can help to some other beginner…

Why core module blinking SOS by morse code?

Hello, here are some basics from docs. I’ll clarify more after the weekend.

relative is number of millisoconds from now
absolute is number of milliseconds from start of the MCU

Registering the task will add it to the list of task and all tasks are called one after another. It is similar to the master-loop but it allows you dynamically register and unregister tasks at runtime.



Every task has to call “plan” function, otherwise it is planned in the time “INFINITY” which means the task is never run again, unless is replanned by bc_scheduler functions.



Thank you for quick answer! It clarified some of my questions. I am sorry that I am asking for something what is in the documentation, but sometimes I have problem to find something there. Sometimes I know that I have read something there, but I am not able to find it again. I am opening lot of sections and looking for that. I can’t say that it is not in the appropriate section, but the placing is logical for me when just I am on the correct page. I think, that some search engine can be very useful.

You clarified me absolute and relative scheduling and that every task is planned for some time and when it ends it never start again if it is not replanned.

These questions are still unclear:

  • why to use “bc_scheduler_plan_current_now” instead of calling some function directly?
  • what difference is between “bc_scheduler_plan_current_from_now” and “bc_scheduler_plan_current_relative”? (current spin is not same as current time?)
  • what difference is between “bc_tick_get” and “bc_scheduler_get_spin_tick”?
  • “bc_scheduler_unregister” - it is used just before the task starts? For example when I plan some task to some time and I want to cancel it, can I use this function? But when it starts it has no effect, because it is running… but - in the climate example is it used inside the function. Why it is there?

Thank you very much!