コード例 #1
0
ファイル: menupage1.py プロジェクト: halcyon22/Pandora-Pi
    def button3(self):
        self.logger.info('Page 1 - Button 3 - Vol Down')
    
        pandoraUtils.writeToLCD("Volume", "Down")
        pandoraUtils.sendCommand('((((')

        pandoraUtils.parseAndWrite(2)
コード例 #2
0
ファイル: menupage1.py プロジェクト: halcyon22/Pandora-Pi
    def button4(self):
        self.logger.info('Page 1 - Button 4 - Vol Up')

        pandoraUtils.writeToLCD("Volume", "Up")
        pandoraUtils.sendCommand('))))')

        pandoraUtils.parseAndWrite(2)
コード例 #3
0
def getIPAddress():

	s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
	s.connect(('google.com', 0))
	IPaddr = s.getsockname()[0]

	pandoraUtils.writeToLCD("IP Address:", IPaddr)
コード例 #4
0
ファイル: menupage2.py プロジェクト: halcyon22/Pandora-Pi
    def button2(self):
        self.logger.info('Page 2 - Button 2 - DisLike')

        pandoraUtils.writeToLCD("Disliking", pandoraUtils.getShared("song"))
        pandoraUtils.sendCommand('-')

        pandoraUtils.parseAndWrite(2)
コード例 #5
0
ファイル: menupage3.py プロジェクト: halcyon22/Pandora-Pi
    def button2(self):
        self.logger.info('Page 3 - Button 2 - Off')

        pandoraUtils.writeToLCD("Shutting Down", "Thanks")
        pandoraUtils.sendCommand('q')

        sleep(2)
        state.current_menu = menupower.MenuPower()
        state.current_menu.show_menu()
コード例 #6
0
ファイル: menupage1.py プロジェクト: halcyon22/Pandora-Pi
    def button5(self):
        self.logger.info('Page 1 - Button 5 - Play/Pause')

        if state.playing_stream == "Playing":
            pandoraUtils.writeToLCD("Paused")
            state.playing_stream = "Paused"
        else:
            pandoraUtils.writeToLCD("Playing")
            state.playing_stream = "Playing"
            pandoraUtils.parseAndWrite(2)

        pandoraUtils.sendCommand('p')
コード例 #7
0
ファイル: eventReciever.py プロジェクト: halcyon22/Pandora-Pi
def main():

    pandoraUtils.initLogging()
    logger = logging.getLogger('eventReceiver')

    # Read event type from command arguments
    if len(sys.argv) < 2:
        logger.error("Error reading event type from command arguments")
        return

    event_type = sys.argv[1]
    logger.info("event_type="+event_type)

    # Read parameters from input
    params = {}
    
    for s in sys.stdin.readlines():
        param, value = s.split("=", 1)
        params[param.strip()] = value.strip()

    # Handle specific events
    if event_type == "songstart":

        info = {}
        info["song"] = params["title"]
        info["artist"] = params["artist"]
        info["album"] = params["album"]
        info["stationCount"] = params["stationCount"]
        info["stationName"] = params["stationName"]

        stations = []

        for i in range(0, int(params["stationCount"])):
            stations.append(params["station"+str(i)])

            if params["station"+str(i)] == params["stationName"]:
                info["stationNumber"] = i

        info["stations"] = stations

        pandoraUtils.setShared(info)
        pandoraUtils.parseAndWrite()

    elif event_type == "songfinish":
        pass

    elif event_type == "usergetstations":
        previous_station = pandoraUtils.getShared("stationNumber")
        if (previous_station != None):
            pandoraUtils.sendCommand('s'+str(previous_station))

    elif event_type == "userlogin":
        pandoraUtils.writeToLCD("Logging in...")
コード例 #8
0
ファイル: menupage1.py プロジェクト: halcyon22/Pandora-Pi
    def button2(self):
        self.logger.info('Page 1 - Button 2 - Next Station')

        current_station = pandoraUtils.getShared("stationNumber")
        station_count = pandoraUtils.getShared("stationCount")
        next_station = current_station + 1
        if (next_station >= station_count):
            next_station = 0

        self.logger.info('next station: '+str(next_station))

        pandoraUtils.writeToLCD("Next", "Station")
        pandoraUtils.sendCommand('s'+str(next_station))

        # "listening to .."
        pandoraUtils.parseAndWrite(8, True)
        # display song
        pandoraUtils.parseAndWrite(3)
コード例 #9
0
ファイル: menupower.py プロジェクト: halcyon22/Pandora-Pi
    def button1(self):
        self.logger.info('Power - Button 1 - Start Pandora')

        pandoraUtils.writeToLCD("Pandora Pi", "Starting")
        Popen('sudo -u pi pianobar', shell=True)
        state.current_menu = menupage1.Page1()
コード例 #10
0
ファイル: menupower.py プロジェクト: halcyon22/Pandora-Pi
 def show_menu(self):
     pandoraUtils.writeToLCD("Pandora OFF", "1: Start Pandora")
コード例 #11
0
ファイル: menupage1.py プロジェクト: halcyon22/Pandora-Pi
    def button1(self):
        self.logger.info('Page 1 - Button 1 - Skip Song')

        pandoraUtils.writeToLCD("Skipping", "Song")
        pandoraUtils.sendCommand('n')
コード例 #12
0
ファイル: menupage3.py プロジェクト: halcyon22/Pandora-Pi
    def button1(self):
        self.logger.info('Page 3 - Button 1 - Current Station')

        pandoraUtils.writeToLCD(pandoraUtils.getShared("stationName"))
        pandoraUtils.parseAndWrite(2)
コード例 #13
0
ファイル: menupage3.py プロジェクト: halcyon22/Pandora-Pi
 def show_menu(self):
     pandoraUtils.writeToLCD("1:Current Station", "2:Off 6:Now Playing")
