Using the pico really is necessary. There isn't a lot of space inside the project shell, and I really don't need the wires messier than they already are.You have plenty of I/O available for buttons. I wouldn't bother with an external micro. More to build, more to debug, more to maintain.
There isn't space for a few extra wires but there is space for a Pico, a USB cable, and extra wires? That doesn't make sense. At least not to me.
USB CDC looks like a good optionThe most straightforward way would be to connect as a USB serial port (USB CDC), and use it with C stdio (or whatever).
You sure about that? It's likely to be more work than USB HID.
To use CDC you'll need to:
- Define a custom message format
- Configure CDC on Pico
- Send messages from Pico
- Modify you Pi code to read serial data from the correct device with the correct settings. Preferably without blocking its other functions
- Decode messages. Including coping with broken or incomplete ones
- Configure Pico as HID keyboard (there are circuit and micropython examples for this)
- Send a HID report on button change(s)
- On the Pi modify your code using a library of your choice to respond to keypress/joystick/whichever events. No messing with low level stuff like reading raw keyboard or serial data.
Check the official docs and do a web search. The truth is out there., but I haven't been able to figure it out previously.Is there an easy way to use it with Circuit Python or Micro Python?
Full disclosure: I've not done USB HID with circuit/micro python on a Pico. I have done HID keyboard with full fat python on a Pi zero. It's almost trivial: https://github.com/thagrol/pwdgen
Statistics: Posted by thagrol — Fri Jan 24, 2025 11:27 pm