Apparently your searches overlooked the kernel itself.
So leds-gpio couldn't provide the led handling you needed? After setting up the LEDS with device tree they can be driven using the LED sysfs ABI.
Wrt the buttons, the latest GPIO uAPI provides both edge detection and debounce but you go with polling instead.
This is an approximation of your button functionality, but using those features with the tools from libgpiod v2.
Call this button.sh:
Use it like so:to create a file that tracks the state of GPIO22.
Of course you could do whatever you like in that script instead of writing to a file.
Btw the latest GPIO uAPI is hardly "hot off the presses". It was first released in Linux 5.10. Yes that is a 5. It is only recently that Pi users noticed as the Pi5 broke most of their existing libraries, as does the long overdue and ongoing removal of the long deprecated GPIO sysfs interface.
So leds-gpio couldn't provide the led handling you needed? After setting up the LEDS with device tree they can be driven using the LED sysfs ABI.
Wrt the buttons, the latest GPIO uAPI provides both edge detection and debounce but you go with polling instead.
This is an approximation of your button functionality, but using those features with the tools from libgpiod v2.
Call this button.sh:
Code:
#!/bin/bashgpioget --numeric $1 > $1gpiomon -p10ms --format "%E" $1 | while read edgedoif [ "$edge" = 'rising' ]; thenecho "1" > $1elseecho "0" > $1fidone
Code:
$ button.sh GPIO22
Of course you could do whatever you like in that script instead of writing to a file.
Btw the latest GPIO uAPI is hardly "hot off the presses". It was first released in Linux 5.10. Yes that is a 5. It is only recently that Pi users noticed as the Pi5 broke most of their existing libraries, as does the long overdue and ongoing removal of the long deprecated GPIO sysfs interface.
Statistics: Posted by warthog618 — Sun Oct 06, 2024 8:48 am