class HazerDmxControl: def __init__(self, serialPort): self.dmx = DmxPy(serialPort) self.hazeChannel = 1 self.fanChannel = 2 def _percentToDMXRange(self, percentage): return int(round((percentage / 100.0) * 255)) def _calcAndSend(self, channel, percentage): self.dmx.setChannel(channel, self._percentToDMXRange(percentage)) print("Sending to channel: ", channel, " percentage: ", percentage, " dmx range:", self._percentToDMXRange(percentage)) self.dmx.render() def setHazeIntensity(self, hazePercentage): self._calcAndSend(self.hazeChannel, hazePercentage) def setFanSpeed(self, fanPercentage): self._calcAndSend(self.fanChannel, fanPercentage)
Lights.cleanup() break # stops the loop else: #Turn off the reader until function finishes. os.system("/home/pi/Christmas-2015/Scripts/disableRFID.sh") Popen(['mpg321', '/home/pi/Christmas-2015/Assets/ChristmasOpener.mp3'], stdout=PIPE, close_fds=True) #Trigger GPIO Pins 33 to turn on project0r. Then wait 30 seconds for the audio to finish #Lights.off([37]) #time.sleep(27) #Lights.on({37}) #Do the DMX thing instead. dmx.setChannel(1, 255) dmx.setChannel(2, 255) dmx.setChannel(3, 255) dmx.setChannel(4, 255) dmx.render() time.sleep(27) dmx.setChannel(1, 0) dmx.setChannel(2, 0) dmx.setChannel(3, 0) dmx.setChannel(4, 0) dmx.render() #Turn the reader back on. os.system("/home/pi/Halloween2015/Scripts/enableRFID.sh")
dmx = DmxPy('/dev/ttyUSB0') while True: # Runs until break is encountered. We want to set it to break on a particular ID. n = raw_input("Scanned ID: ") currentScan = time.time() if n == "STOP": break # stops the loop else : dbConn.logAccess(n) #Play Music File os.system('mpg321 /home/pi/Python/Assets/christmas.mp3 -q &') # Turn On Projectors dmx.setChannel(2,255) dmx.render() # Blink Lights count = 0 while (count < 28): dmx.setChannel(1, 255) dmx.render() time.sleep(.5) dmx.setChannel(1, 0) dmx.render() time.sleep(.5) count = count + 1 # Return Lights to normal. Turn off Projectors dmx.setChannel(2,0) dmx.setChannel(1,255)