mholgatem / GPIOnext

The next evolution of GPioneer! Create virtual gamepads with your GPIO pins!
MIT License
134 stars 37 forks source link

Not working with an SPI connected joystick #65

Closed KingWille closed 2 years ago

KingWille commented 2 years ago

I'm trying to use an analog joystick for my Retropie system, and I'm using an MCP3008 ADC via SPI to do it. The joystick reads just fine using my test codes, but when i have the Joystick connected to the GPIO pins, GPIOnext doesn't work. I get the following error:

RuntimeError: Failed to add edge detection

mholgatem commented 2 years ago

@KingWille - Sorry, but GPIOnext doesn't handle SPI. It relies solely on the rpi.gpio library which only reads the states of the gpio pins, it doesn't handle any communication protocols like SPI or I2C. You could fork the code and add your own code using a library like spidev to get the values of your joystick. From there you could handle the joystick values in the Axis Class. I know that this wasn't what you were hoping for, but unfortunately it's beyond the scope of what I designed gpionext for.

Personally, I would look at using an Arduino Micro as a solution. It has analog pins and can emulate a gamepad via usb. You

KingWille commented 2 years ago

Ok, well thank you for your quick response and tips on how to solve it. Im a beginner working with a friend but I'll continue trying. We thought of the arduino solution and that's the backup plan, but ideally we want it to work with a ADC card.

joecoolish commented 7 months ago

I just submitted a pull request that adds SPI support. I have tested it with an MCP3008 and it works great! I would love additional testing.

mholgatem commented 7 months ago

Awesome @joecoolish ! I'll check it out when I have a chance (it'll probably be a week or two). I'll merge it once I've had a chance to test it out. Thanks for the hard work!

KingWille commented 7 months ago

Thanks mholgatem! Although I'm not working on this project anymore, thanks for coming with a solution. If you're interested, I have repo with spi functional code for gamepads in general. It's not my original code completely, just an altered version of another persons code. It's been awhile though, so I can't remember the creators name.