PlatformIO-based asynchronous button for ESP32 built on Arduino framework.
Button button(0); // GPIO 0 for ESP32 Devkit BOOT button.
void setup() {
Serial.begin(115200);
button.begin(); // Invoke the begin function once for calibration.
// button.begin(0); // GPIO can be initialized here as well.
// Invoke a relevant callback function to handle presses.
button.onSinglePress([]() {
Serial.println("onSinglePress");
});
}
void loop() {
button.async(); // Invoke the async function inside the RTOS loop.
}
Toggle button mode (will automatically disable push button modes):
onToggle();
Push button mode (won't work if onToogle is invoked):
onSinglePress();
onDoublePress();
onTripplePress();
onLongPress();
Live repeat key press detection (won't work if onToogle is invoked):
onRepeatPress();
Make sure these softwares are installed:
-
Python: Required for PlatformIO core to run.
-
Visual Studio Code: Required for PlatformIO core to run.
-
PlatformIO IDE: Required for the project to compile.
Follow these steps to setup the project:
-
VS Code > PlatformIO > New Project > Example.
-
Open the platformio.ini file and add this:
[env:esp32dev]
lib_deps =
https://github.com/iarghadip/Button
Follow these documents to stay informed:
-
This project is licensed under the terms of the MIT License.
-
All notable changes to this project will be documented in the CHANGELOG file.
-
All known issues, bugs, and feature requests are tracked in the Issues section.