Skip to content

Added terminalio font support and scaling #86

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 23, 2020

Conversation

makermelissa
Copy link
Collaborator

Fixes #72.

@makermelissa makermelissa requested a review from a team October 8, 2020 21:55
@makermelissa
Copy link
Collaborator Author

The reason I added scaling into this PR (backported from MatrixPortal) is because the terminalio font at default size is very small.

@tannewt
Copy link
Member

tannewt commented Oct 9, 2020

Could we share the graphics bits of the two portal libraries instead of backporting between the two?

@makermelissa
Copy link
Collaborator Author

Maybe, but the graphics are dealt with quite differently due to the different display sizes. For instance, I have a scrolling type for the Matrix that isn't needed with the PyPortal.

@@ -399,6 +407,9 @@ def __init__(
self._text_wrap[i] = text_wrap[i]
self._text_maxlen[i] = text_maxlen[i]
self._text_transform[i] = text_transform[i]
if not isinstance(text_scale[i], (int, float)) or text_scale[i] < 1:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested these changes and I am getting and I'm getting an exception from this line:

Traceback (most recent call last):
  File "code.py", line 80, in <module>
  File "/lib/adafruit_pyportal.py", line 410, in __init__
TypeError: 'int' object is not subscriptable

I'm using the code from the quotes example here: https://learn.adafruit.com/adafruit-pyportal/parsing-json. I tried with the code as-is, and with the new text_scale parameter added, I'm getting same results both ways.

Copy link
Contributor

@FoamyGuy FoamyGuy Oct 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to get past this error by adding a check for text_scale type inside the body of the if statement at line 368 of the modified code. Now mine looks like:

if isinstance(text_position[0], (list, tuple)):
    num = len(text_position)
    if not text_wrap:
        text_wrap = [0] * num
    if not text_maxlen:
        text_maxlen = [0] * num
    if not text_transform:
        text_transform = [None] * num
    if isinstance(text_scale, int):  # new check for text scale
        text_scale = [text_scale] * num

@tannewt
Copy link
Member

tannewt commented Oct 12, 2020

Maybe, but the graphics are dealt with quite differently due to the different display sizes. For instance, I have a scrolling type for the Matrix that isn't needed with the PyPortal.

kk, maybe it's the network stuff we should be sharing. It makes sense the graphics would be different.

@makermelissa
Copy link
Collaborator Author

Thanks @FoamyGuy, I updated the code.

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with the newest commits and it's working well now.

Looks good to me. Thanks for this new feature @makermelissa

@makermelissa makermelissa merged commit 6511953 into adafruit:master Oct 23, 2020
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Oct 28, 2020
Updating https://github.com/adafruit/Adafruit_CircuitPython_MONSTERM4SK to 0.0.1 from b9f1195:
  < Merge pull request adafruit/Adafruit_CircuitPython_MONSTERM4SK#2 from FoamyGuy/main
  < Merge pull request adafruit/Adafruit_CircuitPython_MONSTERM4SK#1 from FoamyGuy/main
  < fixing a few things in setup py
  < adding rainbow star example. implementing buttons property in the library
  < remove pypi upload from actions

Updating https://github.com/adafruit/Adafruit_CircuitPython_PyPortal to 3.6.0 from 3.5.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#86 from makermelissa/terminalio

Updating https://github.com/adafruit/Adafruit_CircuitPython_VCNL4010 to 0.10.4 from 0.10.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_VCNL4010#14 from gpshead/typo-proxinity

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Added the following libraries: Adafruit_CircuitPython_EMC2101, Adafruit_CircuitPython_MONSTERM4SK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default param for text_font
3 participants