From 08c1adaa40b0204f500bf95492ef999f61cd8dc3 Mon Sep 17 00:00:00 2001 From: aouvrard Date: Sun, 22 Jan 2017 12:36:23 +0100 Subject: AOU:ajout du pi3 --- README | 9 --------- README.md | 9 +++++++++ btn_track.sh | 37 ------------------------------------- btn_track_pi1.sh | 37 +++++++++++++++++++++++++++++++++++++ btn_track_pi3.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 92 insertions(+), 46 deletions(-) delete mode 100644 README create mode 100644 README.md delete mode 100644 btn_track.sh create mode 100644 btn_track_pi1.sh create mode 100644 btn_track_pi3.sh diff --git a/README b/README deleted file mode 100644 index b494f79..0000000 --- a/README +++ /dev/null @@ -1,9 +0,0 @@ -This project contain files to transform raspbian on web radio player with one button to manage. - -#Installation -- Start from raspbian jessie 8 -- Add a simple push button on GPIO number 24. -- Install mpd `apt install mpd mpc` -- Copy/Paste btn_track.sh script in $HOME -- Create mpc.service -`sudo nano /etc/systemd/system/mpc.service` diff --git a/README.md b/README.md new file mode 100644 index 0000000..b494f79 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +This project contain files to transform raspbian on web radio player with one button to manage. + +#Installation +- Start from raspbian jessie 8 +- Add a simple push button on GPIO number 24. +- Install mpd `apt install mpd mpc` +- Copy/Paste btn_track.sh script in $HOME +- Create mpc.service +`sudo nano /etc/systemd/system/mpc.service` diff --git a/btn_track.sh b/btn_track.sh deleted file mode 100644 index c6a3ce5..0000000 --- a/btn_track.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -#Set GPIO ID with push button -GPIO_ID="24" - -#Initialize GPIO -echo $GPIO_ID > /sys/class/gpio/export -echo in > /sys/class/gpio/gpio$GPIO_ID/direction - -#Start MPC -mpc clear -mpc load radios -mpc repeat on -mpc play - -printf "MPC started" - -i=0 -echo "Loop check push" -while : -do - until /bin/grep 1 /sys/class/gpio/gpio$GPIO_ID/value >> /dev/null - do - /bin/sleep .1 - done - - let i++ - if [ $i -ge 30 ] - then - printf "Shutdown by button" - sudo systemctl poweroff - break - fi - - echo "Next Track" - mpc next -done diff --git a/btn_track_pi1.sh b/btn_track_pi1.sh new file mode 100644 index 0000000..c6a3ce5 --- /dev/null +++ b/btn_track_pi1.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +#Set GPIO ID with push button +GPIO_ID="24" + +#Initialize GPIO +echo $GPIO_ID > /sys/class/gpio/export +echo in > /sys/class/gpio/gpio$GPIO_ID/direction + +#Start MPC +mpc clear +mpc load radios +mpc repeat on +mpc play + +printf "MPC started" + +i=0 +echo "Loop check push" +while : +do + until /bin/grep 1 /sys/class/gpio/gpio$GPIO_ID/value >> /dev/null + do + /bin/sleep .1 + done + + let i++ + if [ $i -ge 30 ] + then + printf "Shutdown by button" + sudo systemctl poweroff + break + fi + + echo "Next Track" + mpc next +done diff --git a/btn_track_pi3.sh b/btn_track_pi3.sh new file mode 100644 index 0000000..e359a9d --- /dev/null +++ b/btn_track_pi3.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +#Set GPIO ID with push button +GPIO_ID="24" + +#Initialize GPIO +echo $GPIO_ID > /sys/class/gpio/export +echo in > /sys/class/gpio/gpio$GPIO_ID/direction + +#Start MPC +mpc clear +mpc load radios +mpc repeat on +mpc play + +printf "MPC started" + + +i=0 +echo "Loop check push" +while : +do + until /bin/grep 1 /sys/class/gpio/gpio$GPIO_ID/value >> /dev/null + do + /bin/sleep .1 + i=0 + done + + echo i=$i + + let i++ + if [ $i -ge 3 ] + then + printf "Shutdown by button" + sudo systemctl poweroff + break + fi + + if [ $i -ge 1 ] + then + echo "Next Track" + mpc next + /bin/sleep .5 + fi +done + -- cgit v1.2.3