mirror of
https://github.com/jaksatomovic/esp32-clickwheel.git
synced 2025-08-26 22:58:30 -04:00
first commit
This commit is contained in:
commit
868b14f8c8
286 changed files with 59925 additions and 0 deletions
55
lib/Button2/examples/MultiHandler/MultiHandler.ino
Normal file
55
lib/Button2/examples/MultiHandler/MultiHandler.ino
Normal file
|
@ -0,0 +1,55 @@
|
|||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Button2.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
#define BUTTON_PIN 2
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
Button2 button;
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(50);
|
||||
Serial.println("\n\nMulti Handler Demo");
|
||||
|
||||
button.begin(BUTTON_PIN);
|
||||
button.setClickHandler(handler);
|
||||
// button.setLongClickHandler(handler); // this will only be called upon release
|
||||
button.setLongClickDetectedHandler(handler); // this will only be called upon detection
|
||||
button.setDoubleClickHandler(handler);
|
||||
button.setTripleClickHandler(handler);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
void loop() {
|
||||
button.loop();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
void handler(Button2& btn) {
|
||||
switch (btn.getType()) {
|
||||
case single_click:
|
||||
break;
|
||||
case double_click:
|
||||
Serial.print("double ");
|
||||
break;
|
||||
case triple_click:
|
||||
Serial.print("triple ");
|
||||
break;
|
||||
case long_click:
|
||||
Serial.print("long");
|
||||
break;
|
||||
}
|
||||
Serial.print("click");
|
||||
Serial.print(" (");
|
||||
Serial.print(btn.getNumberOfClicks());
|
||||
Serial.println(")");
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////
|
Loading…
Add table
Add a link
Reference in a new issue