-
Notifications
You must be signed in to change notification settings - Fork 25
Fix business card display #20
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
Conversation
Per the release notes for CircuitPython 5.0.0 Alpha 2, calling wait_for_frame is no longer needed, and calling refresh() should accomplish the same goal. Additionally, target_frames_per_second is already set to 60 by default.
When displaying the business card, group the calls to add the background bitmap and the labels to the group in the same place in code, allowing them to display at the same time. This change has removed the black background around the labels, which appeared to be caused by a bug, since labels don't have a background color property.
Can you test on the latest stable release (4.1.2)? I don't believe display.refresh() is a function on there, which is why we have the try block. |
@makermelissa That function is in fact missing in 4.1.2. I didn't release that the latest version of the libraries supports both CircuitPython 4 and 5. Added back the try/except, and added some comments for clarity. I can remove the comments if you think they're unnecessary. |
Thanks. The comments are good. Once we're at 5.0.0 stable, we can change it so it only uses the CP5 method. :) |
Hi, tested on a PyGamer with CP 5.0 Beta 5 and it appears to draw it twice still. Black background is gone still, which is good. |
As maybe another way to do this, but 5.x only, try setting |
The label redrawing issue is fixed on CP 4.0 with this PR. However, while holding down the button on CP 5, it will continue to draw the label over and over. Maybe @caternuson's suggestion would fix it. |
My goal with this PR was to fix the double redraw / blinking when initially navigating to this screen with one button press. I think redrawing while the button is held down is OK, since I don't think holding down the button is expected user behavior. That said, I did try @caternuson's approach and it does work fine when the button is held down. Unfortunately, it made the code overly complex. I don't think it's worth complicating things if the code is temporary until CP5 is out of beta but I'm happy to put in the patch if that's what would work best for the library. Additionally, using CP5 I still had to call For reference, here's the code I tried: business_card_splash = displayio.Group(max_size=4)
self.display.show(business_card_splash)
with open(image_name, "rb") as file_name:
on_disk_bitmap = displayio.OnDiskBitmap(file_name)
face_image = displayio.TileGrid(on_disk_bitmap, pixel_shader=displayio.ColorConverter())
is_cp_version_5 = hasattr(self.display, "auto_refresh")
if is_cp_version_5:
# Temporary turn off auto refresh while we change some things
self.display.auto_refresh = False
# Add the background and the text to the splash
business_card_splash.append(face_image)
for group in business_card_label_groups:
business_card_splash.append(group)
if is_cp_version_5: # Refresh display in CircuitPython 5
self.display.auto_refresh = True
self.display.refresh()
else: # Refresh display in CircuitPython 4
self.display.wait_for_frame() Commenting out |
Ok, thanks for trying. It's still an improvement on the existing code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making these changes.
Updating https://github.com/adafruit/Adafruit_CircuitPython_BusDevice to 4.2.1 from 4.2.0: > Merge pull request adafruit/Adafruit_CircuitPython_BusDevice#45 from dhalbert/fix-end-values Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 2.4.0 from 2.3.2: > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#35 from FoamyGuy/master Updating https://github.com/adafruit/Adafruit_CircuitPython_PyBadger to 1.1.1 from 1.1.0: > Merge pull request adafruit/Adafruit_CircuitPython_PyBadger#20 from nnja/fix_business_card_display
I noticed strange behavior when using the business card function in this library.
The text would display, then hide, then display again. Additionally, the image elements wouldn't appear at the same time.
It looked like this:

I made some updates to make the text appear smoothly with the background. It now looks like this:
Notes:
wait_for_frame()
, since the release notes for CircuitPython 5.0.0 Alpha 2 say it's no longer necessary.target_frames_per_second
argument torefresh
, since that's the default value.As a side effect, the text displayed no longer has a black background. That might have been a bug in the original code, since I couldn't find a background color property on
adafruit_display_text.label
.Tested on a PyBadge LC.