File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff 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
2531void 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);
You can’t perform that action at this time.
0 commit comments