Skip to content

Updated README and added text_scale parameter for labels #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 8, 2020
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
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ Introduction
:target: https://github.com/psf/black
:alt: Code Style: Black

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


Dependencies
Expand Down
18 changes: 16 additions & 2 deletions adafruit_matrixportal/matrixportal.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def __init__(
self._text_maxlen = []
self._text_transform = []
self._text_scrolling = []
self._text_scale = []
self._scrolling_index = None
self._text_font = terminalio.FONT
self._text_line_spacing = []
Expand All @@ -139,6 +140,7 @@ def add_text(
text_wrap=False,
text_maxlen=0,
text_transform=None,
text_scale=1,
scrolling=False,
line_spacing=1.25,
):
Expand All @@ -155,6 +157,7 @@ def add_text(
``False``, no wrapping.
:param text_maxlen: The max length of the text for text wrapping. Defaults to 0.
:param text_transform: A function that will be called on the text before display
:param int text_scale: The factor to scale the default size of the text by
:param bool scrolling: If true, text is placed offscreen and the scroll() function is used
to scroll text on a pixel-by-pixel basis. Multiple text labels with
the scrolling set to True will be cycled through.
Expand All @@ -171,6 +174,9 @@ def add_text(
text_maxlen = 0
if not text_transform:
text_transform = None
if not isinstance(text_scale, (int, float)) or text_scale < 1:
text_scale = 1
text_scale = round(text_scale)
if scrolling:
text_position = (self.display.width, text_position[1])

Expand All @@ -184,6 +190,7 @@ def add_text(
self._text_wrap.append(text_wrap)
self._text_maxlen.append(text_maxlen)
self._text_transform.append(text_transform)
self._text_scale.append(text_scale)
self._text_scrolling.append(scrolling)
self._text_line_spacing.append(line_spacing)

Expand Down Expand Up @@ -262,11 +269,18 @@ def set_text(self, val, index=0):
string = string[: self._text_maxlen[index]]
print("text index", self._text[index])
index_in_splash = None

if self._text[index] is not None:
print("Replacing text area with :", string)
if self._debug:
print("Replacing text area with :", string)
index_in_splash = self.splash.index(self._text[index])
elif self._debug:
print("Creating text area with :", string)

if len(string) > 0:
self._text[index] = Label(self._text_font, text=string)
self._text[index] = Label(
self._text_font, text=string, scale=self._text_scale[index]
)
self._text[index].color = self._text_color[index]
self._text[index].x = self._text_position[index][0]
self._text[index].y = self._text_position[index][1]
Expand Down
9 changes: 8 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,20 @@ Table of Contents
.. toctree::
:caption: Tutorials

* Adafruit MatrixPortal M4 <https://learn.adafruit.com/adafruit-matrixportal-m4>

.. toctree::
:caption: Related Products

* Adafruit Matrix Portal <https://www.adafruit.com/product/4745>
* Adafruit MatrixPortal M4 <https://www.adafruit.com/product/4745>
* Adafruit Metro M4 Express AirLift <https://www.adafruit.com/product/4000>
* Adafruit RGB Matrix Shield <https://www.adafruit.com/product/2601>
* Adafruit RGB Matrix Featherwing for M0/M4 <https://www.adafruit.com/product/3036>
* Adafruit RGB Matrix FeatherWing for nrf52840 <https://www.adafruit.com/product/4702>
* 64x32 RGB LED Matrix <https://www.adafruit.com/product/2278>
* 16x32 RGB LED Matrix <https://www.adafruit.com/product/420>
* 64x64 2.5mm pitch RGB LED Matrix <https://www.adafruit.com/product/3649>
* 64x64 3mm pitch RGB LED Matrix <https://www.adafruit.com/product/4732>

.. toctree::
:caption: Other Links
Expand Down