Skip to content

Commit 2ff5676

Browse files
committed
not sure why but sometimes the group pop fails when updating text. also patching so we can use either firmware
1 parent d326154 commit 2ff5676

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

adafruit_display_text/text_area.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,17 @@ def _update_text(self, new_text):
9191
# TODO(tannewt): Make this smarter when we can remove and add things into the middle
9292
# of a group.
9393
for _ in range(len(self.sprites) - i):
94-
self.group.pop()
94+
try:
95+
self.group.pop()
96+
except IndexError:
97+
break
9598
first_different = False
9699
if not first_different:
97-
face = displayio.TileGrid(glyph["bitmap"], pixel_shader=self.p,
98-
position=(self._x + x, self._y + y + self.height - glyph["bounds"][1] - glyph["bounds"][3]))
100+
position = (self._x + x, self._y + y + self.height - glyph["bounds"][1] - glyph["bounds"][3])
101+
try:
102+
face = displayio.TileGrid(glyph["bitmap"], pixel_shader=self.p, position=position)
103+
except:
104+
face = displayio.Sprite(glyph["bitmap"], pixel_shader=self.p, position=position)
99105
self.group.append(face)
100106
self.sprites[i] = face
101107
x += glyph["shift"][0]

0 commit comments

Comments
 (0)