Пример #1
0
    def button3(self):
        self.logger.info('Page 1 - Button 3 - Vol Down')
    
        pandoraUtils.writeToLCD("Volume", "Down")
        pandoraUtils.sendCommand('((((')

        pandoraUtils.parseAndWrite(2)
Пример #2
0
    def button4(self):
        self.logger.info('Page 1 - Button 4 - Vol Up')

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

        pandoraUtils.parseAndWrite(2)
Пример #3
0
    def button2(self):
        self.logger.info('Page 2 - Button 2 - DisLike')

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

        pandoraUtils.parseAndWrite(2)
Пример #4
0
def parseAndWrite(secDelay = 0, changedStation = False):

	global current_screen

	current_screen = "default"

	sleep(secDelay)

	pandoraUtils.parseAndWrite(changedStation)
Пример #5
0
    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')
Пример #6
0
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...")
Пример #7
0
    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)
Пример #8
0
    def button6(self):
        self.logger.info('Page 3 - Button 6 - Now Playing')

        state.current_menu = menupage1.Page1()
        pandoraUtils.parseAndWrite()
Пример #9
0
    def button1(self):
        self.logger.info('Page 3 - Button 1 - Current Station')

        pandoraUtils.writeToLCD(pandoraUtils.getShared("stationName"))
        pandoraUtils.parseAndWrite(2)
Пример #10
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)
Пример #11
0
	
	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)])

		info["stations"] = stations

		pandoraUtils.setShared(info)

	elif event_type == "songfinish":
		pass
	elif event_type == "usergetstations":
		pass

	pandoraUtils.parseAndWrite()
Пример #12
0
    def button3(self):
        self.logger.info('Page 2 - Button 3 - IP Address')
        IPaddr = getIPAddress()
        pandoraUtils.writeToLCD("IP Address:", IPaddr)

        pandoraUtils.parseAndWrite(5)