Skip to content

Commit

Permalink
second swipe option: do nothing #228
Browse files Browse the repository at this point in the history
  • Loading branch information
MiczFlor committed Oct 1, 2018
1 parent b651a1a commit f6d5cfa
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 33 deletions.
8 changes: 1 addition & 7 deletions docs/MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,13 +479,10 @@ static domain_name_servers=192.168.178.1
~~~~
Save the changes with `Ctrl & O` then `Enter` then `Ctrl & X`.



## <a name="addmultiplewifissids"></a>I want to add another wifi-ssid e.g. at a friend?
## <a name="addmultiplewifissids"></a>I want to add another Wi-ssid e.g. at a friend?
To add multiple wifi networks you can simply add and ssid section into dhcpd.conf.
This can be usefull if you take your phoniebox on a trip to a friend or want to control it on the go by let the phoniebox connect to your mobiles own hotspot.


~~~~
$ sudo nano /etc/dhcpcd.conf
~~~~
Expand Down Expand Up @@ -538,7 +535,6 @@ Be aware your PI is using your perhaps expensive 3G data plan (e.g. in foreign c
**Hotel use / Hotspot use:**
Be aware that everyone on that wifi can connect to your Pi and could at least control mpc and upload files


To always be able to connect to your phoniebox no matter what IP config the network has, be sure to know the hostname (default:raspberry) or change it to a more unique one
~~~
$ sudo nano /etc/hostname
Expand All @@ -558,8 +554,6 @@ $ sudo reboot
* via browser http://phoniebox (be sure to use the http:// - if it didn't work, it could be you land on phoniebox.de ;) )
* via ssh using phoniebox:22



## <a name="faqAudioNotWorking"></a>Audio is not working

This might occur if you are using external sound cards like *pHat BEAT* or the like. I split this into two parts: a) sound did never work and b) sound worked once, now, with a new soundcard, it doesn't.
Expand Down
75 changes: 49 additions & 26 deletions scripts/rfid_trigger_play.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#############################################################
# $DEBUG true|false
DEBUG=false
DEBUG=true

# Set the date and time of now
NOW=`date +%Y-%m-%d.%H:%M:%S`
Expand Down Expand Up @@ -314,32 +314,60 @@ if [ ! -z "$FOLDER" -a ! -z ${FOLDER+x} -a -d "${AUDIOFOLDERSPATH}/${FOLDER}" ];

# Second Swipe value
if [ $DEBUG == "true" ]; then echo "Var \$SECONDSWIPE: ${SECONDSWIPE}" >> $PATHDATA/../logs/debug.log; fi
# Playlist name
if [ $DEBUG == "true" ]; then echo "Var \$PLAYLISTNAME: ${PLAYLISTNAME}" >> $PATHDATA/../logs/debug.log; fi

# check if
# - $SECONDSWIPE is set to toggle pause/play ("$SECONDSWIPE" == "PAUSE")
# - AND (-a)
# Setting a VAR to start "play playlist from start"
# This will be changed in the following checks "if this is the second swipe"
PLAYPLAYLIST=yes

# Check if the second swipe happened
# - The same playlist is cued up ("$LASTPLAYLIST" == "$PLAYLISTNAME")
# - AND (-a)
# - check the length of the playlist, if =0 then it was cleared before, a state, which should only
# be possible after a reboot ($PLLENGTH -gt 0)
PLLENGTH=$(echo -e "status\nclose" | nc -w 1 localhost 6600 | grep -o -P '(?<=playlistlength: ).*')
if [ "$SECONDSWIPE" == "PAUSE" -a "$LASTPLAYLIST" == "$PLAYLISTNAME" -a $PLLENGTH -gt 0 ]
if [ "$LASTPLAYLIST" == "$PLAYLISTNAME" ]
then
STATE=$(echo -e "status\nclose" | nc -w 1 localhost 6600 | grep -o -P '(?<=state: ).*')
if [ $STATE == "play" ]
if [ $DEBUG == "true" ]; then echo "Second Swipe DID happen: \$LASTPLAYLIST == \$PLAYLISTNAME" >> $PATHDATA/../logs/debug.log; fi

