first commit

This commit is contained in:
jaksatomovic 2024-03-06 12:40:28 +01:00
commit 868b14f8c8
286 changed files with 59925 additions and 0 deletions

View file

@ -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();
}
/////////////////////////////////////////////////////////////////