From d07d8378a8c0eb95a68e8996db25c9a596e72e47 Mon Sep 17 00:00:00 2001 From: mmaster Date: Tue, 21 Sep 2021 23:05:25 +0200 Subject: [PATCH] some documentation --- check_playerproc.sh | 4 ++-- poll_button.sh | 22 +++++++++++----------- randomvideo.sh | 32 ++++++++++++++++++++++++++++---- view_birdcam.sh | 26 +++++++++++++------------- 4 files changed, 54 insertions(+), 30 deletions(-) mode change 100644 => 100755 randomvideo.sh diff --git a/check_playerproc.sh b/check_playerproc.sh index 75b1cac..6f82c65 100755 --- a/check_playerproc.sh +++ b/check_playerproc.sh @@ -25,8 +25,8 @@ if [ -z "$gpiocmd" ]; then fi fi -player="vlc" -gpiopin_led_b="28" +player="vlc" ### var: player process +gpiopin_led_b="28" ### var: gpio led $gpiocmd mode $gpiopin_led_b out $gpiocmd write $gpiopin_led_b 0 diff --git a/poll_button.sh b/poll_button.sh index 5cc3d37..76b45ae 100755 --- a/poll_button.sh +++ b/poll_button.sh @@ -25,16 +25,16 @@ if [ -z "$gpiocmd" ]; then fi fi -gpiopin_sw="0" ### var -gpiopin_led_r="2" ### var -gpiopin_led_g="29" ### var +gpiopin_sw="0" ### var: gpio switch +gpiopin_led_r="2" ### var: gpio led red +gpiopin_led_g="29" ### var: gpio led green -cameracmd="/home/pi/birdcam/view_birdcam.sh" ### var +cameracmd="/home/pi/birdcam/view_birdcam.sh" ### var: path to player script -buttonpolling="0.05" ### var: seconds -buttontimeout="1" ### var: seconds -countermax="1200" ### var: countermax=time/buttonpolling +buttonpolling="0.05" ### var: button polling in seconds +buttontimeout="1" ### var: button timeout in seconds +countermax="1200" ### var: counter max for automatic switching (countermax=time/buttonpolling) $gpiocmd mode $gpiopin_led_g out $gpiocmd write $gpiopin_led_g 0 @@ -52,7 +52,7 @@ while true; do $gpiocmd write $gpiopin_led_g 0 $gpiocmd mode $gpiopin_led_r in - camname="random" ### var + camname="random" ### var: parameter for random video $cameracmd $camname & echo "$camname started!" sleep $buttontimeout @@ -68,7 +68,7 @@ while true; do $gpiocmd write $gpiopin_led_g 0 $gpiocmd mode $gpiopin_led_r in - camname="birdcam1" ### var + camname="birdcam1" ### var: parameter for camera 1 $cameracmd $camname & echo "$camname started!" sleep $buttontimeout @@ -84,9 +84,9 @@ while true; do $gpiocmd write $gpiopin_led_g 0 $gpiocmd mode $gpiopin_led_r in - camname="birdcam2" ### var + camname="birdcam2" ### var: parameter for camera 2 $cameracmd $camname & echo "$camname started!" sleep $buttontimeout -done \ No newline at end of file +done diff --git a/randomvideo.sh b/randomvideo.sh old mode 100644 new mode 100755 index 26f82a7..9db0254 --- a/randomvideo.sh +++ b/randomvideo.sh @@ -1,10 +1,34 @@ #!/bin/sh -folder="/home/pi/Video" -player="cvlc" -playerparam="--no-osd --play-and-exit" +folder="/home/pi/Video" ### var: path to video files +player="cvlc" ### var: player command +playerparam="--no-osd --play-and-exit" ### var: player parameters + +player_path="$(command -v $player)" + +player_package="vlc" ### var: player apt package + +if [ -z "$player_path" ]; then + echo "Missing $player, try to install it ..." + + echo "Check internet connection ..." + pingserver="raspbian.raspberrypi.org" ### var: pingcheck destination + if ! ping -q -c1 $pingserver>/dev/null; then + echo "No internet connection ..." + exit 0 + fi + + sudo apt-get update; sudo apt-get -y install $player_package + + player_path="$(command -v $player)" + + if [ -z "$player_path" ]; then + echo "Cannot install $player, exiting ..." + exit 0 + fi +fi while true; do file="$(find "$folder" -maxdepth 1 -type f |sort -R |head -n1)" $player $playerparam $file -done \ No newline at end of file +done diff --git a/view_birdcam.sh b/view_birdcam.sh index b231633..180ff0d 100755 --- a/view_birdcam.sh +++ b/view_birdcam.sh @@ -1,8 +1,8 @@ #!/bin/sh -player="cvlc" ### var -player_path="$(command -v $player)" ### var -player_package="vlc" ### var +player="cvlc" ### var: player command +player_path="$(command -v $player)" +player_package="vlc" ### var: player apt package if [ -z "$player_path" ]; then echo "Missing $player, try to install it ..." @@ -29,13 +29,13 @@ if [ -z "$1" ]; then exit 0 fi -cameralist="~/birdcam/conf/cameralist.txt" ### var -playerproc="vlc" ### var -playerparam="--no-osd --play-and-exit" ### var -streamurl="rtsp://$1:554/user=admin&password=&channel=1&stream=0.sdp?real_stream" ### var +cameralist="/home/pi/birdcam/conf/cameralist.txt" ### var: list of all cameras/commands file +playerproc="vlc" ### var: media player process name +playerparam="--no-osd --play-and-exit" ### var: media player parameters +streamurl="rtsp://$1:554/user=admin&password=&channel=1&stream=0.sdp?real_stream" ### var: camera stream url -randomvideosh="/home/pi/birdcam/randomvideo.sh" ### var -randomvideoproc="randomvideo.sh" ### var +randomvideosh="/home/pi/birdcam/randomvideo.sh" ### var: path to random video script +randomvideoproc="randomvideo.sh" ### var: name of process for random video script if [ ! -z "$(pgrep $playerproc)" ]; then pkill $playerproc @@ -45,19 +45,19 @@ if [ ! -z "$(pgrep $randomvideoproc)" ]; then pkill $randomvideoproc fi -if [ "$1" = "random" ]; then ### var +if [ "$1" = "random" ]; then $randomvideosh exit 0 fi -if [ "$1" = "birdcam1" ]; then ### var +if [ "$1" = "birdcam1" ]; then ### var: hostname camera1 $player_path $playerparam "$streamurl" -elif [ "$1" = "birdcam2" ]; then ### var +elif [ "$1" = "birdcam2" ]; then ### var: hostname camera2 $player_path $playerparam "$streamurl" else echo "Wrong camera! Available cameras:" cat $cameralist -fi \ No newline at end of file +fi