def interrupted(signum, frame): print "Nine minutes have passed. Playing files" # Relay communication is Opposite. On = Off Lights.off([33]) thunderLine(100) Lights.on([33]) signal.alarm(TIMEOUT)
def switchLights(): Lights.switch() Log.write(message='Switched lights (' + ('On' if Lights.value else 'Off') + ')', level=1, startedby=current_user.id) return 'ok'
def importlightRigEnv(self): import Lights PathLightsEnv = 'D:\zebratv\Projects\BOLO\editorial\incoming\LightRigs\Environments/' SelectedFiles = self.ui.listWidget_LightRigEnvironment.selectedItems() for sf in SelectedFiles: RealPath = PathLightsEnv + '/' + sf.text() + '_LightRig.mb' Lights.importLightRigEnv(RealPath, sf.text())
def importLightRigChar(self): import Lights PathLightsCha = 'D:\zebratv\Projects\BOLO\editorial\incoming\LightRigs\Characters/' SelectedFiles = self.ui.listWidget_LightRigCharacters.selectedItems() for sf in SelectedFiles: RealPath = PathLightsCha + '/' + sf.text() + '_LightRig.mb' Lights.importLightRigChar(RealPath, sf.text())
def update_lights(): """Periodically update the display state of the lights""" global lights_text lights_state = Lights.read() lights = Lights.get_lights() for i, light in enumerate(lights_text): light.set(f"{lights[i]}: {(lights_state >> i) & 0x01}") window.after(LIGHTS_FREQ, update_lights)
def execute(self): if (Lights.value == self.value): Log.write(message='Turning light ' + ('on' if self.value else 'off') + ' skipped because it' 's already ' + ('on' if self.value else 'off') + '.', level=1, image=imageId, startedby='event') return Lights.value = self.value Lights.broadcast() Log.write(message='Turned light ' + ('on' if self.value else 'off') + '.', level=1, startedby='event')
def display(battery=None): #print watchdog countdown global stdscr # Read ADC values adc_values = ADC.read() global frequency frequency = PLL.Get_Frequency() stdscr.addstr(0, 10, "Battery") stdscr.addstr(1, 0, "==============================") stdscr.addstr(2, 0, f"ADC:") stdscr.addstr(2, 10, f"Low Precision: {adc_values[0][0]}") stdscr.addstr(3, 10, f"High Precision: {adc_values[0][1]}") # Read Current values stdscr.addstr(4, 0, f"Current:") stdscr.addstr(4, 10, f"{adc_values[1]} A ") #Read CAN data CANdata = CAN.Get_CAN_Info() text = ' '.join(CANdata) #put elements of the list of CAN data bytes into a string CANbox.erase() #clear previous data in the box CANbox.addstr(4, 0, textwrap.fill(text, 40)) CANbox.addstr(3, 2, "CAN ID and Message:") # Display Watchdog ticks ticks = WDTimer.Tick() stdscr.addstr(10, 0, f" ") #clear previous tick stdscr.addstr(10, 0, f"WDTimer Countdown: {ticks}") #Display current frequency stdscr.addstr(6, 0, f" ") stdscr.addstr(6, 0, f"Clock Frequency: {frequency} Hz") # Read Module values stdscr.addstr(0, 54, "Modules") stdscr.addstr(1, 40, "====================================") module_values = SPI.read() for i, module in enumerate(module_values): stdscr.addstr(i+2, 37, f"{i+1}") stdscr.addstr(i+2, 40, f"| {'X' if module[0] else ' '} | {module[1]/10000:.4f}V | {module[2]/1000:.3f}°C | {module[3]/1000:.3f}°C |") # Read LED values stdscr.addstr(0, 90, "LEDs") stdscr.addstr(1, 80, "=======================") lights = Lights.read() curses.init_pair(1, curses.COLOR_RED, curses.COLOR_RED) curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_GREEN) curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_BLACK) for i in range(9): stdscr.addstr(i+2, 80, lights_names[i]) if lights & (0x1<<i): if i == 7: stdscr.addstr(i+2, 100, "[]", curses.color_pair(2)) else: stdscr.addstr(i+2, 100, "[]", curses.color_pair(1)) else: stdscr.addstr(i+2, 100, "[]", curses.color_pair(3)) strobe = Strobelight.read() stdscr.addstr(11, 80, 'S_PULSING') if strobe: stdscr.addstr(11, 100, "[]", curses.color_pair(2)) else: stdscr.addstr(11, 100, "[]", curses.color_pair(3)) stdscr.refresh()
def pre_run(): afe = atm90e26() afe.setup('spi') cfg = {k: base_config[k] for k in base_config} local_overrides = json.load(open('./device_params.json')) for k in local_overrides: cfg[k] = local_overrides[k] if cfg.get('calibration', None) is not None: afe.loadCalibration(cfg['calibration']) afe.reset() cfg['lights'] = Lights.Lights() cfg['afe'] = afe cfg['serial'] = getSerial() cfg['ips'] = getIPaddrs() sdn = sdnotify.SystemdNotifier() cfg['sdnotify'] = sdn sdn.notify('READY=1') i = iSetup(cfg) cfg['iconn'] = i return cfg
def load(): global version, saturation, saturationchanged status = configparser.ConfigParser() status.read(inifilename) FoodStore.load(status) EventList.load(status) Lights.load(status) section = 'status' if not status.has_section(section): raise Exception("Broken state.ini file") saturation = float(status.get(section, 'saturation')) saturationchanged = datetime.datetime.strptime( status.get(section, 'saturationchanged'), "%Y-%m-%d %H:%M:%S.%f") version = status.getint(section, 'version') + 1 Camera.counter = status.getint(section, 'Cameracounter')
def save(): status = configparser.ConfigParser() status.read(inifilename) section = 'status' if not status.has_section(section): status.add_section(section) status.set(section, 'saturation', str(saturation)) status.set(section, 'saturationchanged', str(saturationchanged)) status.set(section, 'version', str(version)) status.set(section, 'Cameracounter', str(Camera.counter)) FoodStore.save(status) EventList.save(status) Lights.save(status) with open(inifilename, 'w') as configfile: status.write(configfile)
def get_request(): if request.method == 'POST': payload = request.get_json(silent=True) if 'plants' in payload: plants = Plants.Plants(payload) plants.handle_plants() if 'lights' in payload: lights = Lights.Lights(payload) lights.handle_lights() else: print ('nothing in the payload') #print ("Got data: " + str(payload)) return {'succeeded with query' : str(payload)}
def loclite(): Lights.bluelight() time.sleep(2)
def input(): global lastScan global previousFile try: print "You have 30 seconds to type in your stuff...." n = raw_input("Scanned ID: ") # Disable RFID os.system("/home/pi/Halloween2015/Scripts/disableRFID.sh") currentScan = time.time() print "Input is: ", n if n == "0001603911": print "PKill scanned. Aborting Script." Lights.cleanup() return False elif n == "0003756767" or n == "0006951576" or n == "0009621329" or n == "0006968801": # Do Katies stuff # Stop Audio Loop subprocess.Popen(["sudo", "pkill", "mpg321"]) time.sleep(0.5) # Trigger GPIO Pins. Lightning sticks on 33 - Relay Opposite. On=Off Lights.off([33]) # Play Thunderline os.system("mpg321 /home/pi/Halloween2015/Assets/Thunder/HorsemanLightning.mp3 & -q") # After 4 secs, Dim DMX 30% Light Channels, 0% Blacklight Channels # Blacklight channels removed. time.sleep(4) print "House Down" setHouse(7) # Play Horseman Audio and drop heads time.sleep(4) os.system("mpg321 /home/pi/Halloween2015/Assets/HorsemanSlashes.mp3 -q &") time.sleep(10) # After 10 seconds, drop heads. # Trigger GPIO Pins. Head Chop on 15 print "Drop Head" Lights.on([37]) # wait an additional 11 seconds time.sleep(11) # Bring house lights back up DMX Lights 100% and stop lightning Lights.on([33]) print "House Back Up" for x in range(20, 255): setHouse(x) time.sleep(0.02) time.sleep(30) # Reset Heads GPIO 11 then bring blacklight back up after 5 print " Raising Head" Lights.off([37]) # Restart Audio os.system("mpg321 /home/pi/Halloween2015/Assets/Thunder/RagingWinds.mp3 --loop 0 --gain 30 -q &") else: # Do Katies stuff # Stop Audio Loop subprocess.Popen(["sudo", "pkill", "mpg321"]) time.sleep(0.5) # Trigger GPIO Pins. Lightning sticks on 33 - Relay Opposite. On=Off Lights.off([33]) # Play Thunderline os.system("mpg321 /home/pi/Halloween2015/Assets/Thunder/HorsemanLightning.mp3 & -q") # After 4 secs, Dim DMX 30% Light Channels, 0% Blacklight Channels # Blacklight channels removed. time.sleep(4) print "House Down" setHouse(7) # Play Horseman Audio and drop heads time.sleep(4) os.system("mpg321 /home/pi/Halloween2015/Assets/HorsemanSlashes.mp3 -q &") time.sleep(10) # After 10 seconds, drop heads. # Trigger GPIO Pins. Head Chop on 15 print "Drop Head" Lights.on([37]) # wait an additional 11 seconds time.sleep(11) # Bring house lights back up DMX Lights 100% and stop lightning Lights.on([33]) print "House Back Up" for x in range(20, 255): setHouse(x) time.sleep(0.02) time.sleep(30) # Reset Heads GPIO 11 then bring blacklight back up after 5 print " Raising Head" Lights.off([37]) # Restart Audio os.system("mpg321 /home/pi/Halloween2015/Assets/Thunder/RagingWinds.mp3 --loop 0 --gain 30 -q &") return except: # timeout return
import Lights import sys sys.path.append("/home/pi/PiClasses") import Logging import time import os time.sleep(15) dbConn = Logging.Logging() dbConn.logBoot() lastScan = 0 previousFile = "" Lights.setup() os.system("/home/pi/Scripts/enableRFID.sh") 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) #Disable RFID os.system("/home/pi/Scripts/disableRFID.sh") #Trigger GPIO Pins. Trixie just uses pin 13 Lights.on([13])
__author__ = 'madsens' import pygame import os import Lights import time #import TextFade Lights.setup() pygame.display.init() pygame.font.init() # This runs the Naughty/Nice Gag while True: # Display Parchment background = pygame.image.load( "/home/pi/Christmas-2015/Assets/brown-parchment.jpg") screen = pygame.display.set_mode(background.get_size()) background = pygame.image.load( "/home/pi/Christmas-2015/Assets/brown-parchment.jpg").convert() font = pygame.font.SysFont('sans-serif', 160, True) screen.blit(background, (0, 0)) pygame.display.flip() # Wait for Input rfid = raw_input() # If STOP, Quit the program if rfid == "STOP": pygame.quit()
def __init__(self): ip = "0.0.0.0" port = 8005 self._topcommunicator = TcpCommunicator(ip, port, bind=True) self._botcommunicator = I2cCommunicator() self._myhardware = Hardware(self._botcommunicator) #===============AVR self._Avr1address = 6 self._Avr2address = 7 self._myhardware.addAVR(self._Avr1address) self._myhardware.addAVR(self._Avr2address) #===============Devices motorsbasepwm = 1440 zero = 0 cameraservobase = 1500 RGBwhite = 7 self._myhardware._avrList[0].addDevice("Front_Right_Thruster", motorsbasepwm, 2) self._myhardware._avrList[0].addDevice("Front_Left_Thruster", motorsbasepwm, 2) self._myhardware._avrList[0].addDevice("Back_Right_Thruster", motorsbasepwm, 2) self._myhardware._avrList[0].addDevice("Back_Left_Thruster", motorsbasepwm, 2) self._myhardware._avrList[0].addDevice("Up_Front_Thruster", motorsbasepwm, 2) self._myhardware._avrList[0].addDevice("Up_Back_Thruster", motorsbasepwm, 2) self._myhardware._avrList[0].addDevice("DC", zero, 1) self._myhardware._avrList[1].addDevice("Camera_Servo", cameraservobase, 2) self._myhardware._avrList[1].addDevice("LED", RGBwhite, 1) self._myhardware._avrList[1].addDevice("Cycle_Flag", zero, 1) #=============Components #identifiers must be in the form of a list self._rovmanipulator = Manipulator(self._myhardware, {"grip": 0}) self._rovLights = Lights(self._myhardware, {"led": 7}) self._rovCamera = Camera(self._myhardware, {"cam": 0}) self._rovmotion = Motion(self._myhardware, { "x": 0, "y": 0, "z": 0, "r": 0, "currentmode": "normal" }) modules = [ self._rovmanipulator, self._rovLights, self._rovCamera, self._rovmotion ] #=============PostOffcie self.mypostoffice = PostOffice() for module in modules: self.mypostoffice.registerEventListner("TCP", module.mail) self.mypostoffice.registerEventListner("TCP ERROR", module.mail) self.mypostoffice.registerEventListner("I2C", self._rovmanipulator.mail) self.mypostoffice.registerEventListner( "I2C", self._myhardware._avrList[1].mail) self.mypostoffice.registerEventListner( "I2C", self._myhardware._avrList[0].mail) self.mypostoffice.registerEventListner("Sensors", self._topcommunicator._send) self._topcommunicator.registerCallBack(self.mypostoffice.triggerEvent) #=============Sensors # self._mysensors=SensorRegistry() # self._mysensors.registerSensor(sensor) # self._mysensors.registerCallBack(self.mypostoffice.triggerEvent) #=====intterupts self._interruptor = Interrupt() self._interruptor.register(23, False, self.mypostoffice.triggerEvent, "I2C") self._topcommunicator._mainLoop()
__author__ = 'madsens' import Lights import time import Logging from subprocess import Popen, PIPE import os # This code runs the fireflies gag lastScan = 0 Lights.setup() previousFile = "" Popen(['mpg321', '/home/pi/Halloween2015/Assets/Crickets.mp3', '--loop', '0'], stdout=PIPE, close_fds=True) #Turn the reader back on. os.system("/home/pi/Halloween2015/Scripts/enableRFID.sh") 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 == "0001603911": Lights.cleanup() break # stops the loop else : #Turn off the reader until function finishes. os.system("/home/pi/Halloween2015/Scripts/disableRFID.sh") Popen(['mpg321', '/home/pi/Halloween2015/Assets/CreepyLaugh.mp3'], stdout=PIPE, close_fds=True) #Log Activation of PI #Logging.LogAccess(n)
__author__ = 'madsens' import Logging import os import Movies import time import Lights # This code runs the Furnace Lights.setup2() Logging.PowerLog() print 'Starting' Movies.StartLoop('/home/pi/NYE2015/Assets/Furnace') while True: # Runs until break is encountered. We want to set it to break on a particular ID. #Logging.HeartBeat() n = raw_input("Scanned ID: ") Lights.showColor("gold") if n == "STOP": Movies.StopLoop() Lights.cleanup() print "Stopping." break # stops the loop else : # On Input, Disable Reader os.system("/home/pi/NYE2015/Scripts/disableRFID.sh") Lights.showColor("red") time.sleep(2) Lights.showColor("none") print "Playing."
def loclite(): # combines lights and relay access Lights.greenlight() # lights time.sleep(2) # time between scans Relay.openlock() # power to relay.
### Switches ### buttons = [] for i, switch in enumerate(Switches.get_switches()): button = tk.Button(master=button_frame, text=switch) button.grid( row=i // len(button_frame_columns), column=i % len(button_frame_columns), sticky="nsew", ) buttons.append(button) for i, switch in enumerate(Switches.get_switches()): buttons[i].config(command=partial(Switches.toggle, switch, buttons)) ### Lights ### lights_text = list() for i, light in enumerate(Lights.get_lights()): light_text = tk.StringVar(value=f"{light}: ") light = tk.Label(master=lights_frame, textvar=light_text) light.grid( row=i // len(lights_frame_columns), column=i % len(lights_frame_columns), sticky="nsew", ) lights_text.append(light_text) ### Contactors ### motor_status = tk.StringVar(value="Motor Contactor: ") motor_ = tk.Label(master=contactor_frame, textvariable=motor_status) motor_.grid(row=0, column=0, sticky="nsew") array_status = tk.StringVar(value="Array Contactor: ") array_txt = tk.Label(master=contactor_frame, textvariable=array_status)
def test_lights(): say('Testing lights') Display.set_cursor_position(0,2) Display.write('Lights ') say('Lamp 0 on') Display.set_cursor_position(0,2) Display.write('Lamp 0 On ') Lights.set_lamp(0, 1) time.sleep(3) say('Lamp 1 on') Display.set_cursor_position(0,2) Display.write('Lamp 1 On ') Lights.set_lamp(1, 1) time.sleep(3) say('Lamp 2 on') Display.set_cursor_position(0,2) Display.write('Lamp 2 On ') Lights.set_lamp(2, 1) time.sleep(3) say('Lamp 3 on') Display.set_cursor_position(0,2) Display.write('Lamp 3 On ') Lights.set_lamp(3, 1) time.sleep(3) say('Lamp 0 off') Display.set_cursor_position(0,2) Display.write('Lamp 0 Off ') Lights.set_lamp(0, 0) say('Lamp 1 off') Display.set_cursor_position(0,2) Display.write('Lamp 1 Off ') Lights.set_lamp(1, 0) say('Lamp 2 off') Display.set_cursor_position(0,2) Display.write('Lamp 2 Off ') Lights.set_lamp(2, 0) say('Lamp 3 off') Display.set_cursor_position(0,2) Display.write('Lamp 3 Off') Lights.set_lamp(3, 0) Display.set_cursor_position(0,2) Display.write(' ')
def rejectlite(): # combines lights and relay access Lights.redlight() # lights time.sleep(2) # time between scans
__author__ = "shilohmadsen" # This code will have the main listener app. It will wait for a "keyboard" input and when recieved, will execute the code # contained within the function. Individual tasks, such as play video, actuate motors or light up leds will be their own # function files included in the code. This will allow us to have modular code to use for pis doing only what it needs to do. import Lights import Movies import time Movies.StartLoop("/home/pi/Halloween2015/Assets/BarBrawl") Lights.setup() while True: # Runs until break is encountered. We want to set it to break on a particular ID. Lights.showColor("gold") n = raw_input("Scanned ID: ") if n == "0001603911": Movies.StopLoop() Lights.cleanup() break # stops the loop else: # Insert various function calls to run files etc. Lights.showColor("red") time.sleep(2) Movies.PlayMovie()
__author__ = 'madsens' import Lights import os import time Lights.setup() os.system("/home/pi/Halloween2015/Scripts/enableRFID.sh") while True: # Runs until break is encountered. We want to set it to break on a particular ID. n = raw_input("Scanned ID: ") if n == "0001603911": break # stops the loop else : #Disable RFID os.system("/home/pi/Halloween2015/Scripts/disableRFID.sh") #Trigger GPIO Pins. This uses a Relay, so we need to actually call OFF to turn it on... Lights.off([37]) time.sleep(3) #Candle GPIO "off" Lights.on([37]) #Log Activation of PI #Logging.LogAudioAccess(n, previousFile) #Reenable RFID os.system("/home/pi/Halloween2015/Scripts/enableRFID.sh")
__author__ = 'madsens' import pygame import os import Lights import time #import TextFade Lights.setup() pygame.display.init() pygame.font.init() # This runs the Naughty/Nice Gag while True: # Display Parchment background = pygame.image.load ("/home/pi/Christmas-2015/Assets/brown-parchment.jpg") screen = pygame.display.set_mode (background.get_size()) background = pygame.image.load ("/home/pi/Christmas-2015/Assets/brown-parchment.jpg").convert() font = pygame.font.SysFont('sans-serif', 160, True) screen.blit (background, (0,0) ) pygame.display.flip() # Wait for Input rfid = raw_input() # If STOP, Quit the program if rfid == "STOP": pygame.quit() break
__author__ = 'madsens' import Lights import time from subprocess import Popen, PIPE import os from DmxPy import DmxPy # This code runs the Dining Room dmx = DmxPy('/dev/ttyUSB0') lastScan = 0 Lights.setup() #Turn the reader back on. os.system("/home/pi/Christmas-2015/Scripts/enableRFID.sh") 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": 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)
__author__ = 'madsens' import Lights import time from subprocess import Popen, PIPE import os from DmxPy import DmxPy # This code runs the Dining Room dmx = DmxPy('/dev/ttyUSB0') lastScan = 0 Lights.setup() #Turn the reader back on. os.system("/home/pi/Christmas-2015/Scripts/enableRFID.sh") 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": 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])