Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deinit the reset pin when displayio.I2CDisplay fails #7563

Merged
merged 1 commit into from
Feb 13, 2023

Conversation

Neradoc
Copy link

@Neradoc Neradoc commented Feb 10, 2023

Fixes an issue when displayio.I2CDisplay raises an exception because of a bad address for example. The reset pin (if any) remains "never reset" (ironically) and raises a "pin in use" error on subsequent reloads.

Deinits self before raising the exception.
Is this the right way to do that ? Or should it just deinit the resest pin (if set).

Example code:

import board
import displayio
import adafruit_displayio_ssd1306

displayio.release_displays()
reset = board.D9

i2c = board.I2C()
bus = displayio.I2CDisplay(i2c, device_address=0, reset=reset)
display = adafruit_displayio_ssd1306.SSD1306(bus, width=128, height=64)

Output defore the fix:

code.py output:
Traceback (most recent call last):
  File "code.py", line 12, in <module>
ValueError: Unable to find I2C Display at 0

Code done running.

Press any key to enter the REPL. Use CTRL-D to reload.

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Traceback (most recent call last):
  File "code.py", line 12, in <module>
ValueError: D9 in use

Code done running.

Press any key to enter the REPL. Use CTRL-D to reload.

@tannewt tannewt changed the base branch from main to 8.0.x February 10, 2023 16:53
@tannewt tannewt changed the base branch from 8.0.x to main February 10, 2023 16:53
@tannewt
Copy link
Member

tannewt commented Feb 10, 2023

Would you mind switching this change to 8.0.x (using rebase and then changing the base here) so that we can release it sooner? Thanks!

@tannewt tannewt added this to the 8.0.x milestone Feb 10, 2023
@Neradoc Neradoc force-pushed the deinit-i2cdisplay-reset-on-raise branch from 2ccfa57 to 7ba196c Compare February 10, 2023 18:50
@Neradoc Neradoc changed the base branch from main to 8.0.x February 10, 2023 18:51
@Neradoc Neradoc changed the base branch from 8.0.x to main February 10, 2023 18:55
@Neradoc Neradoc changed the base branch from main to 8.0.x February 10, 2023 18:55
@Neradoc Neradoc force-pushed the deinit-i2cdisplay-reset-on-raise branch from 7ba196c to 3c93594 Compare February 10, 2023 18:56
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@tannewt tannewt merged commit 1af2b6a into adafruit:8.0.x Feb 13, 2023
@Neradoc Neradoc deleted the deinit-i2cdisplay-reset-on-raise branch March 19, 2023 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants