Skip to content

Commit 0fb5c98

Browse files
committed
CircuitPython_SharpDisplay_Displayio: work around a displaytext bug
1 parent 731cb29 commit 0fb5c98

File tree

1 file changed

+11
-3
lines changed
  • CircuitPython_SharpDisplay_Displayio

1 file changed

+11
-3
lines changed

CircuitPython_SharpDisplay_Displayio/code.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def sample(population, k):
153153
# if necessary
154154
displayio.release_displays()
155155
bus = board.SPI()
156-
framebuffer = sharpdisplay.SharpMemoryFramebuffer(bus, board.D2, 400, 240)
156+
framebuffer = sharpdisplay.SharpMemoryFramebuffer(bus, board.D6, 400, 240)
157157
display = framebufferio.FramebufferDisplay(framebuffer, auto_refresh = True)
158158

159159
# Load our font
@@ -231,7 +231,15 @@ def sample(population, k):
231231
print(name)
232232
lines = name.split(" ")
233233
with BatchDisplayUpdate(display):
234-
names_font[0].text = lines[0]
235-
names_font[1].text = lines[1]
234+
for i in range(2):
235+
names_font[i].text = lines[i]
236+
237+
# Due to a bug in adafruit_display_text, we need to reestablish
238+
# the position of the labels when updating them.
239+
# Once https://github.com/adafruit/Adafruit_CircuitPython_Display_Text/issues/82
240+
# has been resolved, this code will no longer be necessary (but
241+
# will not be harmful either)
242+
names_font[i].anchor_point = (0.5, 0)
243+
names_font[i].anchored_position = (200, i*84+42)
236244
time.sleep(5)
237245
names_font[0].text = names_font[1].text = ""

0 commit comments

Comments
 (0)