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

rgbmatrix: Avoid leaving an incompletely configured display bus #9865

Merged
merged 3 commits into from
Dec 5, 2024

Conversation

jepler
Copy link
Member

@jepler jepler commented Dec 4, 2024

I did not reproduce the exact problem reported; however, I reproduced that a failure to construct an RGBMatrix object would leave CircuitPython in an inconsistent state with a display bus registered but not working:

>>> import rgbmatrix, board; rgbmatrix.RGBMatrix(width=64, bit_depth=1, rgb_pins=[], addr_pins=[], clock_pin=board.A0, latch_pin=board.A1, output_enable_pin=board.A2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: The length of rgb_pins must be 6, 12, 18, 24, or 30
>>> import rgbmatrix, board; rgbmatrix.RGBMatrix(width=64, bit_depth=1, rgb_pins=[], addr_pins=[], clock_pin=board.A0, latch_pin=board.A1, output_enable_pin=board.A2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: Too many display busses; forgot displayio.release_displays() ?

After the fix the second call also results in a ValueError, not a RuntimeError, which is correct.

Closes #9674

I did not reproduce the exact problem reported; however, I reproduced
that a failure to construct an RGBMatrix object would leave CircuitPython
in an inconsistent state with a display bus registered but not working:

```py
>>> import rgbmatrix, board; rgbmatrix.RGBMatrix(width=64, bit_depth=1, rgb_pins=[], addr_pins=[], clock_pin=board.A0, latch_pin=board.A1, output_enable_pin=board.A2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: The length of rgb_pins must be 6, 12, 18, 24, or 30
>>> import rgbmatrix, board; rgbmatrix.RGBMatrix(width=64, bit_depth=1, rgb_pins=[], addr_pins=[], clock_pin=board.A0, latch_pin=board.A1, output_enable_pin=board.A2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: Too many display busses; forgot displayio.release_displays() ?
```

After the fix the second call also results in a ValueError, not a
RuntimeError, which is correct.

Closes adafruit#9674
dhalbert
dhalbert previously approved these changes Dec 4, 2024
Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

Nice solution.

.. as was already done for metro m4 express.

Soon we're likely to need to do this across the board for 512kB flash
SAMD51 parts.
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.

Exceptions in adafruit_matrixportal.matrix.Matrix constructor crash MatrixPortal M4
2 participants