#! /bin/sh -
# interface.sh - Wifi Radio User Interface Script
# 01/29/09      Jeff Keyzer     http://mightyohm.com
# 01/29/09      Gary Dion     http://garydion.com
#
# The script expects the AVR to send data at 19200 baud (8N1) to the router,
#
# For more information, visit
# http://garydion.com/projects/wifiradio/
#
# This work is protected by the
# Creative Commons Attribution-Share Alike 3.0 United States License.
# http://creativecommons.org/licenses/by-sa/3.0/us/

# Some configuration settings
VOLUME = 100

trap 'kill $! ; exit 1' SIGINT  # exit on ctrl-c, useful for debugging
                                # kills the display.sh process before exiting

stty 19200 -echo < /dev/tts/0   # set serial port to 9600 baud
                                # so we can talk to the AVR
                                # turn off local echo to make TX/RX directions
                                # completely separate from each other

# mpd setup
mpc volume $VOLUME              # adjust this to suit your speakers/amplifier
mpc clear                       # clear current playlist
mpc load 1                      # load stock playlist

while true        # loop forever
do
   echo "currentsong" | nc localhost 6600 | grep -e "^Title: " -e "^Name: " > /dev/tts/0
   mpc | grep -e "playing" -e "volume" > /dev/tts/0
   sleep 1
done

