robert-hh / SH1106

MicroPython driver for the SH1106 OLED controller
Other
157 stars 38 forks source link

AttributeError: 'str' object has no attribute 'init' #8

Closed bgolab closed 4 years ago

bgolab commented 4 years ago

MicroPython v1.11 on 2019-05-29; PYBv1.0 with STM32F405RG Type "help()" for more information.

from machine import I2C, Pin i2c=I2C(1) i2c.scan() [76] import sh1106

display = sh1106.SH1106_I2C(128,32, i2c, 'none', 76) Traceback (most recent call last): File "", line 1, in File "sh1106.py", line 176, in init AttributeError: 'str' object has no attribute 'init'

robert-hh commented 4 years ago

Obviously not. The parameter has to be just None, not a string. But I agree that the documentation is confusing.

bgolab commented 4 years ago

ok. ssd1306 works fine

from machine import I2C, Pin i2c=I2C(1) i2c.scan() [60, 76] import ssd1306 oled=ssd1306.SSD1306_I2C(128,32,i2c,60) oled.text('ala', 1, 1, 1) oled.show()

but (after re-powering the board to clear the I2C state):

from machine import I2C, Pin i2c=I2C(1) i2c.scan() [60, 76] import sh1106 display = sh1106.SH1106_I2C(128,32, i2c, None,60) Traceback (most recent call last): File "", line 1, in File "sh1106.py", line 177, in init File "sh1106.py", line 111, in init File "sh1106.py", line 117, in init_display File "sh1106.py", line 151, in show File "sh1106.py", line 190, in sw_write_data OSError: I2C operation not supported

I need to dig it deeper...

robert-hh commented 4 years ago

Are you using a SH1106 or an SSD1306? And which board are you using?

bgolab commented 4 years ago

I use SH1106 (at least the vendor claims that). That's why I need to investigate it deeper.

I started with your driver, then switched to SSD1306 which works fine.