parent
3d89f570c3
commit
5da67bc518
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# SPDX-License-Identifier: Unlicense
|
||||||
|
|
||||||
folder="/mnt/video"
|
folder="/mnt/video"
|
||||||
player="cvlc"
|
player="cvlc"
|
||||||
|
@ -6,8 +7,8 @@ playerparam="--play-and-exit --quiet --no-osd -A alsa --alsa-audio-device=front:
|
||||||
pgrepplayer="vlc"
|
pgrepplayer="vlc"
|
||||||
|
|
||||||
swupgpio=23
|
swupgpio=23
|
||||||
swdowngpio=25
|
|
||||||
|
|
||||||
|
playerfull="$(command -v $player) $playerparam"
|
||||||
swupstat=$($(command -v gpio) read $swupgpio)
|
swupstat=$($(command -v gpio) read $swupgpio)
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
|
@ -20,7 +21,7 @@ if [ $# -gt 1 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $swupstat -eq 1 ]; then
|
if [ "$swupstat" -eq 1 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -29,9 +30,9 @@ if [ "buzzer" != "$1" ] && [ "cron" != "$1" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $(command -v pgrep) "$pgrepplayer" > /dev/null; then
|
if pgrep "$pgrepplayer" > /dev/null; then
|
||||||
if [ "$1" = "buzzer" ]; then
|
if [ "$1" = "buzzer" ]; then
|
||||||
$(command -v pkill) "$pgrepplayer"
|
pkill "$pgrepplayer"
|
||||||
|
|
||||||
elif [ "$1" = "cron" ]; then
|
elif [ "$1" = "cron" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -39,6 +40,6 @@ if $(command -v pgrep) "$pgrepplayer" > /dev/null; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
$(command -v "$player") $playerparam "$(find "$folder" -maxdepth 1 -type f |sort -R |head -n1)" &
|
$playerfull "$(find "$folder" -maxdepth 1 -type f |sort -R |head -n1)" &
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
64
buzzer.sh
64
buzzer.sh
|
@ -1,52 +1,84 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# SPDX-License-Identifier: Unlicense
|
||||||
|
|
||||||
buzzgpio=0
|
buzzergpio=0
|
||||||
strobogpio=2
|
strobegpio=2
|
||||||
swupgpio=23
|
swupgpio=23
|
||||||
swdowngpio=25
|
swdowngpio=25
|
||||||
|
|
||||||
player="cvlc"
|
player="cvlc"
|
||||||
playerparam="--play-and-exit --quiet --no-osd -A alsa --alsa-audio-device=front:CARD=Device,DEV=0"
|
playerparam="--play-and-exit --quiet --no-osd -A alsa --alsa-audio-device=front:CARD=Device,DEV=0"
|
||||||
|
playerloop="--loop"
|
||||||
|
|
||||||
pgrepplayer="vlc"
|
pgrepplayer="vlc"
|
||||||
|
|
||||||
|
pollingtime=0.05
|
||||||
|
buzzertimeout=2
|
||||||
|
strobeduration=1
|
||||||
|
|
||||||
|
volumetimeout=0.1
|
||||||
|
|
||||||
|
playerfull="$(command -v $player) $playerparam"
|
||||||
cmdgpio="$(command -v gpio)"
|
cmdgpio="$(command -v gpio)"
|
||||||
|
cmdamixer="$(command -v amixer)"
|
||||||
|
|
||||||
$cmdgpio mode $buzzgpio in
|
$cmdgpio mode $buzzergpio in
|
||||||
|
|
||||||
$cmdgpio mode $strobogpio out
|
$cmdgpio mode $strobegpio out
|
||||||
$cmdgpio write $strobogpio 1
|
$cmdgpio write $strobegpio 1
|
||||||
|
|
||||||
$cmdgpio mode $swdowngpio in
|
$cmdgpio mode $swdowngpio in
|
||||||
$cmdgpio mode $swupgpio in
|
$cmdgpio mode $swupgpio in
|
||||||
|
|
||||||
|
volumevalue=0
|
||||||
|
$cmdamixer -q -c 2 sset 'Speaker' $volumevalue%
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
|
||||||
buzzerstat="$($cmdgpio read $buzzgpio)"
|
buzzerstat="$($cmdgpio read $buzzergpio)"
|
||||||
swupstat="$($cmdgpio read $swupgpio)"
|
swupstat="$($cmdgpio read $swupgpio)"
|
||||||
|
swdownstat="$($cmdgpio read $swdowngpio)"
|
||||||
|
|
||||||
if [ "$buzzerstat" -eq 0 ] && [ "$swupstat" -eq 0 ]; then
|
if [ "$buzzerstat" -eq 0 ] && [ "$swupstat" -eq 0 ]; then
|
||||||
/home/pi/RandomVideo/RandomVideo.sh buzzer
|
~/RandomVideo/RandomVideo.sh buzzer
|
||||||
$cmdgpio write $strobogpio 0; sleep 1; $cmdgpio write $strobogpio 1 &
|
$cmdgpio write $strobegpio 0; sleep $strobeduration; $cmdgpio write $strobegpio 1 &
|
||||||
|
sleep $buzzertimeout
|
||||||
sleep 1
|
|
||||||
|
|
||||||
elif [ "$swupstat" -eq 1 ]; then
|
elif [ "$swupstat" -eq 1 ]; then
|
||||||
|
|
||||||
if $(command -v pgrep) "$pgrepplayer" > /dev/null; then
|
if pgrep "$pgrepplayer" > /dev/null; then
|
||||||
$(command -v pkill) "$pgrepplayer"
|
pkill "$pgrepplayer"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$(command -v $player) $playerparam --loop ~/RandomVideo/onair.mp4 &
|
$playerfull $playerloop ~/RandomVideo/onair.mp4 &
|
||||||
|
|
||||||
while [ "$swupstat" -eq 1 ]; do
|
while [ "$swupstat" -eq 1 ]; do
|
||||||
swupstat="$($cmdgpio read $swupgpio)"
|
swupstat="$($cmdgpio read $swupgpio)"
|
||||||
sleep 0.1
|
sleep $pollingtime
|
||||||
done
|
done
|
||||||
|
|
||||||
$(command -v pkill) "$pgrepplayer"
|
pkill "$pgrepplayer"
|
||||||
|
|
||||||
|
elif [ "$volumevalue" -eq 0 ] && [ "$swdownstat" -eq 1 ]; then
|
||||||
|
|
||||||
|
while [ "$volumevalue" -lt "$volumemax" ] || [ "$buzzerstat" -eq 0 ]; do
|
||||||
|
volumevalue=$((volumevalue + 1))
|
||||||
|
$cmdamixer -q -c 2 sset 'Speaker' $volumevalue%
|
||||||
|
buzzerstat="$($cmdgpio read $buzzergpio)"
|
||||||
|
sleep $volumetimeout
|
||||||
|
done
|
||||||
|
|
||||||
|
elif [ "$volumevalue" -gt 0 ] && [ "$swdownstat" -eq 0 ]; then
|
||||||
|
|
||||||
|
while [ "$volumevalue" -gt 0 ] || [ "$swdownstat" -eq 1 ]; do
|
||||||
|
volumevalue=$((volumevalue -1))
|
||||||
|
$cmdamixer -q -c 2 sset 'Speaker' $volumevalue%
|
||||||
|
swdownstat="$($cmdgpio read $swdowngpio)"
|
||||||
|
sleep $volumetimeout
|
||||||
|
done
|
||||||
|
|
||||||
elif [ "$buzzerstat" -eq 1 ] && [ "$swupstat" -eq 0 ]; then
|
elif [ "$buzzerstat" -eq 1 ] && [ "$swupstat" -eq 0 ]; then
|
||||||
sleep 0.1
|
sleep $pollingtime
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue