-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.ino
42 lines (37 loc) · 1.23 KB
/
example.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <Arduino.h>
#include "Button.h"
static void onButtonPressDownCb(void *button_handle, void *usr_data) {
Serial.println("Button pressed down");
}
static void onButtonPressDownRepeatCb(void *button_handle, void *usr_data)
{
Serial.println("Button press down repeat");
}
static void onButtonPressUpCb(void *button_handle, void *usr_data) {
Serial.println("Button press Up");
}
static void onButtonSingleClickCb(void *button_handle, void *usr_data) {
Serial.println("Button single click");
}
static void onButtonSingleClickRepeatCb(void *button_handle, void *usr_data)
{
Serial.println("Button single click repeat");
}
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
// initializing a button
Button *btn = new Button(GPIO_NUM_9, false);
btn->attachPressDownEventCb(&onButtonPressDownCb, NULL);
btn->attachPressUpEventCb(&onButtonPressUpCb, NULL);
btn->attachPressDownEventCb(&onButtonPressDownRepeatCb, NULL);
btn->attachSingleClickEventCb(&onButtonSingleClickCb,NULL);
btn->attachSingleClickEventCb(&onButtonSingleClickRepeatCb,NULL);
btn->unregisterPressDownEventCb(&onButtonPressDownCb);
btn->detachSingleClickEvent();
}
void loop()
{
delay(10);
}