Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit 1cf7af3

Browse files
Merge branch 'dev' into users/t-xunguy/clue-sensors
2 parents fa9154d + dc81ebb commit 1cf7af3

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed
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
@@ -115,7 +115,7 @@ def __init__(
115115
if font:
116116
self._font = font
117117
self.text_group = displayio.Group(max_size=20, scale=text_scale)
118-
118+
self.text_scale = text_scale
119119
if title:
120120
# Fail gracefully if title is longer than 60 characters.
121121
if len(title) > 60:
@@ -130,7 +130,7 @@ def __init__(
130130
)
131131
title.x = 0
132132
title.y = 8
133-
self._y = title.y + 18
133+
self._y = title.y + 18 * text_scale
134134

135135
self.text_group.append(title)
136136
else:
@@ -154,7 +154,7 @@ def add_text_line(self, color=0xFFFFFF):
154154
text_label = self._label.Label(self._font, text="", max_glyphs=45, color=color)
155155
text_label.x = 0
156156
text_label.y = self._y
157-
self._y = text_label.y + 13
157+
self._y = text_label.y + 13 * self.text_scale
158158
self.text_group.append(text_label)
159159

160160
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)