Skip to content

Commit 56b7ed6

Browse files
use twowire
1 parent 6f64815 commit 56b7ed6

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

MultiPlexer_TCA9548A/MultiPlexer_TCA9548A.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,22 @@
44

55
#include "MultiPlexer_TCA9548A.h"
66

7+
TwoWire twire = TwoWire(1);
8+
79
MultiPlexer_TCA9548A::MultiPlexer_TCA9548A(int i2c_addr) {
810
_mux = new TCA9548A(i2c_addr);
911
}
1012

11-
void MultiPlexer_TCA9548A::begin() {
12-
_mux->begin(Wire); // TwoWire instance can be passed here as 3rd argument
13-
_mux->closeAll(); // Set a base state which we know (also the default state on power on)
14-
changeBus(0); // tell the TCA9548A we want to use I2C bus number zero (to talk to the OLED)
13+
void MultiPlexer_TCA9548A::begin(int sda_pin, int scl_pin) {
14+
_mux->begin(twire, sda_pin, scl_pin);
15+
16+
// set a base state which we know (also the default state on power on)
17+
_mux->closeAll();
18+
19+
// tell the TCA9548A we want to use I2C bus number zero (to talk to the OLED)
20+
openChannel(0);
1521
}
1622

17-
void MultiPlexer_TCA9548A::changeBus(uint8_t bus_nr) {
23+
void MultiPlexer_TCA9548A::openChannel(uint8_t bus_nr) {
1824
_mux->openChannel(bus_nr);
1925
}

MultiPlexer_TCA9548A/MultiPlexer_TCA9548A.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class MultiPlexer_TCA9548A
1212
{
1313
public:
1414
MultiPlexer_TCA9548A(int i2c_addr = 0x70);
15-
void begin();
16-
void changeBus(uint8_t bus_nr);
15+
void begin(int sda_pin, int scl_pin);
16+
void openChannel(uint8_t bus_nr);
1717

1818
private:
1919
TCA9548A* _mux;

0 commit comments

Comments
 (0)