-
Notifications
You must be signed in to change notification settings - Fork 25
adding support for PyPortal and a simpletest example. #33
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
Changes from 1 commit
31da0f4
4e4ca4d
69851ec
540411a
dbaba83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2020 Kattni Rembor for Adafruit Industries | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
""" | ||
`adafruit_pybadger.pyportal` | ||
================================================================================ | ||
|
||
Badge-focused CircuitPython helper library for PyPortal. | ||
|
||
|
||
* Author(s): Kattni Rembor | ||
|
||
Implementation Notes | ||
-------------------- | ||
|
||
**Hardware:** | ||
|
||
* `Adafruit PyPortal <https://www.adafruit.com/product/4116>`_ | ||
|
||
**Software and Dependencies:** | ||
|
||
* Adafruit CircuitPython firmware for the supported boards: | ||
https://github.com/adafruit/circuitpython/releases | ||
|
||
""" | ||
|
||
import audioio | ||
from adafruit_pybadger.pybadger_base import PyBadgerBase | ||
|
||
__version__ = "0.0.0-auto.0" | ||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PyBadger.git" | ||
|
||
|
||
class PyPortal(PyBadgerBase): | ||
"""Class that represents a single PyPortal.""" | ||
|
||
_audio_out = audioio.AudioOut | ||
_neopixel_count = 1 | ||
|
||
@property | ||
def _unsupported(self): | ||
"""This feature is not supported on PyPortal.""" | ||
raise NotImplementedError("This feature is not supported on PyPortal.") | ||
|
||
# The following is a list of the features available in other PyBadger modules but | ||
# not available for PyPortal. If called while using a PyPortal, they will result in the | ||
# NotImplementedError raised in the property above. | ||
play_file = _unsupported | ||
light = _unsupported | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They PyPortal also has a light sensor. Can't it be supported? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Weird. The following line does dim down the screen. I've tested it in a pybadge and the behavior seems the same. pybadger.auto_dim_display() Note: The dim code acts weird by itself. If you change the environment of both boards, they don't seem to react to it. It looks like it only changes the backlight once, even if it's on the loops. But seems like something for another bug request. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I think we can support the light sensor. I will work on adding that today. I think the auto_dim functionality uses the accelerometer in the PyBadge to check for movement and dim the display when there hasn't been any. The PyPortals do not have one so we won't be able to have it work the same way, but perhaps could be adapted to use touch or something else. |
||
button = _unsupported | ||
|
||
|
||
pyportal = PyPortal() # pylint: disable=invalid-name | ||
"""Object that is automatically created on import.""" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
"""Simpletest examaple using Adafruit PyPortal. Uses the touchscreen to advance between examples.""" | ||
import board | ||
from adafruit_pybadger import pybadger | ||
import adafruit_touchscreen | ||
|
||
# pylint: disable=invalid-name | ||
|
||
# These pins are used as both analog and digital! XL, XR and YU must be analog | ||
# and digital capable. YD just need to be digital | ||
ts = adafruit_touchscreen.Touchscreen( | ||
board.TOUCH_XL, | ||
board.TOUCH_XR, | ||
board.TOUCH_YD, | ||
board.TOUCH_YU, | ||
calibration=((5200, 59000), (5800, 57000)), | ||
size=(320, 240), | ||
) | ||
|
||
pybadger.show_badge( | ||
name_string="Blinka", hello_scale=2, my_name_is_scale=2, name_scale=3 | ||
) | ||
|
||
cur_example = 0 | ||
prev_touch = None | ||
while True: | ||
p = ts.touch_point | ||
if p and not prev_touch: | ||
cur_example += 1 | ||
if cur_example >= 3: | ||
cur_example = 0 | ||
print(cur_example) | ||
prev_touch = p | ||
|
||
if cur_example == 0: | ||
pybadger.show_business_card( | ||
image_name="Blinka.bmp", | ||
name_string="Blinka", | ||
name_scale=2, | ||
email_string_one="blinka@", | ||
email_string_two="adafruit.com", | ||
) | ||
elif cur_example == 1: | ||
pybadger.show_qr_code(data="https://circuitpython.org") | ||
elif cur_example == 2: | ||
pybadger.show_badge( | ||
name_string="Blinka", hello_scale=2, my_name_is_scale=2, name_scale=3 | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is play_file unsupported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't left unsupported for a specific reason. I started the PyPortal class with a copy of the existing CLUE class and it got brought in as unsupported from there. I just didn't have time to work on adding it after the display stuff was working before I went to bed last night.
I will add some more commits today to add the other functionalities that are possible on this hardware.
Looking back in the CLUE file now it is setting up an AudioPWMOut object but then setting play_file as unsupported. That seems odd to me at first glance, but maybe there is a reason. I'll poke around a bit today.