it is the little things that count

pull/6/head
Rick Farina (Zero_Chaos) 2019-12-12 21:53:50 -05:00
parent 9febcdee41
commit 534d8cc12c
No known key found for this signature in database
GPG Key ID: A29433C0AA431DDC
1 changed files with 9 additions and 9 deletions

View File

@ -1,25 +1,25 @@
#!/bin/bash
function setup() {
echo $1 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio$1/direction
echo "${1}" > /sys/class/gpio/export
echo in > "/sys/class/gpio/gpio${1}/direction"
}
function check_gpio() {
if [ ! -d /sys/class/gpio/gpio$1 ]; then
setup $1
if [ ! -d "/sys/class/gpio/gpio${1}" ]; then
setup "${1}"
fi
state=$(cat /sys/class/gpio/gpio$1/value)
echo $state
state=$(cat "/sys/class/gpio/gpio${1}/value")
echo "${state}"
}
gpio0=$(check_gpio 0)
gpio2=$(check_gpio 2)
if [ $gpio0 -eq "0" ] && [ $gpio2 -eq "0" ]; then
if [ ${gpio0} -eq "0" ] && [ ${gpio2} -eq "0" ]; then
echo "switch1"
elif [ $gpio0 -eq "0" ]; then
elif [ ${gpio0} -eq "0" ]; then
echo "switch3"
elif [ $gpio2 -eq "0" ]; then
elif [ ${gpio2} -eq "0" ]; then
echo "switch2"
fi