Open Gibol opened 1 year ago
There is a problem in your commit: if this is not ESP32/ESP8266/STM32 platform then Wire.begin()
will not be executed and the library will be broken for other platforms.
It is better to do like this:
void ArduinoI2c::begin()
{
#if defined(ESP8266) || defined(ESP32) || defined(ESP31B) || defined(ARDUINO_ARCH_STM32)
if ( (m_scl >= 0) && (m_sda >= 0) )
{
#if defined(ESP8266) || defined(ESP32) || defined(ESP31B)
Wire.begin(m_sda, m_scl);
#elif defined(ARDUINO_ARCH_STM32)
// Wire.begin(m_sda, m_scl) does not work for stm32duino core
Wire.setSCL(m_scl);
Wire.setSDA(m_sda);
Wire.begin();
#endif
}
else
#endif
{
Wire.begin();
}
#ifdef SSD1306_WIRE_CLOCK_CONFIGURABLE
Wire.setClock(400000);
#endif
}
This change allows i2c displays to work with non-default i2c pins on STM32. Tested on custom board with STM32F072C8T6 and SH1106 128x64 display with I2C2 peripheral on PB10 and PB11