# check if
# - $SECONDSWIPE is set to toggle pause/play ("$SECONDSWIPE" == "PAUSE")
# - AND (-a)
# - AND (-a)
# - check the length of the playlist, if =0 then it was cleared before, a state, which should only
# be possible after a reboot ($PLLENGTH -gt 0)
PLLENGTH=$(echo -e "status\nclose" | nc -w 1 localhost 6600 | grep -o -P '(?<=playlistlength: ).*')
if [ "$SECONDSWIPE" == "PAUSE" -a $PLLENGTH -gt 0 ]
then
# The following involves NOT playing the playlist, so we set:
PLAYPLAYLIST=no

STATE=$(echo -e "status\nclose" | nc -w 1 localhost 6600 | grep -o -P '(?<=state: ).*')
if [ $STATE == "play" ]
then
if [ $DEBUG == "true" ]; then echo "MPD playing, pausing the player" >> $PATHDATA/../logs/debug.log; fi
sudo $PATHDATA/playout_controls.sh -c=playerpause &>/dev/null
else
if [ $DEBUG == "true" ]; then echo "MPD not playing, start playing" >> $PATHDATA/../logs/debug.log; fi
sudo $PATHDATA/playout_controls.sh -c=playerplay &>/dev/null
fi
if [ $DEBUG == "true" ]; then echo "Completed: toggle pause/play" >> $PATHDATA/../logs/debug.log; fi
elif [ "$SECONDSWIPE" == "NOAUDIOPLAY" ]
then
if [ $DEBUG == "true" ]; then echo "MPD playing, pausing the player" >> $PATHDATA/../logs/debug.log; fi
sudo $PATHDATA/playout_controls.sh -c=playerpause &>/dev/null
else
if [ $DEBUG == "true" ]; then echo "MPD not playing, start playing" >> $PATHDATA/../logs/debug.log; fi
sudo $PATHDATA/playout_controls.sh -c=playerplay &>/dev/null
# The following involves NOT playing the playlist, so we set:
PLAYPLAYLIST=no

# "$SECONDSWIPE" == "NOAUDIOPLAY"
# "$LASTPLAYLIST" == "$PLAYLISTNAME" => same playlist triggered again
# => do nothing
# echo "do nothing" > /dev/null 2>&1
if [ $DEBUG == "true" ]; then echo "Completed: do nothing" >> $PATHDATA/../logs/debug.log; fi
fi
elif [ "$SECONDSWIPE" == "RESTART" ]
fi
# now we check if we are still on for playing what we got passed on:
if [ "$PLAYPLAYLIST" == "yes" ]
then
if [ $DEBUG == "true" ]; then echo "We must play the playlist no matter what: \$PLAYPLAYLIST == yes" >> $PATHDATA/../logs/debug.log; fi

# Above we already checked if the folder exists -d "$AUDIOFOLDERSPATH/$FOLDER"
# Now we check if we need to play from start.
#
# if this is not a "second swipe", check if folder $FOLDER exists and play content
# the process is as such - because of the recursive play option:
# - each folder can be played.
# - a single folder will create a playlist with the same name as the folder
Expand All @@ -364,15 +392,10 @@ if [ ! -z "$FOLDER" -a ! -z ${FOLDER+x} -a -d "${AUDIOFOLDERSPATH}/${FOLDER}" ];
if [ $DEBUG == "true" ]; then echo "Command: $PATHDATA/playout_controls.sh -c=playlistaddplay -v=\"${PLAYLISTNAME}\" -d=\"${FOLDER}\"" >> $PATHDATA/../logs/debug.log; fi
# the variable passed on to play is NOT the folder name, but the playlist name
# because (see above) a folder can be played recursively (including subfolders) or flat (only containing files)
sudo echo ${PLAYLISTNAME} > $PATHDATA/../settings/Latest_Playlist_Played
sudo chmod 777 $PATHDATA/../settings/Latest_Playlist_Played
$PATHDATA/playout_controls.sh -c=playlistaddplay -v="${PLAYLISTNAME}" -d="${FOLDER}"
#elif [ "$SECONDSWIPE" == "NOAUDIOPLAY" ]
#then
# "$SECONDSWIPE" == "NOAUDIOPLAY"
# => do nothing
# commented out because error if no statement given...
fi
sudo echo ${PLAYLISTNAME} > $PATHDATA/../settings/Latest_Playlist_Played
sudo chmod 777 $PATHDATA/../settings/Latest_Playlist_Played
else
if [ $DEBUG == "true" ]; then echo "Path not found $AUDIOFOLDERSPATH/$FOLDER" >> $PATHDATA/../logs/debug.log; fi
fi

0 comments on commit f6d5cfa

Please sign in to comment.