mirror of
https://github.com/jaksatomovic/esp32-clickwheel.git
synced 2025-08-26 06:48:28 -04:00
first commit
This commit is contained in:
commit
868b14f8c8
286 changed files with 59925 additions and 0 deletions
|
@ -0,0 +1,53 @@
|
|||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Button2.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
#define BUTTON_PIN_1 3
|
||||
#define BUTTON_PIN_2 4
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
Button2 button_1, button_2;
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(50);
|
||||
Serial.println("\n\nMulti Handler Demo w/ 2 buttons");
|
||||
|
||||
button_1.begin(BUTTON_PIN_1);
|
||||
button_1.setClickHandler(handler);
|
||||
button_1.setDoubleClickHandler(handler);
|
||||
|
||||
button_2.begin(BUTTON_PIN_2);
|
||||
button_2.setClickHandler(handler);
|
||||
button_2.setDoubleClickHandler(handler);
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
void loop() {
|
||||
button_1.loop();
|
||||
button_2.loop();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
void handler(Button2& btn) {
|
||||
switch (btn.getType()) {
|
||||
case single_click:
|
||||
break;
|
||||
case double_click:
|
||||
Serial.print("double ");
|
||||
break;
|
||||
}
|
||||
Serial.print("click ");
|
||||
Serial.print("on button #");
|
||||
Serial.print((btn == button_1) ? "1" : "2");
|
||||
Serial.println();
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////
|
Loading…
Add table
Add a link
Reference in a new issue