mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-24 11:46:30 +00:00
add gpio.sh handy bash command
This commit is contained in:
parent
e012a475d8
commit
91e27c051b
20
board/common/overlay/usr/bin/gpio.sh
Executable file
20
board/common/overlay/usr/bin/gpio.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
GPIO=$1
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 <gpio> [0|1]" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
test -z "$GPIO" && usage
|
||||
test -e /sys/class/gpio/gpio$GPIO || echo $GPIO > /sys/class/gpio/export
|
||||
|
||||
if [ -n "$2" ]; then
|
||||
echo out > /sys/class/gpio/gpio$GPIO/direction
|
||||
echo $2 > /sys/class/gpio/gpio$GPIO/value
|
||||
else
|
||||
echo in > /sys/class/gpio/gpio$GPIO/direction
|
||||
cat /sys/class/gpio/gpio$GPIO/value
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user