File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ MultiPlexer_TCA9548A.h - Control TCA9548A I2C multiplexer.
3+ */
4+
5+ #include " MultiPlexer_TCA9548A.h"
6+
7+ MultiPlexer_TCA9548A::MultiPlexer_TCA9548A (int i2c_addr) {
8+ _mux = new TCA9548A (i2c_addr);
9+ }
10+
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)
15+ }
16+
17+ void MultiPlexer_TCA9548A::changeBus (uint8_t bus_nr) {
18+ _mux->openChannel (bus_nr);
19+ }
Original file line number Diff line number Diff line change 1+ /*
2+ MultiPlexer_TCA9548A.h - Control TCA9548A I2C multiplexer.
3+ */
4+ #ifndef MultiPlexer_TCA9548A_h
5+ #define MultiPlexer_TCA9548A_h
6+
7+ #include < Arduino.h>
8+ #include < Wire.h>
9+ #include < TCA9548A.h>
10+
11+ class MultiPlexer_TCA9548A
12+ {
13+ public:
14+ MultiPlexer_TCA9548A (int i2c_addr = 0x70 );
15+ void begin ();
16+ void changeBus (uint8_t bus_nr);
17+
18+ private:
19+ TCA9548A* _mux;
20+ };
21+
22+ #endif
You can’t perform that action at this time.
0 commit comments