Commit Graph

16 Commits

Author SHA1 Message Date
Jeff Epler fbf052bb27 Gamepad & GamepadShift: Enable ticks while object exists
Otherwise, button presses might not be noticed.
2020-05-13 10:14:37 -05:00
Scott Shawcroft 190bdf8117
Simplify type check in tick and init last 2019-04-16 10:44:09 -07:00
Scott Shawcroft 0e03a321e4
Fully split gamepadshift from gamepad 2019-04-16 10:11:54 -07:00
Scott Shawcroft c927e6b938
Split GamePadShift from GamePad to save space on most boards. 2019-04-15 15:40:06 -07:00
Radomir Dopieralski 4dc286fa14 Reorganize the gamepad code 2019-04-12 20:43:29 +02:00
Radomir Dopieralski ae60968563 More refactoring 2019-04-12 20:43:29 +02:00
Radomir Dopieralski 7e89beeb31 Optimize the size of code for gamepad 2019-04-12 20:43:29 +02:00
Radomir Dopieralski 3469b1ec5d Add debouncing to GamePadShift 2019-04-12 20:43:29 +02:00
Radomir Dopieralski b485e45f4f Go back to simple bit-banging in GamePadShift, fix problems 2019-04-12 20:43:29 +02:00
Radomir Dopieralski a7925930fa Read one bit per system clock tick in GamePadShift 2019-04-12 20:43:29 +02:00
Radomir Dopieralski 6ff4e0ecb0 Add GamePadShift for handling shift-register-based buttons 2019-04-12 20:43:29 +02:00
Radomir Dopieralski b219ce6d37 Add gamepad_singleton to root pointers 2018-05-30 23:11:22 +02:00
Radomir Dopieralski 52d05bbc37 Cache pullup state in gamepad
Don't check the pin's pull direction on every tick, instead cache it
at the beginning. Also avoid a "can't get pull of output pin" error
when one of the pins passed is in output mode.
2018-05-23 11:26:16 +02:00
Radomir Dopieralski 280374fa63 Respect pin's pull in gamepad
While it is traditional to have buttons on pins that are pulled up, and
have the button connect them to the ground, some CircuitPython boards
(notably the CPX) have the button pins pulled low and the button
connects them to VCC.

This patch makes the gamepad only change the pin's pull if it wasn't
already set when passed to the constructor, and also makes it consider
a button pressed when its value is the opposite of its pull.
2018-03-31 21:13:02 +02:00
Radomir Dopieralski 1c97b7f4df Gracefully reset the gamepad module
If a soft reset happens while the gamepad module is scanning for button
presses, there is a moment when the pins get de-initialized, but the
gamepad module is still trying to read them, which ends in a crash.
We can avoid it by disabling scanning on reset.

(cherry picked from commit 470a23d4c9)

Conflicts:
	atmel-samd/main.c
2017-10-22 20:54:10 -07:00
Radomir Dopieralski f4981677b0 Add a `gamepad` module for handling buttons in the background. (#295)
The `GamePad` singleton monitors buttons in the background to make sure a button press is never missed and debouncing happens consistently.
2017-10-03 13:35:57 -07:00