From f054b81f9aa0ad3120db4aa829f288e11374b32a Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Fri, 2 Apr 2021 12:10:30 -0700 Subject: [PATCH] Added ability to set text on add_text and added scaling --- adafruit_portalbase/__init__.py | 7 ++++++- adafruit_portalbase/graphics.py | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/adafruit_portalbase/__init__.py b/adafruit_portalbase/__init__.py index 2ac5f49..5f92b6c 100755 --- a/adafruit_portalbase/__init__.py +++ b/adafruit_portalbase/__init__.py @@ -149,6 +149,7 @@ def add_text( line_spacing=1.25, text_anchor_point=(0, 0.5), is_data=True, + text=None, ): """ Add text labels with settings @@ -202,7 +203,11 @@ def add_text( } self._text.append(text_field) - return len(self._text) - 1 + text_index = len(self._text) - 1 + if text is not None: + self.set_text(text, text_index) + + return text_index # pylint: enable=too-many-arguments diff --git a/adafruit_portalbase/graphics.py b/adafruit_portalbase/graphics.py index 964189f..9e9e414 100755 --- a/adafruit_portalbase/graphics.py +++ b/adafruit_portalbase/graphics.py @@ -41,14 +41,14 @@ class GraphicsBase: """ # pylint: disable=too-many-instance-attributes, too-many-locals, too-many-branches, too-many-statements - def __init__(self, display, *, default_bg=0x000000, debug=False): + def __init__(self, display, *, default_bg=0x000000, scale=1, debug=False): self._debug = debug self.display = display if self._debug: print("Init display") - self.splash = displayio.Group(max_size=15) + self.splash = displayio.Group(max_size=15, scale=scale) self._qr_group = None if self._debug: print("Init background")