-
Notifications
You must be signed in to change notification settings - Fork 249
Home
Big Thank you to:
Doanh Văn Lương (aka tarzan115) for creating this wiki based on my documentation! (I always wanted to do it, and always did not find the time.)
And to Uri Shaked for creating Wokwi - an online Arduino learning platform and TaskScheduler playground.
Learn TaskScheduler by experimenting here: Traffic Light with TaskScheduler
Check out other libraries: Dictionary, EspBootstrap, AverageFilter, and other.
Cooperative multitasking for Arduino microcontrollers
A lightweight implementation of cooperative multitasking (task scheduling) supporting:
- Periodic task execution, with dynamic execution period in
milliseconds
(default) ormicroseconds
(if explicitly enabled) – frequency of execution - Number of iterations (limited or infinite number of iterations)
- Execution of tasks in predefined sequence
- Dynamic change of task execution parameters (frequency, number of iterations, callback methods)
- Power saving via entering IDLE sleep mode when tasks are not scheduled to run
- Support for event-driven task invocation via Status Request object
- Support for task IDs and Control Points for error handling and watchdog timer
- Support for Local Task Storage pointer (allowing use of same callback code for multiple tasks)
- Support for layered task prioritization
- Support for
std::functions
(ESP8266
only) - Support for overall task timeouts
- Static and dynamic callback method binding
- CPU load / idle statistics for time critical applications
- Scheduling options with priority for original schedule (with and without catchup) and interval
- Ability to pause/resume and enable/disable scheduling
- Thread-safe scheduling while running under preemptive scheduler (i. e., FreeRTOS)
Scheduling overhead: between 15
and 18
microseconds per scheduling pass (Arduino UNO rev 3 @ 16MHz
clock, single scheduler w/o prioritization)
Memory requirements: 46 bytes (plain vanilla), 57 bytes (IDLE sleep, WDT and LTS pointer support). Other options have similar memory footprints.
TaskScheduler was tested on the following platforms:
- Arduino Uno R3
- Arduino Nano
- Arduino Micro
- ATtiny85
- ESP8266 (Node MCU v2.0)
- ESP32
- Teensy (tested on Teensy 3.5)
- nRF52 (tested on nRF52832)
- STM32 (tested on Mini USB STM32F103RCBT6 ARM Cortex-M3 leaflabs Leaf maple mini module F)
- MSP430 and MSP432 boards
- Raspberry Pi (requires external
Arduino.h
andmillis()
implementation)
Check the changes here
-
Implementation scenarios and ideas
1. Event driven programming
2. "Native" support for finite state machine
3. Multiple possible callbacks for task
4. Interrupt-driven execution support
5. UsingonEnable
andonDisable
methods
6. Using status request objects
7. Using local task storage pointer
8. Enabling task prioritization -
Futher information
Please refer to examples, provided withTaskScheduler
package for further information and implementation options.Real time examples of
TaskScheduler
are available here:- http://www.instructables.com/id/APIS-Automated-Plant-Irrigation-System/
- http://www.instructables.com/id/Wave-your-hand-to-control-OWI-Robotic-Arm-no-strin/
- http://www.instructables.com/id/Arduino-Nano-based-Hexbug-Scarab-Robotic-Spider
- http://www.instructables.com/id/Interactive-Predator-Costume-With-Head-Tracking-Pl/
- https://www.instructables.com/id/Portable-Party-Lights/