コード例 #14
0
def main():

	global playing_stream
	global current_screen

	pandoraUtils.writeToLCD("Pandora Pi", "Starting")
	
	sleep(4)
	
	pandoraUtils.parseAndWrite()

	while True:

		# Default Page

		if ( GPIO.input(2) == False  and current_screen == "default"):
			
			pandoraUtils.log('Button 1 - Skip Song')
			pandoraUtils.writeToLCD("Skipping", "Song")
			os.system('echo "n" >> ' + fifo_folder_location)

		if ( GPIO.input(3) == False  and current_screen == "default"):

			pandoraUtils.log('Button 2 - Skip Station')
			pandoraUtils.writeToLCD("Next", "Station")
			current_station = randint(1,total_stations)
			os.system('echo "s' + str(current_station) + '" >> ' + fifo_folder_location)

			parseAndWrite(8, True)

			parseAndWrite(3)


		if ( GPIO.input(4)== False  and current_screen == "default"):

			pandoraUtils.log('Button 3 - Vol Down')
			pandoraUtils.writeToLCD("Volume", "Down")
			os.system('echo "((((" >> ' + fifo_folder_location)

			sleparseAndWriteep(2)


		if ( GPIO.input(17)== False  and current_screen == "default"):

			pandoraUtils.log('Button 4 - Vol Up')
			pandoraUtils.writeToLCD("Volume", "Up")
			os.system('echo "))))" >> ' + fifo_folder_location)

			parseAndWrite(2)


		if ( GPIO.input(27)== False  and current_screen == "default"):

			pandoraUtils.log('Button 5 - Play/Pause')

			if playing_stream == "Playing":
				pandoraUtils.writeToLCD("Paused", "")
				playing_stream = "Paused"
			else:
				pandoraUtils.writeToLCD("Playing", "")
				playing_stream = "Playing"
				parseAndWrite(2)

			os.system('echo "p" >> ' + fifo_folder_location)

			
		if ( GPIO.input(22)== False  and current_screen == "default"):

			pandoraUtils.log('Button 6 - Menu')
			
			pandoraUtils.writeToLCD("Pandora Pi", "Menu")
			sleep(.75)

			pandoraUtils.writeToLCD("1:Like 2:Dislike", "3:IP 4:Next Pg")
			current_screen = "menupg1"

		# Menu Page 1

		if ( GPIO.input(2) == False  and current_screen == "menupg1"):

			pandoraUtils.log('Button 6 - Menu - Sub 1 - Like')
			pandoraUtils.writeToLCD("Liking", pandoraUtils.getShared("song"))
			os.system('echo "+" >> ' + fifo_folder_location)

			parseAndWrite(2)
			

		if ( GPIO.input(3) == False  and current_screen == "menupg1"):

			pandoraUtils.log('Button 6 - Menu - Sub 2 - DisLike')
			pandoraUtils.writeToLCD("Disliking", pandoraUtils.getShared("song"))
			os.system('echo "-" >> ' + fifo_folder_location)

			parseAndWrite(2)

		if ( GPIO.input(4) == False  and current_screen == "menupg1"):

			pandoraUtils.log('Button 6 - Menu - Sub 3 - IP Address')
			getIPAddress()

			parseAndWrite(5)


		if ( GPIO.input(17) == False  and current_screen == "menupg1"):

			pandoraUtils.writeToLCD("1:Prev Pg 2:Cur St", "3:Off 4:Next Pg")
			current_screen = "menupg2"

		# Menu Page 2

		if ( GPIO.input(2) == False  and current_screen == "menupg2"):

			pandoraUtils.log('Button 6 - Menu - Sub 1 - Menu Pg 1')
			pandoraUtils.writeToLCD("1:Like 2:Dislike", "3:IP 4:Next Pg")
			current_screen = "menupg1"

		if ( GPIO.input(3) == False  and current_screen == "menupg2"):

			pandoraUtils.log('Button 6 - Menu - Sub 2 - Station Name')
			pandoraUtils.writeToLCD(pandoraUtils.getShared("stationName"), "")

			parseAndWrite(2)

		# if ( GPIO.input(4) == False  and current_screen == "menupg2"):

		# 	pandoraUtils.log('Button 6 - Menu - Sub 3 - Shutdown')
		# 	pandoraUtils.writeToLCD("Shutting Down", "Thanks")
		# 	pianobarProcess.terminate()
		# 	# os.system('echo "q" >> ' + fifo_folder_location)

		# 	sleep(2)

		# 	pandoraUtils.writeToLCD("Pandora Pi: OFF", "1: Turn ON")
		# 	current_screen = "off"

		# if ( GPIO.input(2) == False  and current_screen == "off"):

		# 	pianobarProcess = Popen('sudo -u pi pianobar', shell=True)

		# 	PandoraUtils.writeToLCD("Pandora Pi", "Starting")
			
		# 	current_screen = "default"

		# 	sleep(4)
	
		# 	pandoraUtils.parseAndWrite()


		sleep(.25)
コード例 #15
0
ファイル: menupage2.py プロジェクト: halcyon22/Pandora-Pi
    def button3(self):
        self.logger.info('Page 2 - Button 3 - IP Address')
        IPaddr = getIPAddress()
        pandoraUtils.writeToLCD("IP Address:", IPaddr)

        pandoraUtils.parseAndWrite(5)
コード例 #16
0
ファイル: menupage2.py プロジェクト: halcyon22/Pandora-Pi
    def show_menu(self):
        pandoraUtils.writeToLCD("Pandora Pi", "Menu")
        sleep(.75)

        pandoraUtils.writeToLCD("1:Like 2:Dislike", "3:IP 4:Next Pg")