I'm using the PyGamer and the JEPlayer(https://github.com/jepler/JEplayer) project to make my own personal language shadowing device. The JEPlayer does an excellent job of playing MP3 but I need to customize it a bit. Currently all the physical buttons perform the same action during playback using the gamepadshift which is being depricated but I'd really like to have the buttons do different functions (ie. Button A replays, Button B goes to next track, etc). I started looking into it and it looks like I might need to use keypad.shiftregister, but I got lost pretty quickly with it. Anyone have any pointers?
#Help with PyGamer buttons
1 messages · Page 1 of 1 (latest)
A good place to start is https://learn.adafruit.com/adafruit-pygamer/pinouts; search on that page for ShiftRegisterKeys and you'll see some CircPy code. The first part initializes k, a keypad.ShiftRegisterKeys object. The second part is a loop that keeps getting events from k.
Each time you press or release a button, an event is generated. Each event has fields key_number, pressed and released (which are simply the inverse of one another), and a timestamp.
The idea is that you keep calling k.events.get() in a loop, and every time it returns a value (vs. None), you look at the event, see what button is being pressed or released, and act accordingly.
You'll probably have to do some experimenting to see which button has which key_number -- offhand I don't see that documented anywhere.