From 31da0f417f5e7418e0f65a8c0bbeb4d9a89a5ab3 Mon Sep 17 00:00:00 2001 From: FoamyGuy Date: Fri, 12 Jun 2020 21:23:33 -0500 Subject: [PATCH 1/9] adding support for PyPortal and simpletest example. --- adafruit_pybadger/__init__.py | 2 + adafruit_pybadger/pyportal.py | 72 +++++++++++++++++++++++ examples/pybadger_pyportal_touchscreen.py | 47 +++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 adafruit_pybadger/pyportal.py create mode 100644 examples/pybadger_pyportal_touchscreen.py diff --git a/adafruit_pybadger/__init__.py b/adafruit_pybadger/__init__.py index f4a5228..b656444 100755 --- a/adafruit_pybadger/__init__.py +++ b/adafruit_pybadger/__init__.py @@ -31,3 +31,5 @@ from .pybadge import pybadge as pybadger elif "PyGamer" in os.uname().machine: from .pygamer import pygamer as pybadger +elif "PyPortal" in os.uname().machine: + from .pyportal import pyportal as pybadger diff --git a/adafruit_pybadger/pyportal.py b/adafruit_pybadger/pyportal.py new file mode 100644 index 0000000..60841e2 --- /dev/null +++ b/adafruit_pybadger/pyportal.py @@ -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 `_ + +**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 + button = _unsupported + + +pyportal = PyPortal() # pylint: disable=invalid-name +"""Object that is automatically created on import.""" diff --git a/examples/pybadger_pyportal_touchscreen.py b/examples/pybadger_pyportal_touchscreen.py new file mode 100644 index 0000000..443d030 --- /dev/null +++ b/examples/pybadger_pyportal_touchscreen.py @@ -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 + ) From 4e4ca4d0c58ae90c34c242b5ca5ff977368b8232 Mon Sep 17 00:00:00 2001 From: FoamyGuy Date: Sat, 13 Jun 2020 10:48:33 -0500 Subject: [PATCH 2/9] fixing light and play_file for PyPortal --- adafruit_pybadger/pyportal.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/adafruit_pybadger/pyportal.py b/adafruit_pybadger/pyportal.py index 60841e2..a4ce221 100644 --- a/adafruit_pybadger/pyportal.py +++ b/adafruit_pybadger/pyportal.py @@ -42,6 +42,8 @@ """ +import board +import analogio import audioio from adafruit_pybadger.pybadger_base import PyBadgerBase @@ -55,6 +57,11 @@ class PyPortal(PyBadgerBase): _audio_out = audioio.AudioOut _neopixel_count = 1 + def __init__(self): + super().__init__() + + self._light_sensor = analogio.AnalogIn(board.LIGHT) + @property def _unsupported(self): """This feature is not supported on PyPortal.""" @@ -63,8 +70,6 @@ def _unsupported(self): # 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 button = _unsupported From 69851ece22c45f35fee19f0d9e49691561c814d1 Mon Sep 17 00:00:00 2001 From: FoamyGuy Date: Sat, 13 Jun 2020 11:05:49 -0500 Subject: [PATCH 3/9] adding a properly sized blinka bmp image for PyPortal example --- examples/Blinka_PyPortal.bmp | Bin 0 -> 42102 bytes examples/pybadger_pyportal_touchscreen.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 examples/Blinka_PyPortal.bmp diff --git a/examples/Blinka_PyPortal.bmp b/examples/Blinka_PyPortal.bmp new file mode 100644 index 0000000000000000000000000000000000000000..a547e205eeb4600f9ade52a0a78779f0115348f2 GIT binary patch literal 42102 zcmeI5e_WI0`o}L&ehex#P5c35DvE)kq9STCL?z{iQbKqLq2>(K9BK%G&drStGH?eN zcGzfRJON)oWcjVLuU03GZ)z0y&Fp}FOD(mMIT5Tpr=#aw_p_h;8uU8nkJ@&>Ua))5 zo;~b&@4D{$xit)Ljhg(j0D(@HKr2)4KO{5WtA3;OFiF@USzuKMe4=%Q#r!{1`Zo z41k#s2y^h5n^OoZaQ1@)rztSUZ4%6KodTf`F(3lwz)Z#@nEEKdT(_wJ<2+#z!xu(+ zIm2Z4*)V$S81Qjf1~7gs_&CLZ3v7ay;3=3idIkhKuY=J(0KV>P0DK;SkTKI?qiYyE zHhDa(7(Wqaxy8dW9~W3LItaqYJ_$iCFTmCj8^GJ!8$w_ggn9+Q1mDNO*LylFaZdvg zYz47vB80o`gpfy4AaZ;-1Vb6Do4f$xCN70FlS5!7NMYvmnXu6}5Ee}hfO)eSuyA4& z1WgHriL<7`lhfzJ4F4IhaqR^e~4VS7^VfxfafQ#g`^P*$afP#A{>P|0dwG) zhYms2v`sV3+D$zntKyo=Opl-cn)6ni-Xw< z7Q*X3Y*;jp2{})sz$^Z-P~f{2UVO9?qNZg)$m$W0KWQ(7E?f@T{t589-ydLSz&gm8 zkqrCbE7-8g1(q#d0z01E2q8-r!>ewsuqAXJ@Mk{^{51toL8h3AqtLsjA?kZ`8J8yoh6 zbm`Y1N_Y+G(-NU{TOw2@RDdk91FBPB1NE+0NXys>jpEVp=DIK7WWl4L+Hejuuf~C5 z>!0AQ=UYI%?J(57coLd8hoNxaE6}({1n<5U4yVL%(3F=7=jD$;)AkSHIDZeQImhAi zHm4W&mBRb`n&1OoJroud!AE&2`0j02_yp@$YUjb3!aqT4sTjT}-wBtfXW-hA zU}#sq1b>y~!nKA3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{4X`E`^An<73uDrZcAC9qA&DrAX#4WIJ3j z3q$0gs@A)Ic!>bSFtDxdQrn&(^css#@w=_ckze0U>gtw!ckc_g3BdqY@7@2~|KZ|a zy%ddESk|ZDRNmta01;t_%_{c2zHE$M#-*W&S@`MkB{%{l_YyiP!a!?GRr0;W&E&1;Ly{m8Dd~pBX{Rcn8 zaa^lP7oq1+yXsOBf7d6Eo;q{p)c*0-#V+&T|J~OpdHf>%qRP3+^vG9H{N(-n_jLCj zJh=bh!OchO43Qv7q8w^hT}rjt8^(^A>MKr-nr zj!$!6mFeRCqOtL-$bq4~cfd>9)j=vNf}VLRksYtg$dDb!fiYbiTWt)_3~+cRafT#h zRwApcGsG Date: Sat, 13 Jun 2020 12:00:00 -0500 Subject: [PATCH 4/9] starting work on pewpew m4 support --- adafruit_pybadger/__init__.py | 3 + adafruit_pybadger/pewpewm4.py | 108 ++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 adafruit_pybadger/pewpewm4.py diff --git a/adafruit_pybadger/__init__.py b/adafruit_pybadger/__init__.py index f4a5228..82bde5a 100755 --- a/adafruit_pybadger/__init__.py +++ b/adafruit_pybadger/__init__.py @@ -31,3 +31,6 @@ from .pybadge import pybadge as pybadger elif "PyGamer" in os.uname().machine: from .pygamer import pygamer as pybadger +elif "PewPew M4" in os.uname().machine: + from .pewpewm4 import pewpewm4 as pybadger + diff --git a/adafruit_pybadger/pewpewm4.py b/adafruit_pybadger/pewpewm4.py new file mode 100644 index 0000000..24e84fc --- /dev/null +++ b/adafruit_pybadger/pewpewm4.py @@ -0,0 +1,108 @@ +# 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.clue` +================================================================================ + +Badge-focused CircuitPython helper library for Pew Pew M4. + + +* Author(s): Kattni Rembor + +Implementation Notes +-------------------- + +**Hardware:** + +* `Pew Pew M4 `_ + +**Software and Dependencies:** + +* Adafruit CircuitPython firmware for the supported boards: + https://github.com/adafruit/circuitpython/releases + +""" + +from collections import namedtuple +import board +import digitalio +import audioio +from gamepad import GamePad +import adafruit_lsm6ds +from adafruit_pybadger.pybadger_base import PyBadgerBase + +__version__ = "0.0.0-auto.0" +__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PyBadger.git" + +Buttons = namedtuple("Buttons", "b a start right down up left") + + +class PewPewM4(PyBadgerBase): + """Class that represents a single Pew Pew M4.""" + + _audio_out = audioio.AudioOut + _neopixel_count = 0 + + def __init__(self): + super().__init__() + + + self._buttons = GamePad( + digitalio.DigitalInOut(board.BUTTON_A), + digitalio.DigitalInOut(board.BUTTON_B), + ) + + @property + def button(self): + """The buttons on the board. + + Example use: + + .. code-block:: python + + from adafruit_pybadger import pybadger + + while True: + if pybadger.button.a: + print("Button A") + elif pybadger.button.b: + print("Button B") + """ + button_values = self._buttons.get_pressed() + return Buttons( + button_values & PyBadgerBase.BUTTON_B, button_values & PyBadgerBase.BUTTON_A + ) + + @property + def _unsupported(self): + """This feature is not supported on CLUE.""" + raise NotImplementedError("This feature is not supported on CLUE.") + + # The following is a list of the features available in other PyBadger modules but + # not available for CLUE. If called while using a CLUE, they will result in the + # NotImplementedError raised in the property above. + light = _unsupported + + + +clue = Clue() # pylint: disable=invalid-name +"""Object that is automatically created on import.""" From 540411af6100c8efec55a15c39be98f958db20d2 Mon Sep 17 00:00:00 2001 From: FoamyGuy Date: Sat, 13 Jun 2020 12:18:18 -0500 Subject: [PATCH 5/9] raise the unsupported error for acceleration and auto_dim_display on PyPortal --- adafruit_pybadger/pyportal.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/adafruit_pybadger/pyportal.py b/adafruit_pybadger/pyportal.py index a4ce221..7e7c544 100644 --- a/adafruit_pybadger/pyportal.py +++ b/adafruit_pybadger/pyportal.py @@ -71,6 +71,8 @@ def _unsupported(self): # not available for PyPortal. If called while using a PyPortal, they will result in the # NotImplementedError raised in the property above. button = _unsupported + acceleration = _unsupported + auto_dim_display = _unsupported pyportal = PyPortal() # pylint: disable=invalid-name From 2589e549e187847439d6369452fc0a4a2d262c80 Mon Sep 17 00:00:00 2001 From: FoamyGuy Date: Wed, 17 Jun 2020 18:46:38 -0500 Subject: [PATCH 6/9] adding support for Pew Pew M4. refactor neopixels into the board specific modules. --- adafruit_pybadger/clue.py | 6 ++++ adafruit_pybadger/pewpewm4.py | 43 +++++++++++++++-------- adafruit_pybadger/pybadge.py | 6 ++++ adafruit_pybadger/pybadger_base.py | 6 ---- adafruit_pybadger/pygamer.py | 6 ++++ adafruit_pybadger/pyportal.py | 11 +++++- examples/Blinka_PewPewM4.bmp | Bin 0 -> 11382 bytes examples/pybadger_pewpewm4_simpletest.py | 25 +++++++++++++ 8 files changed, 82 insertions(+), 21 deletions(-) create mode 100644 examples/Blinka_PewPewM4.bmp create mode 100644 examples/pybadger_pewpewm4_simpletest.py diff --git a/adafruit_pybadger/clue.py b/adafruit_pybadger/clue.py index 850f0f6..a6548a1 100755 --- a/adafruit_pybadger/clue.py +++ b/adafruit_pybadger/clue.py @@ -48,6 +48,7 @@ import audiopwmio from gamepad import GamePad import adafruit_lsm6ds +import neopixel from adafruit_pybadger.pybadger_base import PyBadgerBase __version__ = "0.0.0-auto.0" @@ -70,6 +71,11 @@ def __init__(self): if i2c is not None: self._accelerometer = adafruit_lsm6ds.LSM6DS33(i2c) + # NeoPixels + self._neopixels = neopixel.NeoPixel( + board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB + ) + self._buttons = GamePad( digitalio.DigitalInOut(board.BUTTON_A), digitalio.DigitalInOut(board.BUTTON_B), diff --git a/adafruit_pybadger/pewpewm4.py b/adafruit_pybadger/pewpewm4.py index 24e84fc..00f0665 100644 --- a/adafruit_pybadger/pewpewm4.py +++ b/adafruit_pybadger/pewpewm4.py @@ -47,13 +47,12 @@ import digitalio import audioio from gamepad import GamePad -import adafruit_lsm6ds from adafruit_pybadger.pybadger_base import PyBadgerBase __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PyBadger.git" -Buttons = namedtuple("Buttons", "b a start right down up left") +Buttons = namedtuple("Buttons", ("o", "x", "z", "right", "down", "up", "left")) class PewPewM4(PyBadgerBase): @@ -65,10 +64,14 @@ class PewPewM4(PyBadgerBase): def __init__(self): super().__init__() - self._buttons = GamePad( - digitalio.DigitalInOut(board.BUTTON_A), - digitalio.DigitalInOut(board.BUTTON_B), + digitalio.DigitalInOut(board.BUTTON_O), + digitalio.DigitalInOut(board.BUTTON_X), + digitalio.DigitalInOut(board.BUTTON_Z), + digitalio.DigitalInOut(board.BUTTON_RIGHT), + digitalio.DigitalInOut(board.BUTTON_DOWN), + digitalio.DigitalInOut(board.BUTTON_UP), + digitalio.DigitalInOut(board.BUTTON_LEFT), ) @property @@ -82,27 +85,39 @@ def button(self): from adafruit_pybadger import pybadger while True: - if pybadger.button.a: - print("Button A") - elif pybadger.button.b: - print("Button B") + if pybadger.button.x: + print("Button X") + elif pybadger.button.o: + print("Button O") """ button_values = self._buttons.get_pressed() return Buttons( - button_values & PyBadgerBase.BUTTON_B, button_values & PyBadgerBase.BUTTON_A + *[ + button_values & button + for button in ( + PyBadgerBase.BUTTON_B, + PyBadgerBase.BUTTON_A, + PyBadgerBase.BUTTON_START, + PyBadgerBase.BUTTON_SELECT, + PyBadgerBase.BUTTON_RIGHT, + PyBadgerBase.BUTTON_DOWN, + PyBadgerBase.BUTTON_UP, + ) + ] ) @property def _unsupported(self): - """This feature is not supported on CLUE.""" - raise NotImplementedError("This feature is not supported on CLUE.") + """This feature is not supported on PewPew M4.""" + raise NotImplementedError("This feature is not supported on PewPew M4.") # The following is a list of the features available in other PyBadger modules but # not available for CLUE. If called while using a CLUE, they will result in the # NotImplementedError raised in the property above. light = _unsupported + acceleration = _unsupported + pixels = _unsupported - -clue = Clue() # pylint: disable=invalid-name +pewpewm4 = PewPewM4() # pylint: disable=invalid-name """Object that is automatically created on import.""" diff --git a/adafruit_pybadger/pybadge.py b/adafruit_pybadger/pybadge.py index 825735b..1b4c79f 100755 --- a/adafruit_pybadger/pybadge.py +++ b/adafruit_pybadger/pybadge.py @@ -54,6 +54,7 @@ import audioio from gamepadshift import GamePadShift import adafruit_lis3dh +import neopixel from adafruit_pybadger.pybadger_base import PyBadgerBase __version__ = "0.0.0-auto.0" @@ -88,6 +89,11 @@ def __init__(self): except ValueError: self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1) + # NeoPixels + self._neopixels = neopixel.NeoPixel( + board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB + ) + self._buttons = GamePadShift( digitalio.DigitalInOut(board.BUTTON_CLOCK), digitalio.DigitalInOut(board.BUTTON_OUT), diff --git a/adafruit_pybadger/pybadger_base.py b/adafruit_pybadger/pybadger_base.py index efa8408..498a886 100755 --- a/adafruit_pybadger/pybadger_base.py +++ b/adafruit_pybadger/pybadger_base.py @@ -56,7 +56,6 @@ except ImportError: import audioio as audiocore import displayio -import neopixel from adafruit_display_shapes.rect import Rect from adafruit_display_text import label from adafruit_bitmap_font import bitmap_font @@ -136,11 +135,6 @@ def __init__(self): self.display = board.DISPLAY self._display_brightness = 1.0 - # NeoPixels - self._neopixels = neopixel.NeoPixel( - board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB - ) - # Auto dim display based on movement self._last_accelerometer = None self._start_time = time.monotonic() diff --git a/adafruit_pybadger/pygamer.py b/adafruit_pybadger/pygamer.py index 83098d4..fd654c7 100755 --- a/adafruit_pybadger/pygamer.py +++ b/adafruit_pybadger/pygamer.py @@ -47,6 +47,7 @@ import analogio import digitalio import audioio +import neopixel from gamepadshift import GamePadShift import adafruit_lis3dh from adafruit_pybadger.pybadger_base import PyBadgerBase @@ -76,6 +77,11 @@ def __init__(self): except ValueError: self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1) + # NeoPixels + self._neopixels = neopixel.NeoPixel( + board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB + ) + self._buttons = GamePadShift( digitalio.DigitalInOut(board.BUTTON_CLOCK), digitalio.DigitalInOut(board.BUTTON_OUT), diff --git a/adafruit_pybadger/pyportal.py b/adafruit_pybadger/pyportal.py index 60841e2..807238a 100644 --- a/adafruit_pybadger/pyportal.py +++ b/adafruit_pybadger/pyportal.py @@ -41,8 +41,9 @@ https://github.com/adafruit/circuitpython/releases """ - +import board import audioio +import neopixel from adafruit_pybadger.pybadger_base import PyBadgerBase __version__ = "0.0.0-auto.0" @@ -55,6 +56,14 @@ class PyPortal(PyBadgerBase): _audio_out = audioio.AudioOut _neopixel_count = 1 + def __init__(self): + super().__init__() + + # NeoPixels + self._neopixels = neopixel.NeoPixel( + board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB + ) + @property def _unsupported(self): """This feature is not supported on PyPortal.""" diff --git a/examples/Blinka_PewPewM4.bmp b/examples/Blinka_PewPewM4.bmp new file mode 100644 index 0000000000000000000000000000000000000000..d93dde5f43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VQ(01@K=*K;|Zg&XAkSFg0Y+lwgM9($^5nl%+OU^d{rAs$KK_5lN_djjdw~r ztu}`@&MQkz)3n;lMKijw6>4-YX%y95K@3Yfk}OZB5^-!C{T%IhmfyGC`R%j4FZ6wU zrHu$E;F-KZtC7p)syjEfLaiaFz3-#hVF@g#)EBah_=!EmnK%N)&`xt`KK#nW6p3zcLK4ts0LAb&zV

