Tiny and cross-device compatible timer-driven timed function calls library.
Supports Arduino AVR, SAM, STM32, ESP8266 and SAMD21 microcontrollers.
While being in 0.X.Y version, library is still in development.
Currently suported architectures:
- AVR
- STM32
- SAM (Arduino Due)
- ESP8266
- SAMD21 (Arduino Zero and Zero MKR, experimental)
Depending on wich architecture this library uses one or another device timer. Take in mind this because can caause conflicts with other libraries:
- AVR: Timer2 (3rd timer)
- STM32: Timer3 (3rd timer)
- SAM: TC3 (Timer1, channel 0)
- ESP8266: Ticker library (inside ESP8266 core, no extras needed)
- SAMD21: Timer2 (3rd timer)
This library defines a global variable when included called "TimerLib".
You have these methods:
- TimerLib.setInterval_us(callback_function, microseconds); : callback_function will be called each microseconds.
- TimerLib.setInterval_s(callback_function, seconds); : callback_function will be called each seconds.
- TimerLib.setTimeout_us(callback_function, microseconds); : callback_function will be called once when microseconds have passed.
- TimerLib.setTimeout_s(callback_function, seconds); : callback_function will be called once when seconds have passed.
- TimerLib.clearTimer(); : will clear any timed function if exists.
It only manages one function at a time, if you call any setXXX method it will cancel any running timed function and process new one.
An attached functions broker could be implemented, but then this would not be (micro)TimerLib. Maybe in other project.....
You can get it from Arduino libraries directly, searching by uTimerLib.
For manual installation:
- Get the ZIP from releases link: https://github.com/Naguissa/uTimerLib/releases
- Rename to uTimerLib.zip
- Install library on Arduino
Included on example folder, available on Arduino IDE.