Skip to content

Added docstring to make #51 pass travis #72

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 3 commits into from
Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions adafruit_circuitplayground/express.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
import digitalio
import neopixel
import touchio
import gamepad


__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground.git"
Expand Down Expand Up @@ -90,6 +92,7 @@ def __init__(self):
self._a.switch_to_input(pull=digitalio.Pull.DOWN)
self._b = digitalio.DigitalInOut(board.BUTTON_B)
self._b.switch_to_input(pull=digitalio.Pull.DOWN)
self.gamepad = gamepad.GamePad(self._a, self._b)

# Define switch:
self._switch = digitalio.DigitalInOut(board.SLIDE_SWITCH)
Expand Down Expand Up @@ -479,6 +482,27 @@ def button_b(self):
"""
return self._b.value

@property
def were_pressed(self):
"""Returns a set of the buttons that have been pressed

.. image :: ../docs/_static/button_b.jpg
:alt: Button B

.. code-block:: python

from adafruit_circuitplayground.express import cpx

while True:
print(cpx.were_pressed)
"""
ret = set()
pressed = self.gamepad.get_pressed()
for button, mask in (('A', 0x01), ('B', 0x02)):
if mask & pressed:
ret.add(button)
return ret

@property
def switch(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
'NeoPixel': ('https://circuitpython.readthedocs.io/projects/neopixel/en/latest/', None)}

# Libraries we depend on but don't need for generating docs.
autodoc_mock_imports = ["board", "analogio", "digitalio", "neopixel", "adafruit_thermistor", "audioio", "touchio", "adafruit_lis3dh", "busio"]
autodoc_mock_imports = ["board", "analogio", "digitalio", "neopixel", "adafruit_thermistor", "audioio", "touchio", "adafruit_lis3dh", "busio", "gamepad"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down