Skip to content

removing use of gamepad #48

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 1 commit into from
Jul 26, 2021
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
25 changes: 0 additions & 25 deletions adafruit_clue.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import audiobusio
import audiopwmio
import audiocore
import gamepad
import touchio

__version__ = "0.0.0-auto.0"
Expand Down Expand Up @@ -197,7 +196,6 @@ def __init__(self):
self._a.switch_to_input(pull=digitalio.Pull.UP)
self._b = digitalio.DigitalInOut(board.BUTTON_B)
self._b.switch_to_input(pull=digitalio.Pull.UP)
self._gamepad = gamepad.GamePad(self._a, self._b)

# Define LEDs:
self._white_leds = digitalio.DigitalInOut(board.WHITE_LEDS)
Expand Down Expand Up @@ -350,29 +348,6 @@ def button_b(self):
"""
return not 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

To use with the CLUE:

.. code-block:: python

from adafruit_clue import clue

while True:
print(clue.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

def shake(self, shake_threshold=30, avg_count=10, total_delay=0.1):
"""
Detect when the accelerometer is shaken. Optional parameters:
Expand Down
10 changes: 4 additions & 6 deletions examples/advanced_examples/clue_ams_remote_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,18 @@
time.sleep(0.25)

# If button B (on the right) is pressed, it increases the volume
if "B" in clue.were_pressed:
if clue.button_b:
ams.volume_up()
a = clue.were_pressed
time.sleep(0.35)
while "B" in clue.were_pressed:
while clue.button_b:
ams.volume_up()
time.sleep(0.07)

# If button A (on the left) is pressed, the volume decreases
if "A" in clue.were_pressed:
if clue.button_a:
ams.volume_down()
a = clue.were_pressed
time.sleep(0.35)
while "A" in clue.were_pressed:
while clue.button_a:
ams.volume_down()
time.sleep(0.07)
time.sleep(0.01)
Expand Down
8 changes: 4 additions & 4 deletions examples/clue_ams_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@
time.sleep(0.25)

# If button B (on the right) is pressed, it increases the volume
if "B" in clue.were_pressed:
if clue.button_b:
ams.volume_up()
time.sleep(0.30)
while "B" in clue.were_pressed:
while clue.button_b:
ams.volume_up()
time.sleep(0.07)

# If button A (on the left) is pressed, the volume decreases
if "A" in clue.were_pressed:
if clue.button_a:
ams.volume_down()
time.sleep(0.30)
while "A" in clue.were_pressed:
while clue.button_a:
ams.volume_down()
time.sleep(0.07)

Expand Down