Thanks to visit codestin.com
Credit goes to github.com

Skip to content

esp32-s2 gamepad.get_pressed() stuck on 0 after restart #3693

Closed
@FoamyGuy

Description

@FoamyGuy

Using this script:

import time
import board
from digitalio import DigitalInOut, Direction, Pull
from gamepad import GamePad

print("wait before anything")
time.sleep(5)

btn_a = DigitalInOut(board.BUTTON_A)
btn_b = DigitalInOut(board.BUTTON_B)

# um feather s2 with OLED featherwing
# btn_a = DigitalInOut(board.IO33)
# btn_b = DigitalInOut(board.IO38)

_buttons = GamePad(
    btn_a,
    btn_b,
)
while True:
    print("{} - {}".format(btn_a.value, btn_b.value))
    print(_buttons.get_pressed())
    time.sleep(1)

When I run this on a ESP32-S2 (MagTag and UM Feather S2) directly after it boots up the printouts are as expected. The True and False values print correctly, as well as the numbers from _buttons.get_pressed() have the correct value.

But if I restart this script by using ctrl-c then ctrl-d the values from _buttons.get_pressed() will start to always show 0. The values from btn_a.value and btn_b.value still correctly change from True to False when I press buttons. But the gamepad values seem to get stuck on 0 after restarting this way.

The same code run on a CLUE and prints correct values both before and after restarting with ctrl-c / ctrl-d.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugespressifapplies to multiple Espressif chips

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions