Skip to content

Commit a42005b

Browse files
add port arg
1 parent a8de511 commit a42005b

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

RotaryEncoderMCP23017ButtonESP32/RotaryEncoderMCP23017ButtonESP32.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,34 @@
55

66
#include "RotaryEncoderMCP23017ButtonESP32.h"
77

8-
// declared here so handler below can access
9-
Method _btnCallback;
10-
//_btnCallback.callback2IntArg(button->getId(), eventType);
11-
12-
RotaryEncoderPushButtonESP32::RotaryEncoderPushButtonESP32(
8+
RotaryEncoderMCP23017ButtonESP32::RotaryEncoderMCP23017ButtonESP32(
139
uint8_t index,
1410
int a_pin,
1511
int b_pin,
1612
int btn_pin,
1713
Method btn_callback,
1814
Method encoder_callback,
19-
MultiPlexer_MCP23017* mcp
15+
MultiPlexer_MCP23017* mcp,
16+
MCP_PORT port
2017
) {
2118
_pinA = a_pin;
2219
_pinB = b_pin;
2320
_btnPin = btn_pin;
24-
_btnCallback = btn_callback;
2521
_encoderCallback = encoder_callback;
2622

2723
_encoder = new ESP32Encoder();
28-
_button = new Button_MCP23017(_btnPin, MCP_PORT::A, mcp, _btnCallback);
24+
_button = new Button_MCP23017(_btnPin, port, mcp, btn_callback);
2925
}
3026

31-
void RotaryEncoderPushButtonESP32::begin() {
27+
void RotaryEncoderMCP23017ButtonESP32::begin() {
3228
// encoder
3329
_encoder->attachSingleEdge(_pinA, _pinB);
3430

3531
// button
3632
_button->begin();
3733
}
3834

39-
void RotaryEncoderPushButtonESP32::loop() {
35+
void RotaryEncoderMCP23017ButtonESP32::loop() {
4036
// button
4137
_button->loop();
4238

@@ -55,6 +51,6 @@ void RotaryEncoderPushButtonESP32::loop() {
5551
}
5652
}
5753

58-
int64_t RotaryEncoderPushButtonESP32::getPosition() {
54+
int64_t RotaryEncoderMCP23017ButtonESP32::getPosition() {
5955
return _encoder->getCount();
6056
}

RotaryEncoderMCP23017ButtonESP32/RotaryEncoderMCP23017ButtonESP32.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class RotaryEncoderMCP23017ButtonESP32
2222
int btn_pin,
2323
Method btn_callback,
2424
Method encoder_callback,
25-
MultiPlexer_MCP23017* mcp
25+
MultiPlexer_MCP23017* mcp,
26+
MCP_PORT port
2627
);
2728
void begin();
2829
void loop();

0 commit comments

Comments
 (0)