Closed ksuszka closed 5 years ago
There are I2C implementations for some boards that don't use the type TwoWire. The current implementation does not depend on the type of Wire.
I want to try to allow both alternate type and port/bus. I have seen libraries that use a template to do this. See this.
I will experiment with the template idea. This will also allow software I2C implementations and optimized hardware implementations.
Please try the update that allows I2C port selection.
I decided to add a configuration option MULTIPLE_I2C_PORTS. The default is nonzero except for AVR boards.
This allows any board with a problem to use the old code. It saves some flash and a tiny bit of SRAM on AVR.
I changed m_wire to m_oledWire since I am using this define when MULTIPLE_I2C_PORTS is zero. A bit less likely to already be defined.
#define m_oledWire Wire
I use decltype(Wire) instead of TwoWire in case Wire is not type TwoWire.
I tried some other Ideas to avoid the define but had problems with a board package called MightyCore.
I just checked your version and it works for me. Thanks for this fix!
I'm using this library with stm32 based board which has two i2c buses. I've added ability to initialize SSD1306AsciiWire object with specific instance of TwoWire library.