def output_handler(pin, value): # Sensorian-led if pin == 0: if value == "1": SensorsInterface.ledOn() else: SensorsInterface.ledOff() # Sensorian-tft elif pin == 1: print "update sensorian-tft was called" # Check TFT availablity print "waiting for TFT_available_lock" TFT_available_lock.acquire() print "acquired TFT_available_lock" availability = TFT_available TFT_available_lock.release() print "released TFT_available_lock" if availability == False: print "dropping TFT write." return print "waiting for TFT_orientation_lock" TFT_orientation_lock.acquire() print "acquired TFT_orientation_lock" orientation = TFT_orientation # orientation = 1 TFT_orientation_lock.release() print "released TFT_orientation_lock" print "Writing to tft" # tft_printer.screen_print(str(value)) print "Trying to acquire TFT_Lock" TFT_Lock.acquire() print "Acquired TFT_Lock" my_tft_writer = TFT_Thread(value, orientation) my_tft_writer.start() print "End of output handler" # Sensorian-rtcc.time elif pin == 2: try: # Extract the time time = str(value).split(",") year = int(time[0]) month = int(time[1]) date = int(time[2]) hour = int(time[3]) minute = int(time[4]) second = int(time[5]) # Set the time SensorsInterface.setRTCCtime(year, month, date, hour, minute, second) print "Time has been set" except: print "Error setting the time" # Sensorian-rtcc.alarmtime elif pin == 3: try: # Extract the time and alarm mode time = str(value).split(",") year = int(time[0]) month = int(time[1]) date = int(time[2]) hour = int(time[3]) minute = int(time[4]) second = int(time[5]) mode = int(time[6]) # Set the alarm SensorsInterface.setRTCCalarm(year, month, date, hour, minute, second, mode) print "Alarm time has been set" except: print "Error setting the alarm" # Sensorian-rtcc.resetalarm elif pin == 4: SensorsInterface.resetRTCCalarm()
def output_handler(pin, value): #Sensorian-led if pin == 0: if value == "1": SensorsInterface.ledOn() else: SensorsInterface.ledOff() #Sensorian-tft elif pin == 1: print "update sensorian-tft was called" #Check TFT availablity print "waiting for TFT_available_lock" TFT_available_lock.acquire() print "acquired TFT_available_lock" availability = TFT_available TFT_available_lock.release() print "released TFT_available_lock" if availability == False: print "dropping TFT write." return print "waiting for TFT_orientation_lock" TFT_orientation_lock.acquire() print "acquired TFT_orientation_lock" orientation = TFT_orientation #orientation = 1 TFT_orientation_lock.release() print "released TFT_orientation_lock" print "Writing to tft" #tft_printer.screen_print(str(value)) print "Trying to acquire TFT_Lock" TFT_Lock.acquire() print "Acquired TFT_Lock" my_tft_writer = TFT_Thread(value, orientation) my_tft_writer.start() print "End of output handler" #Sensorian-rtcc.time elif pin == 2: try: #Extract the time time = str(value).split(",") year = int(time[0]) month = int(time[1]) date = int(time[2]) hour = int(time[3]) minute = int(time[4]) second = int(time[5]) #Set the time SensorsInterface.setRTCCtime(year, month, date, hour, minute, second) print "Time has been set" except: print "Error setting the time" #Sensorian-rtcc.alarmtime elif pin == 3: try: #Extract the time and alarm mode time = str(value).split(",") year = int(time[0]) month = int(time[1]) date = int(time[2]) hour = int(time[3]) minute = int(time[4]) second = int(time[5]) mode = int(time[6]) #Set the alarm SensorsInterface.setRTCCalarm(year, month, date, hour, minute, second, mode) print "Alarm time has been set" except: print "Error setting the alarm" #Sensorian-rtcc.resetalarm elif pin == 4: SensorsInterface.resetRTCCalarm()
selected_sensor_numbers.append(8) selected_sensor_numbers.append(9) selected_sensor_numbers.append(10) if var_args["rtcc"]: selected_sensor_numbers.append(11) selected_sensor_numbers.append(12) selected_sensor_numbers.append(13) selected_sensor_numbers.append(14) selected_sensor_numbers.append(15) selected_sensor_numbers.append(16) selected_sensor_numbers.append(17) SensorsInterface.setupSensorian() # Ensure all alarms are off SensorsInterface.resetRTCCalarm() sensormonitor = SensorMonitor(selected_sensor_numbers) sensormonitor.start() if var_args["connect"]: remote_host = var_args["connect"][0] client = ScratchHandler(selected_sensor_numbers, host=remote_host) else: client = ScratchHandler(selected_sensor_numbers) asyncore.loop() __author__ = "Michael Lescisin" __copyright__ = "Copyright Sensorian 2015"
selected_sensor_numbers.append(8) selected_sensor_numbers.append(9) selected_sensor_numbers.append(10) if var_args['rtcc']: selected_sensor_numbers.append(11) selected_sensor_numbers.append(12) selected_sensor_numbers.append(13) selected_sensor_numbers.append(14) selected_sensor_numbers.append(15) selected_sensor_numbers.append(16) selected_sensor_numbers.append(17) SensorsInterface.setupSensorian() #Ensure all alarms are off SensorsInterface.resetRTCCalarm() sensormonitor = SensorMonitor(selected_sensor_numbers) sensormonitor.start() if var_args['connect']: remote_host = var_args['connect'][0] client = ScratchHandler(selected_sensor_numbers, host=remote_host) else: client = ScratchHandler(selected_sensor_numbers) asyncore.loop() __author__ = "Michael Lescisin" __copyright__ = "Copyright Sensorian 2015"