Ejemplo n.º 1
0
	def index(self,**kwargs):
		cherrypy.response.headers['Content-Type']="application/json"
		jsonInput=cherrypy.request.json
		data=jsonInput

		returnMessage=''
		currentAnimation=""
		LEDState=1

		#print kwargs

		for jsonItem in jsonInput:
			print "ITEM: ", jsonItem
			print "DATA[ITEM]: ",data[jsonItem]
	
			if jsonItem=="SPECTRUM":
				print "IN SPECTRUM"
				trackerDict["currentAnimation"]="SPECTRUM"
				gpioManager.clearAnimationGPIO()
				gpioManager.spectrumAnimation(data[jsonItem])
				returnMessage.join("Spectrum Mode On ")

			elif jsonItem=="RING":
				print "IN RING"
				trackerDict["currentAnimation"]="RING"
				gpioManager.clearAnimationGPIO()
				gpioManager.ringAnimation(data[jsonItem])
				returnMessage.join("Ring Mode On ")

			elif jsonItem=="RANDOM":
				print "IN RANDOM"
				trackerDict["currentAnimation"]="RANDOM"
				gpioManager.clearAnimationGPIO()
				gpioManager.rndAnimation(data[jsonItem])
				returnMessage.join("Random Mode On ")

			elif jsonItem=="RGSTRIPS":
				print "IN RGSTRIPS"
				trackerDict["currentAnimation"]="RGSTRIPS"
				gpioManager.clearAnimationGPIO()
				gpioManager.rgStripsAnimation(data[jsonItem])
				returnMessage.join("RG Strip Mode On ")

			elif jsonItem=="RGLEVEL":
				print "IN RGLEVEL"
				trackerDict["currentAnimation"]="RGLEVEL"
				gpioManager.clearAnimationGPIO()
				gpioManager.rgLevelAnimation(data[jsonItem])
				returnMessage.join("RG Level Mode On ")

			elif jsonItem == "LED":
				print "IN LED"
				trackerDict["LEDState"]=data[jsonItem]
				gpioManager.lightsState(data[jsonItem])
				returnMessage.join("LED state changed")

			elif jsonItem == "BOUNCE":
				print "IN BOUNCE"
				trackerDict["currentAnimation"]="BOUNCE"
				gpioManager.lightsState(data[jsonItem])
				returnMessage.join("BOUNCE Mode on")

			#The following items are used to manipulate music and requires a queue
			elif jsonItem=="PAUSE":
				print "IN PAUSE"
				gpioManager.playing(False)
				#Add command and state to the queue
				queueLock.acquire()
				musicCommandQueue.put(jsonItem)
				musicCommandQueue.put(data[jsonItem])
				queueLock.release()
			elif jsonItem=="PLAY":
				print "IN PLAY"
				gpioManager.playing(True)
				#Add command and state to the queue
				queueLock.acquire()
				musicCommandQueue.put(jsonItem)
				musicCommandQueue.put(data[jsonItem])
				queueLock.release()

			#NOTE: Skip and Stop doesn't work
			elif jsonItem=="SKIP":
				print "IN SKIP"
				#Add command and state to the queue
				queueLock.acquire()
				musicCommandQueue.put(jsonItem)
				musicCommandQueue.put(data[jsonItem])
				queueLock.release()
			elif jsonItem=="STOP":
				print "IN STOP"
				#Add command and state to the queue
				queueLock.acquire()
				musicCommandQueue.put(jsonItem)
				musicCommandQueue.put(data[jsonItem])
				queueLock.release()

			#This one is only used when the android app wants to get data. This is still in testing
			elif jsonItem=="FETCH":
				return {trackerDict['currentAnimation']:1,"LED":trackerDict['LEDState']}
				return "Here is something...."

			else:
				print "Something is wrong"
				returnMessage.join("Error")

		#return rtnMessage
		return returnMessage
Ejemplo n.º 2
0
def LEDOff():
	while currMonth==11 or currMonth==12:
		while not inTimeFrame():
			gpioManager.lightsState(True)