?VnXKyy01Hng~S zu}^rYIMI5H8XGl9TnL|H)K18t@mt51;>9U`{uYiuhT-+Unj>X5lElE{&A(*m5>rfk zCdOGo7BzFzvqON@88e5r;-d}hzv4f9>(+6_qwIhGDhy4}{BkIE$o+=+6cf!9(u6;E z8{axVbA9h0o?gFc+vXtwd1Uu%GH{7mh}I>pdf|4y#fkS5$h_~SXR381UCH6uDp@*q z0=k<4h>wosyJG}5@An?v>vY>T%3W+6-NT0P$Tlu)B!D*Z{0P33#9^PhM+|rEM!PiC z+arYiU@#~j5zs70&@8&vdz*cW!!>v9@SZ-@$vL)yECngb@?k(m!5QHonnnHRO?<_R z$xrdDk?P)4oKc;rCWMu+VVR`%WXm>4$e1~>YEl0+lYv**g!{~l6k0M@;EfS*$)=Y8 zmUk-4$rh8nRE$g!w4vwwO*3$@h@|~mOHMxa6RK3ePQ8k&uRUb5^*Ln;NnyYa*LdOYHmk(~p|MJ?j{eS)L7XtDHLCP69tTwd%T7UofwU%5sh6r*v zcD9aO1zkh``ETET|HF6n>?YGZ{^>PA;j7k$i${3P$XB?3cO*88?6|c0@ZW#<=RbbW ze#^}owTG+LlZmIfe+)m?vxehUu6*^&FApn-gD9=>DfdSRRUB?PtyY&4 Date: Wed, 17 Jun 2020 18:47:32 -0500 Subject: [PATCH 7/9] fix typo in pyportal example comment --- examples/pybadger_pyportal_touchscreen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pybadger_pyportal_touchscreen.py b/examples/pybadger_pyportal_touchscreen.py index 5ce9607..7ce96e0 100644 --- a/examples/pybadger_pyportal_touchscreen.py +++ b/examples/pybadger_pyportal_touchscreen.py @@ -1,4 +1,4 @@ -"""Simpletest examaple using Adafruit PyPortal. Uses the touchscreen to advance between examples.""" +"""Simpletest example using Adafruit PyPortal. Uses the touchscreen to advance between examples.""" import board from adafruit_pybadger import pybadger import adafruit_touchscreen From c444566f86ef26cbbd20967edb568a6af93067b3 Mon Sep 17 00:00:00 2001 From: FoamyGuy Date: Wed, 17 Jun 2020 18:59:01 -0500 Subject: [PATCH 8/9] fix pyportal import --- adafruit_pybadger/pyportal.py | 1 + 1 file changed, 1 insertion(+) diff --git a/adafruit_pybadger/pyportal.py b/adafruit_pybadger/pyportal.py index bea31bf..0daff0e 100644 --- a/adafruit_pybadger/pyportal.py +++ b/adafruit_pybadger/pyportal.py @@ -42,6 +42,7 @@ """ import board +import analogio import audioio import neopixel from adafruit_pybadger.pybadger_base import PyBadgerBase From 2b09d30a6246ebd7f377b45b5b64c931a0f515ab Mon Sep 17 00:00:00 2001 From: FoamyGuy Date: Thu, 18 Jun 2020 18:33:36 -0500 Subject: [PATCH 9/9] fix pylint issues in base --- adafruit_pybadger/pybadger_base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adafruit_pybadger/pybadger_base.py b/adafruit_pybadger/pybadger_base.py index 498a886..e42eeed 100755 --- a/adafruit_pybadger/pybadger_base.py +++ b/adafruit_pybadger/pybadger_base.py @@ -55,10 +55,10 @@ import audiocore except ImportError: import audioio as audiocore +from adafruit_bitmap_font import bitmap_font import displayio from adafruit_display_shapes.rect import Rect from adafruit_display_text import label -from adafruit_bitmap_font import bitmap_font import terminalio import adafruit_miniqr @@ -135,6 +135,8 @@ def __init__(self): self.display = board.DISPLAY self._display_brightness = 1.0 + self._neopixels = None + # Auto dim display based on movement self._last_accelerometer = None self._start_time = time.monotonic()