Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified adafruit-circuitpython-display-text-DSX_CUSTOM_MAR172020.tar.gz
Binary file not shown.
24 changes: 11 additions & 13 deletions src/base_circuitpython/displayio/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,23 @@ def append(self, item):

self.__contents.append(item)
item.parent = self
self.elem_changed()

self.__elem_changed()

def __elem_changed(self):
def elem_changed(self):
# Ensure that this group is what the board is currently showing.
# Otherwise, don't bother to draw it.
if (
self.__auto_write
and self.__check_active_group_ref
and board.DISPLAY.active_group == self
):
if self.__auto_write:
self.trigger_draw()

def trigger_draw(self):
# select the correct parent to draw from if necessary
if self.__check_active_group_ref and board.DISPLAY.active_group == self:
self.draw()

elif self.in_group:

# If a sub-group is modified, propagate to top level to
# see if one of the parents are the current active group.
self.parent.__elem_changed()
self.parent.elem_changed()

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

self.__contents[index] = val

if old_val != val:
self.__elem_changed()
self.elem_changed()

def draw(self, img=None, x=0, y=0, scale=None, show=True):
# this function is not a part of the orignal implementation
Expand Down Expand Up @@ -136,5 +134,5 @@ def __len__(self):
def pop(self, i=-1):
item = self.__contents.pop(i)
item.parent = None
self.__elem_changed()
self.elem_changed()
return item
6 changes: 3 additions & 3 deletions src/clue/adafruit_clue.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def __init__(
if font:
self._font = font
self.text_group = displayio.Group(max_size=20, scale=text_scale)

self.text_scale = text_scale
if title:
# Fail gracefully if title is longer than 60 characters.
if len(title) > 60:
Expand All @@ -129,7 +129,7 @@ def __init__(
)
title.x = 0
title.y = 8
self._y = title.y + 18
self._y = title.y + 18 * text_scale

self.text_group.append(title)
else:
Expand All @@ -153,7 +153,7 @@ def add_text_line(self, color=0xFFFFFF):
text_label = self._label.Label(self._font, text="", max_glyphs=45, color=color)
text_label.x = 0
text_label.y = self._y
self._y = text_label.y + 13
self._y = text_label.y + 13 * self.text_scale
self.text_group.append(text_label)

return text_label
Expand Down
3 changes: 1 addition & 2 deletions src/process_user_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@

from adafruit_clue import clue
from base_circuitpython.base_cp_constants import CLUE
from base_circuitpython import terminal_handler
from base_circuitpython import board
import board

# get handle to terminal for clue
curr_terminal = board.DISPLAY.terminal
Expand Down