Skip to content

Update to CP 10 with busdisplay #38

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

Merged
merged 3 commits into from
Apr 4, 2025

Conversation

Neradoc
Copy link
Contributor

@Neradoc Neradoc commented Apr 2, 2025

displayio.Display was deprecated in 9 and removed in 10.

Traceback (most recent call last):
  File "code.py", line 34, in <module>
  File "/lib/adafruit_bitmapsaver.py", line 34, in <module>
ImportError: can't import name Display

This removes compatibility with Circuitpython 8 and earlier.

Copy link
Contributor

@FoamyGuy FoamyGuy 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 for the fix!

I think adding this in docs/api.rst should fix the actions error. Similar to this one: https://github.com/adafruit/Adafruit_CircuitPython_SSD1681/blob/58e49d44dab693728c1515a8092faa5b9469a869/docs/api.rst?plain=1#L7-L8

API Reference
#############

@@ -177,7 +180,7 @@ def save_pixels(
raise ValueError(
"Third argument must be a Palette or ColorConverter for a Bitmap save"
)
elif not isinstance(pixel_source, Display):
elif not isinstance(pixel_source, BusDisplay):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
elif not isinstance(pixel_source, BusDisplay):
elif not isinstance(pixel_source, (BusDisplay, FramebufferDisplay)):

Please add FramebufferDisplay here as well, it hasfill_row() and is supported by this library too.

It will need to import it as well

from framebufferio import FramebufferDisplay

@Neradoc Neradoc force-pushed the displayio-to-busdisplay branch from eae737d to b75aac8 Compare April 2, 2025 12:46
@Neradoc
Copy link
Contributor Author

Neradoc commented Apr 2, 2025

Oh I didn't do a local sphinx build. It complained about busdisplay too, it passes now.

I'm actually not a big fan of testing for isinstance and also importing unconditionally. What if a board has busdisplay but not framebufferio ? Like those 30 boards:
https://docs.circuitpython.org/en/latest/shared-bindings/support_matrix.html?filter=busdisplay&filter=-framebufferio

Can we test for hasattr("fill_row") instead ?

@FoamyGuy
Copy link
Contributor

FoamyGuy commented Apr 2, 2025

@Neradoc yes, hasattr("fill_row") is good with me. If we change all of the isinstance to hasattr it looks like the only remaining usages of BusDisplay are for type annotations. We could move both BusDisplay and FramebufferDisplay imports into the block guarded by try: import typing so they don't get imported at all when running on mcu.

@Neradoc
Copy link
Contributor Author

Neradoc commented Apr 2, 2025

I think it's good now. I tested it on a board with builtin display only though.

screenshot-20250402-143635

@tannewt tannewt requested a review from FoamyGuy April 4, 2025 17:58
Copy link
Contributor

@FoamyGuy FoamyGuy 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! This looks good to me.

@FoamyGuy FoamyGuy merged commit 29ce41e into adafruit:main Apr 4, 2025
1 check passed
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Apr 5, 2025
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