Commit Graph

13 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 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 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 240678e714 Avoid uninitialized gamepad on exception
Raise exceptions before the gamepad_singleton is created.
Also, use mp_raise for creating the exceptions.
2018-05-23 21:39:06 +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 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