Skip to content

Commit a88cf05

Browse files
committed
added docs
1 parent af50a27 commit a88cf05

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ _ezb.Subscribe(BTN_3, Btn3Hold, HOLD);
9191
_ezb.Subscribe(BTN_3, Btn3Release, RELEASED);
9292
_ezb.Subscribe(BTN_4, Btn4Hold, HOLD);
9393
_ezb.Subscribe(BTN_4, Btn4Release, RELEASED);
94+
95+
//or you can pass lambda functions
96+
_ezb.Subscribe(BTN_4, []() {
97+
//...
98+
}, HOLD);
99+
_ezb.Subscribe(BTN_4, [](int index) {
100+
//index will be the index of the button triggering the event
101+
//...
102+
}, RELEASED);
94103
```
95104
> [!IMPORTANT]
96105
> `button index` stands for an array inside EZButton that holds your button states and IS NOT PIN of the button.
@@ -115,7 +124,18 @@ void loop()
115124
_ezb.Loop();
116125
}
117126
```
127+
8. Define Event Functions that was used in Subscriptions (step 5)
128+
``` C++
129+
void Btn1HoldRelease(){
130+
//...
131+
}
118132

133+
// you can also get the button index
134+
void Btn2Release(int index){
135+
//...
136+
}
137+
//...
138+
```
119139
### Debugging
120140
> [!TIP]
121141
> To enable debugging, you need to add the `-DEZBUTTON_DEBUG` parameter to your `build_flags`.

0 commit comments

Comments
 (0)