SimButton
SimButton gère les boutons poussoirs avec debounce matériel et logiciel.
Configuration
Section intitulée « Configuration »- Mode :
INPUT_PULLUP(résistance de tirage interne) - Logique : actif LOW (bouton connecté entre GPIO et GND)
- Debounce : 50 ms
Utilisation
Section intitulée « Utilisation »#include <SimButton.h>
SimButton btnPower(GPIO_NUM_1); // Bouton marche/arrêtSimButton btnShock(GPIO_NUM_2); // Bouton choc
void setup() { btnPower.begin(); btnShock.begin();
btnPower.onPress([]() { // Action au clic Serial.println("Power pressed"); });
btnPower.onLongPress(2000, []() { // Action après 2 secondes Serial.println("Power long press"); });}
void loop() { btnPower.update(); btnShock.update();}Événements supportés
Section intitulée « Événements supportés »| Événement | Méthode | Description |
|---|---|---|
| Press | onPress(callback) | Appui bref (< 500ms) |
| Long press | onLongPress(ms, callback) | Maintien prolongé |
| Release | onRelease(callback) | Relâchement du bouton |
| Double press | onDoublePress(callback) | Double appui rapide |