Linting, comments.

This commit is contained in:
Kattni Rembor 2020-02-18 16:53:31 -05:00
parent d5cdc1e327
commit 928e009fd7
4 changed files with 35 additions and 17 deletions

View file

@ -44,8 +44,8 @@ Implementation Notes
from collections import namedtuple
import board
import audiopwmio
import digitalio
import audiopwmio
from gamepad import GamePad
import adafruit_lsm6ds
from adafruit_pybadger.pybadger_base import PyBadgerBase
@ -56,7 +56,7 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PyBadger.git"
Buttons = namedtuple("Buttons", "a b")
class Clue(PyBadgerBase):
"""Class that represents a single CLUE."""
_audio_out = audiopwmio.PWMAudioOut
_neopixel_count = 1
@ -73,6 +73,22 @@ class Clue(PyBadgerBase):
@property
def button(self):
"""The buttons on the board.
Example use:
.. code-block:: python
from adafruit_pybadger import PyBadger
pybadger = 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)
@ -80,14 +96,14 @@ class Clue(PyBadgerBase):
@property
def _unsupported(self):
"""This feature is not supported on Circuit Playground Express."""
"""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 Circuit Playground modules but
# not available for Circuit Playground Express. If called while using a Circuit Playground
# Express, they will result in the NotImplementedError raised in the property above.
# 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.
play_file = _unsupported
light = _unsupported
clue = Clue()
clue = Clue() # pylint: disable=invalid-name
"""Object that is automatically created on import."""

View file

@ -23,8 +23,8 @@
`adafruit_pybadger.pybadge`
================================================================================
Badge-focused CircuitPython helper library for PyBadge and PyBadge LC.
Both boards are included in this module as there is no difference in the
Badge-focused CircuitPython helper library for PyBadge, PyBadge LC and EdgeBadge.
All three boards are included in this module as there is no difference in the
CircuitPython builds at this time, and therefore no way to differentiate
the boards from within CircuitPython.
@ -38,6 +38,7 @@ Implementation Notes
* `Adafruit PyBadge <https://www.adafruit.com/product/4200>`_
* `Adafruit PyBadge LC <https://www.adafruit.com/product/3939>`_
* `Adafruit EdgeBadge <https://www.adafruit.com/product/4400>`_
**Software and Dependencies:**
@ -47,10 +48,10 @@ Implementation Notes
"""
from collections import namedtuple
import audioio
import board
import digitalio
import analogio
import audioio
from gamepadshift import GamePadShift
import adafruit_lis3dh
from adafruit_pybadger.pybadger_base import PyBadgerBase
@ -61,11 +62,11 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PyBadger.git"
Buttons = namedtuple("Buttons", "b a start select right down up left")
class PyBadge(PyBadgerBase):
"""Class that represents a single PyBadge, PyBadge LC, or EdgeBadge."""
_audio_out = audioio.AudioOut
_neopixel_count = 5
def __init__(self):
super().__init__()
@ -120,5 +121,5 @@ class PyBadge(PyBadgerBase):
PyBadgerBase.BUTTON_RIGHT, PyBadgerBase.BUTTON_DOWN,
PyBadgerBase.BUTTON_UP, PyBadgerBase.BUTTON_LEFT)])
pybadge = PyBadge()
pybadge = PyBadge() # pylint: disable=invalid-name
"""Object that is automatically created on import."""

View file

@ -335,7 +335,6 @@ class PyBadgerBase:
"""Generate a QR code and display it for ``dwell`` seconds.
:param string data: A string of data for the QR code
:param int dwell: The amount of time in seconds to display the QR code
"""
qr_code = adafruit_miniqr.QRCode(qr_type=3, error_correct=adafruit_miniqr.L)
@ -402,7 +401,6 @@ class PyBadgerBase:
def stop_tone(self):
""" Use with start_tone to stop the tone produced.
"""
# Stop playing any tones.
if self._sample is not None and self._sample.playing:

View file

@ -43,10 +43,10 @@ Implementation Notes
"""
from collections import namedtuple
import audioio
import board
import analogio
import digitalio
import audioio
from gamepadshift import GamePadShift
import adafruit_lis3dh
from adafruit_pybadger.pybadger_base import PyBadgerBase
@ -57,8 +57,11 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PyBadger.git"
Buttons = namedtuple("Buttons", "b a start select")
class PyGamer(PyBadgerBase):
"""Class that represents a single PyGamer."""
_audio_out = audioio.AudioOut
_neopixel_count = 5
def __init__(self):
super().__init__()
@ -116,5 +119,5 @@ class PyGamer(PyBadgerBase):
y = self._pygamer_joystick_y.value
return x, y
pygamer = PyGamer()
pygamer = PyGamer() # pylint: disable=invalid-name
"""Object that is automatically created on import."""