button-buddy/progress-log/2022-03-06-initial-hid-test.md

33 lines
1.8 KiB
Markdown
Raw Normal View History

2022-03-06 14:18:40 -06:00
# 2022-03-06 Initial HID Test
Found a _really_ old 16gb SD card and loaded Raspbian up on it, then followed a guide to enable wifi and ssh on it before throwing it in the Pi Zero and plugging it in. After a few minutes I was able to ssh in.
I followed a guide to enable it as a HID device, which involves adding this to `/boot/config.txt`:
```
dtoverlay=dwc2
```
And adding this to `/etc/modules`:
```
dwc2
libcomposite
```
Then I created the `/raspi_config/hid_usb` script that's in this repo at `/usr/bin/hid_usb` and updated `/etc/rc.local` to execute it at boot time.
After a reboot, the Pi showed up as a usb device when running `lsusb` on the computer it's plugged into:
```
Bus 005 Device 008: ID 1d6b:0104 Linux Foundation Multifunction Composite Gadget
```
I created the `/test_scripts/test1.py` script on the Pi and ran it as root, then used a paperclip to alternately connect GPIO 26 and GPIO 16 with ground, and observed it printing characters on the host computer. 26 printed `a` over and over until I broke the connection, and 16 printed `B`. Success!
Looking at the pin-out, there are enough GPIO inputs to support well over 6 or 9 buttons directly hand-wired, so I think that's all I need to do. I guess I'd connect one pin on each keyboard switch to ground (maybe all chained together to the same ground pin?) then the other pin from each to a distinct GPIO pin on the Pi.
To further test this theory I got a second paper clip and awkwardly connected both GPIO 26 and 16 to the same ground pin simultaneously and observed `aBaBaBaB` being output on the host computer. Looking good!
Done messing with the Pi today. Going to mess with OpenSCAD a bit, having just learned about it and worked through a few steps of the introductory tutorial I still have a ways to go before I'll feel comfortable designing the switch plate and case for this thing.