Skip to content

Commit af50a27

Browse files
committed
added button index example
added lambda example
1 parent 069f9b2 commit af50a27

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

examples/Blink/Blink.ino

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ void setup() {
1919
_ezb.Subscribe(BTN_1, Btn1Pressed, PRESSED);
2020
_ezb.Subscribe(BTN_1, Btn1Released, RELEASED);
2121
_ezb.Subscribe(BTN_1, Btn1Hold, HOLD);
22+
//Or you can use lambda functions
23+
// _ezb.Subscribe(BTN_1, [](){Serial.println("pressed");}, PRESSED);
24+
25+
//You can also get the button index in the event
2226
_ezb.Subscribe(BTN_1, Btn1HoldReleased, HOLD_RELEASED);
27+
//Or you can use lambda functions
28+
// _ezb.Subscribe(BTN_1, [](int index){Serial.println(index);}, HOLD);
2329
}
2430

2531
void loop() {
@@ -41,7 +47,7 @@ void Btn1Hold() {
4147
digitalWrite(LED_BUILTIN, state);
4248
}
4349

44-
void Btn1HoldReleased() {
50+
void Btn1HoldReleased(int index) {
4551
for (int i = 0; i < 6; i++) {
4652
state = !state;
4753
digitalWrite(LED_BUILTIN, state);

0 commit comments

Comments
 (0)