Skip to content

CircuitPython_SharpDisplay_Displayio: work around a displaytext bug #1210

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 2 commits into from
Aug 17, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions CircuitPython_SharpDisplay_Displayio/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def sample(population, k):
# if necessary
displayio.release_displays()
bus = board.SPI()
framebuffer = sharpdisplay.SharpMemoryFramebuffer(bus, board.D2, 400, 240)
framebuffer = sharpdisplay.SharpMemoryFramebuffer(bus, board.D6, 400, 240)
display = framebufferio.FramebufferDisplay(framebuffer, auto_refresh = True)

# Load our font
Expand Down Expand Up @@ -231,7 +231,15 @@ def sample(population, k):
print(name)
lines = name.split(" ")
with BatchDisplayUpdate(display):
names_font[0].text = lines[0]
names_font[1].text = lines[1]
for i in range(2):
names_font[i].text = lines[i]

# Due to a bug in adafruit_display_text, we need to reestablish
# the position of the labels when updating them.
# Once https://github.com/adafruit/Adafruit_CircuitPython_Display_Text/issues/82
# has been resolved, this code will no longer be necessary (but
# will not be harmful either)
names_font[i].anchor_point = (0.5, 0)
names_font[i].anchored_position = (200, i*84+42)
time.sleep(5)
names_font[0].text = names_font[1].text = ""