File tree Expand file tree Collapse file tree 2 files changed +7
-19
lines changed
RotaryEncoderPushButtonESP32 Expand file tree Collapse file tree 2 files changed +7
-19
lines changed Original file line number Diff line number Diff line change 55#include " RotaryEncoderPushButtonESP32.h"
66
77// declared here so handler below can access
8- Method _btnPressCallback;
9- Method _btnReleaseCallback;
8+ Method _btnCallback;
109
1110void handleButtonEvent (
1211 AceButton* button,
1312 uint8_t eventType,
1413 uint8_t buttonState
1514) {
16- switch (eventType) {
17- case AceButton::kEventPressed :
18- // notify others
19- _btnPressCallback.callbackIntArg (button->getId ());
20- break ;
21- case AceButton::kEventReleased :
22- // notify others
23- _btnReleaseCallback.callbackIntArg (button->getId ());
24- break ;
25- }
15+ // notify others
16+ _btnCallback.callback2IntArg (button->getId (), eventType);
2617}
2718
2819RotaryEncoderPushButtonESP32::RotaryEncoderPushButtonESP32 (
2920 uint8_t index,
3021 int a_pin,
3122 int b_pin,
3223 int btn_pin,
33- Method btnPress_callback,
34- Method btnRelease_callback,
24+ Method btn_callback,
3525 Method encoder_callback
3626) {
3727 _pinA = a_pin;
3828 _pinB = b_pin;
3929 _btnPin = btn_pin;
40- _btnPressCallback = btnPress_callback;
41- _btnReleaseCallback = btnRelease_callback;
30+ _btnCallback = btn_callback;
4231 _encoderCallback = encoder_callback;
4332
4433 _encoder = new ESP32Encoder ();
@@ -70,7 +59,7 @@ void RotaryEncoderPushButtonESP32::loop() {
7059 _position = _value;
7160
7261 // notify others
73- _encoderCallback.callback ( );
62+ _encoderCallback.callback2IntArg (_position, rotation );
7463 }
7564}
7665
Original file line number Diff line number Diff line change @@ -20,8 +20,7 @@ class RotaryEncoderPushButtonESP32
2020 int a_pin,
2121 int b_pin,
2222 int btn_pin,
23- Method btnPress_callback,
24- Method btnRelease_callback,
23+ Method btn_callback,
2524 Method encoder_callback
2625 );
2726 void begin ();
You can’t perform that action at this time.
0 commit comments