November 16, 2020, 5:17pm
I’ve got a custom UI board/hat for Raspberry Pi that includes some buttons and encoders. These are all setup with a device overlay so they show up as
/dev/input/ devices like this (output from dmesg):
[ 3.903843] input: keys as /devices/platform/keys/input/input4
[ 4.241849] input: soc:knob3 as /devices/platform/soc/soc:knob3/input/input5
[ 4.262185] input: soc:knob2 as /devices/platform/soc/soc:knob2/input/input6
[ 4.274703] input: soc:knob1 as /devices/platform/soc/soc:knob1/input/input7
[ 4.284326] input: soc:knob4 as /devices/platform/soc/soc:knob4/input/input8
What is my best approach to work with these inputs from OF?
November 16, 2020, 10:54pm
Likely it’s all in the docs for the HAT - and maybe some configuration of ofSerial. But easier still might be that if via the terminal you can poll each location for a value (ie. the terminal prints the encoder or button value), then call it via
string ofSystem(const string &command) - then you could make that an
ofThread, and generate buttonPressed and encoderValueChanged events.
November 17, 2020, 4:22am
Well… I’m the guy who made/designed the HAT in question so…
The buttons (
keys) do get sent to the terminal as keycodes. But, the encoder values do not print there.
The other (audio) software I use with this device uses some C code to get values from the GPIOs (where the buttons/encoders are connected to the pi). Maybe I need to look at the GPIO addon?
November 28, 2020, 5:57am
Did some looking at ofxGPIO and this won’t work for my situation.
ofxGPIO wants to export and control the specific GPIO pins. In my case, the pins are already exported (from the device tree)
sudo cat /sys/kernel/debug/gpio is handy to see what pins are in use by the system.
Will take a look at using
ofSystem and report back.