From 0fb5c9877ff5361f953a3c6b0f635c4ee54e3343 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 17 Aug 2020 12:35:12 -0500 Subject: [PATCH] CircuitPython_SharpDisplay_Displayio: work around a displaytext bug --- CircuitPython_SharpDisplay_Displayio/code.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/CircuitPython_SharpDisplay_Displayio/code.py b/CircuitPython_SharpDisplay_Displayio/code.py index c3f3ec5d9..b076b741c 100644 --- a/CircuitPython_SharpDisplay_Displayio/code.py +++ b/CircuitPython_SharpDisplay_Displayio/code.py @@ -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 @@ -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 = ""