Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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)

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.