adafruit / Adafruit_CircuitPython_DisplayIO_SSD1306

DisplayIO driver for SSD1306 monochrome OLED displays
MIT License
57 stars 24 forks source link

FeatherWing example code: "SDA in use" error #2

Closed anecdata closed 5 years ago

anecdata commented 5 years ago

• Feather M4 + OLED FeatherWing • latest S3: Adafruit CircuitPython bb04fbf on 2019-07-30; Adafruit Feather M4 Express with samd51j19 • 20190729 Library Bundle example code: displayio_ssd1306_featherwing.py

code.py output:
Traceback (most recent call last):
  File "code.py", line 7, in <module>
ValueError: SDA in use
makermelissa commented 5 years ago

This requires CircuitPython 5.0? Just checking that you are running it since you didn't specify.

anecdata commented 5 years ago

My mistake then. I know nothing of CP 5.0. Trying to get displayio OLED working. This library is in the bundle, but 'displayio.I2CDisplay' was not in 4.1.0-rc.1, so I grabbed the latest S3 build.

makermelissa commented 5 years ago

No problem. I just went to https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SSD1306 and looked at dependencies because I was pretty sure it required that. I'm not sure if it needs to be compiled locally or not. Maybe @tannewt can chime in on that since he wrote this. :)

anecdata commented 5 years ago

I can certainly wait until all the pieces shake out. I see that dependency now. Not sure how the S3 builds correspond to CP versions.

(5.0.0-alpha.0 gives me: "AttributeError: 'module' object has no attribute 'I2CDisplay'", just like 4.1.0-rc.1)

dhalbert commented 5 years ago

I am seeing "SDA in use" even on the last master as of now. It happens on a soft reload. A hard reset fixes it.

dhalbert commented 5 years ago

@tannewt Maybe the display is holding onto the I2C bus after a soft reload?

import adafruit_displayio_ssd1306
from adafruit_display_text import label
from adafruit_ble.current_time_client import CurrentTimeClient

displayio.release_displays()

i2c = board.I2C()    # <--- error here, as expected
display_bus = displayio.I2CDisplay(i2c, device_address=0x3c)
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=32)
makermelissa commented 5 years ago

I wonder if release_displays isn't working properly then. It was my understanding that it should release resources as well.

jerryneedell commented 5 years ago

FYI -- just tried on a feather_nrf52840 with OLED deatherwing and it was OK after soft reboot

>>> 
>>> 
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.

Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 5.0.0-alpha.0-45-gd99d3bd47 on 2019-07-28; Adafruit Feather nRF52840 Express with nRF52840
>>> 
>>> 
>>> import oled
>>> 
>>> 
>>> 

oled.py is just the simpletest for the featherwing

import board
import displayio
import adafruit_displayio_ssd1306

displayio.release_displays()

i2c = board.I2C()
display_bus = displayio.I2CDisplay(i2c, device_address=0x3c)
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=32)
jerryneedell commented 5 years ago

hmm - updated to current master and now I don't get any I2C error, but the display does not update with the REPL after a soft reboot. -- it does after a hard reboot

REPL does not show


Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 5.0.0-alpha.0-112-g366fdcce1 on 2019-07-31; Adafruit Feather nRF52840 Express with nRF52840
>>>
>>>
>>> import oled
>>>
>>>
>>>
>>> import board
>>> import displayio
>>> import adafruit_displayio_ssd1306
>>>
>>> displayio.release_displays()
>>>
>>>
>>> i2c = board.I2C()
>>> display_bus = displayio.I2CDisplay(i2c, device_address=0x3c)
>>> display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=32)
>>>
>>>
>>> 
>>> 
>>> 

update: after a hard reboot, the REPL continues to update -- it stop is I re-execute the script

tannewt commented 5 years ago

board.I2C() is a special case for release displays because it should be able to live forever. The subsequent board.I2C() should just return the singleton. I can look later this week. Heads down on ePaper now.

kattni commented 5 years ago

Found this issue as well. Feather M4, DS3231 RTC FeatherWing (irrelevant, error persists without addressing this device, though I initially assumed it was the presence of two devices), and OLED FeatherWing.

Tried with both busio and board.I2C().

Current code:

import time
import board
import displayio

oled = displayio.I2CDisplay(board.I2C(), device_address=0x3C)

Ran through a few iterations of this with @jerryneedell until @anecdata pointed out that it was probably this bug. @tannewt mentioned there was an I2C issue with 5.0 still, and I had forgotten until anecdata pointed it out (thank you again).

Edit: Realised after reading through this more closely, I was not using this lib. Tried code with this lib and the results are the same.