wizard97 / ArduinoProcessScheduler

An Arduino object oriented process scheduler designed to replace them all
46 stars 16 forks source link

ArduinoProcessScheduler

A cooperative Arduino object oriented, cooperative process scheduler to replace them all.

What is this?

As your Arduino projects get more complicated, you will begin to see the need for multitasking, or at least appear to multitask. Perhaps you want to check if a button was pressed as often as you can, but you only want to update a display once every second. Trying to do this on your own can quickly turn into overwhelming spagetti code involving millis(). ArduinoProcessScheduler seeks to simplify this. Simply create your custom Process that needs to be serviced at certain times, and let the scheduler handle the rest.

Why this one?

Here are some similar popular libraries that inspired this one:

What is wrong with them?

  1. They all treat processes/tasks as just callback functions.
    1. Forces you to use ugly global and/or static function variables to track process state.
    2. Limits you to one instance of a process, or lots of copy & paste.
    3. Impossible to truly dynamically create new processes, you are really just enabling/disabling a callback function.
  2. Preemptive schedulers must split stack between all processes
    1. With 2K or RAM and 8 processes, preemptive scheduler could at most equally give each Process 2k/8 = 256 Bytes of RAM.
  3. No concurrency protection (not interrupt safe)
    1. What if an interrupt fires an tries to disable a process while it is running?

Features

Basic

Advanced

Supported Platfroms

Install & Usage

See Wiki

NOTE: Don't forget to install this RingBuf library dependency!

Contributing

I welcome any contributions! Here are some ideas:

License

MIT.