ThingPulse / esp8266-oled-ssd1306

Driver for the SSD1306 and SH1106 based 128x64, 128x32, 64x48 pixel OLED display running on ESP8266/ESP32
https://thingpulse.com
Other
1.98k stars 636 forks source link

Update SH1106Wire.h to fix sda != -1 #348

Closed mengguang closed 3 years ago

mengguang commented 3 years ago

Change sda and scl to int type, so sda != -1 works.

marcelstoer commented 3 years ago

Thanks for this suggestion. Can you please explain your use case.

mengguang commented 3 years ago

If I want to skip Wire.begin in the display library , I should write:

SH1106Wire display(OLED_I2C_ADDR, -1, -1);

or

SH1106Wire display(OLED_I2C_ADDR);

But :
_sda is type of uint8_t then: _sda = -1 give sda == 255
so sda != -1 return true and the library will call Wire.begin.
BTW: SSD1306Wire works fine this way already.