Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sglvladi/ticker_esp32
esp32 library that calls functions periodically (similar to "Ticker.h" for esp8266)
https://github.com/sglvladi/ticker_esp32
arduino esp32 ticker
Last synced: 5 days ago
JSON representation
esp32 library that calls functions periodically (similar to "Ticker.h" for esp8266)
- Host: GitHub
- URL: https://github.com/sglvladi/ticker_esp32
- Owner: sglvladi
- License: gpl-3.0
- Created: 2017-09-13T20:38:11.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-14T05:46:46.000Z (over 7 years ago)
- Last Synced: 2024-10-30T06:41:00.036Z (about 2 months ago)
- Topics: arduino, esp32, ticker
- Language: C++
- Size: 14.6 KB
- Stars: 1
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ticker_ESP32
A primitive library which makes use of the hardware timers in ESP32, to provide similar funtionality and interface akin to the "Ticker.h" library for ESP8266.# Differences to "Ticker.h" for ESP8266
* Each Ticker instance must be provided with the id of the respective hw timer which should be employed. Valid ids can be in the range 0-3. (e.g. ```Ticker LED_Ticker_1(2);```)
* ESP32 has 4 hw timers, which means up to 4 Ticker instances can be instantiated, one for each timer.
* Unlike "Ticker.h", callback functions with arguments are not supported (yet).# Usage
* Define a Ticker instance (e.g. on 4th hw timer):```c++
Ticker myTicker(3);
```* Define a callback function to be called when timer fires:
```c++
void myCallback(){
// Do something interesting...
}
```* Initiate the timer and attach our callback to be run at a certain interval (e.g. 1 sec):
```c++
myTicker.attach(1, myCallback);or
myTicker.attach_us(1000000, myCallback); // 1 second = 1000000 microseconds
```
* When desired, stop the timer and detach the callback:
```
myTicker.detach();
```See the blinkLEDs sketch, for a full example.