Skip to content

Commit dc81ebb

Browse files
authored
Display Bug Fixes (microsoft#297)
* get correct board ref in process_user_code * fixed slow text refresh issue * clue library text scaling issue fixed
1 parent 9d569da commit dc81ebb

4 files changed

Lines changed: 15 additions & 18 deletions

File tree

230 Bytes
Binary file not shown.

src/base_circuitpython/displayio/group.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,23 @@ def append(self, item):
3939

4040
self.__contents.append(item)
4141
item.parent = self
42+
self.elem_changed()
4243

43-
self.__elem_changed()
44-
45-
def __elem_changed(self):
44+
def elem_changed(self):
4645
# Ensure that this group is what the board is currently showing.
4746
# Otherwise, don't bother to draw it.
48-
if (
49-
self.__auto_write
50-
and self.__check_active_group_ref
51-
and board.DISPLAY.active_group == self
52-
):
47+
if self.__auto_write:
48+
self.trigger_draw()
49+
50+
def trigger_draw(self):
51+
# select the correct parent to draw from if necessary
52+
if self.__check_active_group_ref and board.DISPLAY.active_group == self:
5353
self.draw()
5454

5555
elif self.in_group:
56-
5756
# If a sub-group is modified, propagate to top level to
5857
# see if one of the parents are the current active group.
59-
self.parent.__elem_changed()
58+
self.parent.elem_changed()
6059

6160
def __getitem__(self, index):
6261
return self.__contents[index]
@@ -65,9 +64,8 @@ def __setitem__(self, index, val):
6564
old_val = self.__contents[index]
6665

6766
self.__contents[index] = val
68-
6967
if old_val != val:
70-
self.__elem_changed()
68+
self.elem_changed()
7169

7270
def draw(self, img=None, x=0, y=0, scale=None, show=True):
7371
# this function is not a part of the orignal implementation
@@ -136,5 +134,5 @@ def __len__(self):
136134
def pop(self, i=-1):
137135
item = self.__contents.pop(i)
138136
item.parent = None
139-
self.__elem_changed()
137+
self.elem_changed()
140138
return item

src/clue/adafruit_clue.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def __init__(
114114
if font:
115115
self._font = font
116116
self.text_group = displayio.Group(max_size=20, scale=text_scale)
117-
117+
self.text_scale = text_scale
118118
if title:
119119
# Fail gracefully if title is longer than 60 characters.
120120
if len(title) > 60:
@@ -129,7 +129,7 @@ def __init__(
129129
)
130130
title.x = 0
131131
title.y = 8
132-
self._y = title.y + 18
132+
self._y = title.y + 18 * text_scale
133133

134134
self.text_group.append(title)
135135
else:
@@ -153,7 +153,7 @@ def add_text_line(self, color=0xFFFFFF):
153153
text_label = self._label.Label(self._font, text="", max_glyphs=45, color=color)
154154
text_label.x = 0
155155
text_label.y = self._y
156-
self._y = text_label.y + 13
156+
self._y = text_label.y + 13 * self.text_scale
157157
self.text_group.append(text_label)
158158

159159
return text_label

src/process_user_code.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@
5252

5353
from adafruit_clue import clue
5454
from base_circuitpython.base_cp_constants import CLUE
55-
from base_circuitpython import terminal_handler
56-
from base_circuitpython import board
55+
import board
5756

5857
# get handle to terminal for clue
5958
curr_terminal = board.DISPLAY.terminal

0 commit comments

Comments
 (0)