Skip to content

Commit c085bb1

Browse files
authored
Merge pull request #27 from makermelissa/master
Updated README and added text_scale parameter for labels
2 parents 5284071 + 1bf7658 commit c085bb1

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

README.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Introduction
1717
:target: https://github.com/psf/black
1818
:alt: Code Style: Black
1919

20-
Helper library for the Adafruit RGB Matrix Shield + Metro M4 Airlift Lite.
20+
CircuitPython helper for Adafruit MatrixPortal M4, Adafruit RGB Matrix Shield + Metro M4 Airlift Lite,
21+
and Adafruit RGB Matrix FeatherWings
2122

2223

2324
Dependencies

adafruit_matrixportal/matrixportal.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def __init__(
124124
self._text_maxlen = []
125125
self._text_transform = []
126126
self._text_scrolling = []
127+
self._text_scale = []
127128
self._scrolling_index = None
128129
self._text_font = terminalio.FONT
129130
self._text_line_spacing = []
@@ -139,6 +140,7 @@ def add_text(
139140
text_wrap=False,
140141
text_maxlen=0,
141142
text_transform=None,
143+
text_scale=1,
142144
scrolling=False,
143145
line_spacing=1.25,
144146
):
@@ -155,6 +157,7 @@ def add_text(
155157
``False``, no wrapping.
156158
:param text_maxlen: The max length of the text for text wrapping. Defaults to 0.
157159
:param text_transform: A function that will be called on the text before display
160+
:param int text_scale: The factor to scale the default size of the text by
158161
:param bool scrolling: If true, text is placed offscreen and the scroll() function is used
159162
to scroll text on a pixel-by-pixel basis. Multiple text labels with
160163
the scrolling set to True will be cycled through.
@@ -171,6 +174,9 @@ def add_text(
171174
text_maxlen = 0
172175
if not text_transform:
173176
text_transform = None
177+
if not isinstance(text_scale, (int, float)) or text_scale < 1:
178+
text_scale = 1
179+
text_scale = round(text_scale)
174180
if scrolling:
175181
text_position = (self.display.width, text_position[1])
176182

@@ -184,6 +190,7 @@ def add_text(
184190
self._text_wrap.append(text_wrap)
185191
self._text_maxlen.append(text_maxlen)
186192
self._text_transform.append(text_transform)
193+
self._text_scale.append(text_scale)
187194
self._text_scrolling.append(scrolling)
188195
self._text_line_spacing.append(line_spacing)
189196

@@ -262,11 +269,18 @@ def set_text(self, val, index=0):
262269
string = string[: self._text_maxlen[index]]
263270
print("text index", self._text[index])
264271
index_in_splash = None
272+
265273
if self._text[index] is not None:
266-
print("Replacing text area with :", string)
274+
if self._debug:
275+
print("Replacing text area with :", string)
267276
index_in_splash = self.splash.index(self._text[index])
277+
elif self._debug:
278+
print("Creating text area with :", string)
279+
268280
if len(string) > 0:
269-
self._text[index] = Label(self._text_font, text=string)
281+
self._text[index] = Label(
282+
self._text_font, text=string, scale=self._text_scale[index]
283+
)
270284
self._text[index].color = self._text_color[index]
271285
self._text[index].x = self._text_position[index][0]
272286
self._text[index].y = self._text_position[index][1]

docs/index.rst

+8-1
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,20 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26+
* Adafruit MatrixPortal M4 <https://learn.adafruit.com/adafruit-matrixportal-m4>
27+
2628
.. toctree::
2729
:caption: Related Products
2830

29-
* Adafruit Matrix Portal <https://www.adafruit.com/product/4745>
31+
* Adafruit MatrixPortal M4 <https://www.adafruit.com/product/4745>
3032
* Adafruit Metro M4 Express AirLift <https://www.adafruit.com/product/4000>
3133
* Adafruit RGB Matrix Shield <https://www.adafruit.com/product/2601>
34+
* Adafruit RGB Matrix Featherwing for M0/M4 <https://www.adafruit.com/product/3036>
35+
* Adafruit RGB Matrix FeatherWing for nrf52840 <https://www.adafruit.com/product/4702>
3236
* 64x32 RGB LED Matrix <https://www.adafruit.com/product/2278>
37+
* 16x32 RGB LED Matrix <https://www.adafruit.com/product/420>
38+
* 64x64 2.5mm pitch RGB LED Matrix <https://www.adafruit.com/product/3649>
39+
* 64x64 3mm pitch RGB LED Matrix <https://www.adafruit.com/product/4732>
3340

3441
.. toctree::
3542
:caption: Other Links

0 commit comments

Comments
 (0)