remove unnecessary variables
This commit is contained in:
parent
b7cc8591b5
commit
1b9c7ec2c8
58
buzzer.sh
58
buzzer.sh
|
@ -3,66 +3,64 @@
|
||||||
|
|
||||||
configfile="config.json"
|
configfile="config.json"
|
||||||
|
|
||||||
cmdjq="$(command -v jq)"
|
if [ -z "$(command -v jq)" ]; then
|
||||||
if [ -z "$cmdjq" ]; then
|
|
||||||
echo "Missing \"jq\"!"
|
echo "Missing \"jq\"!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cmdgpio="$(command -v gpio)"
|
if [ -z "$(command -v gpio)" ]; then
|
||||||
if [ -z "$cmdgpio" ]; then
|
|
||||||
echo "Missing \"gpio\"!"
|
echo "Missing \"gpio\"!"
|
||||||
echo "This is a part of WiringPi-Package."
|
echo "This is a part of WiringPi-Package."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
player="$($cmdjq -r ".player" < $configfile)"
|
player="$(jq -r ".player" < $configfile)"
|
||||||
if [ -z "$(command -v $player)" ]; then
|
if [ -z "$(command -v $player)" ]; then
|
||||||
echo "Missing \"$player\"!"
|
echo "Missing \"$player\"!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
buzzergpio="$($cmdjq -r ".buzzer | .buzzergpio" < $configfile)"
|
buzzergpio="$(jq -r ".buzzer | .buzzergpio" < $configfile)"
|
||||||
strobegpio="$($cmdjq -r ".buzzer | .strobegpio" < $configfile)"
|
strobegpio="$(jq -r ".buzzer | .strobegpio" < $configfile)"
|
||||||
swupgpio="$($cmdjq -r ".swupgpio" < $configfile)"
|
swupgpio="$(jq -r ".swupgpio" < $configfile)"
|
||||||
swdowngpio="$($cmdjq -r ".buzzer | .swdowngpio" < $configfile)"
|
swdowngpio="$(jq -r ".buzzer | .swdowngpio" < $configfile)"
|
||||||
|
|
||||||
playerparam="$($cmdjq -r ".playerparam" < $configfile)"
|
playerparam="$(jq -r ".playerparam" < $configfile)"
|
||||||
playerloop="$($cmdjq -r ".buzzer | .playerloop" < $configfile)"
|
playerloop="$(jq -r ".buzzer | .playerloop" < $configfile)"
|
||||||
|
|
||||||
pgrepplayer="$($cmdjq -r ".pgrepplayer" < $configfile)"
|
pgrepplayer="$(jq -r ".pgrepplayer" < $configfile)"
|
||||||
|
|
||||||
pollingtime="$($cmdjq -r ".buzzer | .pollingtime" < $configfile)"
|
pollingtime="$(jq -r ".buzzer | .pollingtime" < $configfile)"
|
||||||
buzzertimeout="$($cmdjq -r ".buzzer | .buzzertimeout" < $configfile)"
|
buzzertimeout="$(jq -r ".buzzer | .buzzertimeout" < $configfile)"
|
||||||
strobeduration="$($cmdjq -r ".buzzer | .strobeduration" < $configfile)"
|
strobeduration="$(jq -r ".buzzer | .strobeduration" < $configfile)"
|
||||||
|
|
||||||
volumetimeout="$($cmdjq -r ".buzzer | .volumetimeout" < $configfile)"
|
volumetimeout="$(jq -r ".buzzer | .volumetimeout" < $configfile)"
|
||||||
volumedelay="$($cmdjq -r ".buzzer | .volumedelay" < $configfile)"
|
volumedelay="$(jq -r ".buzzer | .volumedelay" < $configfile)"
|
||||||
volumemax="$($cmdjq -r ".buzzer | .volumemax" < $configfile)"
|
volumemax="$(jq -r ".buzzer | .volumemax" < $configfile)"
|
||||||
|
|
||||||
playerfull="$(command -v $player) $playerparam"
|
playerfull="$(command -v $player) $playerparam"
|
||||||
cmdamixer="$(command -v amixer)"
|
cmdamixer="$(command -v amixer)"
|
||||||
|
|
||||||
$cmdgpio mode $buzzergpio in
|
gpio mode $buzzergpio in
|
||||||
|
|
||||||
$cmdgpio mode $strobegpio out
|
gpio mode $strobegpio out
|
||||||
$cmdgpio write $strobegpio 1
|
gpio write $strobegpio 1
|
||||||
|
|
||||||
$cmdgpio mode $swdowngpio in
|
gpio mode $swdowngpio in
|
||||||
$cmdgpio mode $swupgpio in
|
gpio mode $swupgpio in
|
||||||
|
|
||||||
volumevalue=0
|
volumevalue=0
|
||||||
$cmdamixer -q -c 2 sset 'Speaker' $volumevalue%
|
$cmdamixer -q -c 2 sset 'Speaker' $volumevalue%
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
|
||||||
buzzerstat="$($cmdgpio read $buzzergpio)"
|
buzzerstat="$(gpio read $buzzergpio)"
|
||||||
swupstat="$($cmdgpio read $swupgpio)"
|
swupstat="$(gpio read $swupgpio)"
|
||||||
swdownstat="$($cmdgpio read $swdowngpio)"
|
swdownstat="$(gpio read $swdowngpio)"
|
||||||
|
|
||||||
if [ "$buzzerstat" -eq 0 ] && [ "$swupstat" -eq 0 ]; then
|
if [ "$buzzerstat" -eq 0 ] && [ "$swupstat" -eq 0 ]; then
|
||||||
~/RandomVideo/RandomVideo.sh buzzer
|
~/RandomVideo/RandomVideo.sh buzzer
|
||||||
$cmdgpio write $strobegpio 0; sleep $strobeduration; $cmdgpio write $strobegpio 1 &
|
gpio write $strobegpio 0; sleep $strobeduration; gpio write $strobegpio 1 &
|
||||||
sleep $buzzertimeout
|
sleep $buzzertimeout
|
||||||
|
|
||||||
elif [ "$swupstat" -eq 1 ]; then
|
elif [ "$swupstat" -eq 1 ]; then
|
||||||
|
@ -74,7 +72,7 @@ while true; do
|
||||||
$playerfull $playerloop ~/RandomVideo/onair.mp4 &
|
$playerfull $playerloop ~/RandomVideo/onair.mp4 &
|
||||||
|
|
||||||
while [ "$swupstat" -eq 1 ]; do
|
while [ "$swupstat" -eq 1 ]; do
|
||||||
swupstat="$($cmdgpio read $swupgpio)"
|
swupstat="$(gpio read $swupgpio)"
|
||||||
sleep $pollingtime
|
sleep $pollingtime
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -85,7 +83,7 @@ while true; do
|
||||||
while [ "$volumevalue" -lt "$volumemax" ] && [ "$buzzerstat" -eq 1 ]; do
|
while [ "$volumevalue" -lt "$volumemax" ] && [ "$buzzerstat" -eq 1 ]; do
|
||||||
volumevalue=$((volumevalue + 1))
|
volumevalue=$((volumevalue + 1))
|
||||||
$cmdamixer -q -c 2 sset 'Speaker' $volumevalue%
|
$cmdamixer -q -c 2 sset 'Speaker' $volumevalue%
|
||||||
buzzerstat="$($cmdgpio read $buzzergpio)"
|
buzzerstat="$(gpio read $buzzergpio)"
|
||||||
sleep $volumetimeout
|
sleep $volumetimeout
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -96,7 +94,7 @@ while true; do
|
||||||
while [ "$volumevalue" -gt 0 ] && [ "$swdownstat" -eq 0 ]; do
|
while [ "$volumevalue" -gt 0 ] && [ "$swdownstat" -eq 0 ]; do
|
||||||
volumevalue=$((volumevalue -1))
|
volumevalue=$((volumevalue -1))
|
||||||
$cmdamixer -q -c 2 sset 'Speaker' $volumevalue%
|
$cmdamixer -q -c 2 sset 'Speaker' $volumevalue%
|
||||||
swdownstat="$($cmdgpio read $swdowngpio)"
|
swdownstat="$(gpio read $swdowngpio)"
|
||||||
sleep $volumetimeout
|
sleep $volumetimeout
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue