From 928e009fd7725f6cfbf5109aa708252960ff0e5f Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Tue, 18 Feb 2020 16:53:31 -0500 Subject: [PATCH] Linting, comments. --- adafruit_pybadger/clue.py | 30 +++++++++++++++++++++++------- adafruit_pybadger/pybadge.py | 13 +++++++------ adafruit_pybadger/pybadger_base.py | 2 -- adafruit_pybadger/pygamer.py | 7 +++++-- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/adafruit_pybadger/clue.py b/adafruit_pybadger/clue.py index 05ded4e..251d288 100755 --- a/adafruit_pybadger/clue.py +++ b/adafruit_pybadger/clue.py @@ -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.""" diff --git a/adafruit_pybadger/pybadge.py b/adafruit_pybadger/pybadge.py index cfacb7e..adf01a3 100755 --- a/adafruit_pybadger/pybadge.py +++ b/adafruit_pybadger/pybadge.py @@ -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 `_ * `Adafruit PyBadge LC `_ +* `Adafruit EdgeBadge `_ **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.""" diff --git a/adafruit_pybadger/pybadger_base.py b/adafruit_pybadger/pybadger_base.py index 842580e..fbca18f 100755 --- a/adafruit_pybadger/pybadger_base.py +++ b/adafruit_pybadger/pybadger_base.py @@ -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: diff --git a/adafruit_pybadger/pygamer.py b/adafruit_pybadger/pygamer.py index a59a4fc..1010d96 100755 --- a/adafruit_pybadger/pygamer.py +++ b/adafruit_pybadger/pygamer.py @@ -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."""