Button handler, with software debounce logic and long-press support.
Internally, it is using interrupts and esp_timer for debounce. Does not poll state when idle, only while button is being pressed (this is necessary, as it is impossible to disambiguate press and release in an interrupt routine).
To reference this library by your project, add it as git submodule, using command
git submodule add https://github.com/mdvorak/esp-button.git components/button
and include either of the header files
#include <button.h>
For full example, see button_example_main.c.
Prepare ESP-IDF development environment .
Configure example application with
cd example/
idf.py menuconfig
Flash it via (in the example dir)
idf.py build flash monitor
As an alternative, you can use PlatformIO to build and flash the example project.