def __init__(self, boy, *args, **kwargs): super(BaseModule, self).__init__() logging.info( "BaseModule.__init__(): config.GPIO_AVAILABLE = {GPIO_AVAILABLE}". format(GPIO_AVAILABLE=config.GPIO_AVAILABLE)) if config.GPIO_AVAILABLE: logging.info( "setting output mode for GPIO_LED_ID = {GPIO_LED_ID}".format( GPIO_LED_ID=self.GPIO_LED_ID)) gpio.setup(self.GPIO_LED_ID, gpio.OUT) gpio.output(self.GPIO_LED_ID, False) self.pypboy = boy self.position = (0, 40) self.footer = pypboy.ui.Footer() self.footer.menu = [] for mod in self.submodules: self.footer.menu.append(mod.label) self.footer.selected = self.footer.menu[0] self.footer.position = (0, config.HEIGHT - 53) # 80 self.add(self.footer) self.switch_submodule(0) self.action_handlers = { "pause": self.handle_pause, "resume": self.handle_resume } if config.SOUND_ENABLED: self.module_change_sfx = pygame.mixer.Sound( 'sounds/module_change.ogg')
def __init__(self, boy, *args, **kwargs): super(BaseModule, self).__init__() logging.info("BaseModule.__init__(): config.GPIO_AVAILABLE = {GPIO_AVAILABLE}".format(GPIO_AVAILABLE=config.GPIO_AVAILABLE)) if config.GPIO_AVAILABLE: logging.info("setting output mode for GPIO_LED_ID = {GPIO_LED_ID}".format(GPIO_LED_ID=self.GPIO_LED_ID)) gpio.setup(self.GPIO_LED_ID, gpio.OUT) gpio.output(self.GPIO_LED_ID, False) self.pypboy = boy self.position = (0, 40) self.footer = pypboy.ui.Footer() self.footer.menu = [] for mod in self.submodules: self.footer.menu.append(mod.label) self.footer.selected = self.footer.menu[0] self.footer.position = (0, config.HEIGHT - 53) # 80 self.add(self.footer) self.switch_submodule(0) self.action_handlers = { "pause": self.handle_pause, "resume": self.handle_resume } if config.SOUND_ENABLED: self.module_change_sfx = pygame.mixer.Sound('sounds/module_change.ogg')
def __init__(self): self._xfm = XFMI2CDriver() rospy.loginfo('get xfm firmware info') self.xfm_fm_version, self.xfm_build_num = self._xfm.getFWVersion() i = 1 while not (self.xfm_fm_version != -1 and self.xfm_build_num != -1): self.xfm_fm_version, self.xfm_build_num = self._xfm.getFWVersion() if i % 10 == 0: rospy.logwarn("get xfm firmware error") exit(-1) i += 1 time.sleep(1) rospy.loginfo('get xfm firmware successful!') rospy.loginfo('GPIO setup') try: gpio.setup(XFM_WAKEUP_PIN, gpio.IN) rospy.loginfo('GPIO setup successful!!') except: rospy.loginfo('GPIO setup try again...') time.sleep(2) try: gpio.setup(XFM_WAKEUP_PIN, gpio.IN) rospy.loginfo('GPIO setup successful!!') except: rospy.loginfo('GPIO setup failed!!') exit(-1) self.status_pub = rospy.Publisher('xfm_status', xfm_status, queue_size=1) rospy.Subscriber('xfm_cmd', xfm_cmd, self.cmdCallBack)
def __init__(self, aadvark_index=None): _i2c_bus.__init__(self) self._handle = None if not smbus_found: raise BusException( 'Please install smbus python module: sudo apt-get install python-smbus' ) if gpio_found: self._has_gpio = True self.bus_gpio_list = [1, 2] self._gpio_pin_index = [ evkit_config.getint('linux_gpio', 'pin1_index'), evkit_config.getint('linux_gpio', 'pin2_index') ] # TODO synch logic with bus_serial gpio.setup(self._gpio_pin_index[0], gpio.IN) gpio.setup(self._gpio_pin_index[1], gpio.IN) if self.check_are_we_on_raspi(): #disable SPI if on raspi logger.debug( 'This is Raspberry Pi: Disabling SPI bus so we can use I2C' ) gpio.setup(10, gpio.IN) #MOSI gpio.setup(9, gpio.IN) #MISO gpio.setup(11, gpio.IN) #SCLK else: logger.debug('This is not Raspberry Pi.')
def record(): logger.info("Starting record loop") gpio.setup() gpio.turnOn(gpio.RED) while not should_stop: file_name = time.strftime(FILE_FORMAT) + ".h264" start = time.time() camera.start_recording(VIDEO_FOLDER + file_name, splitter_port=1) while True: if (time.time() - start > RECORD_TIME) or should_stop: break entry = gpsdaemon.get_last_entry() overlay = dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S') # overlay += " lat: " + str(entry["lat"]) # overlay += " lon: " + str(entry["lon"]) overlay += " speed: " + str(entry["speed"]) + "km/h" camera.annotate_text = overlay camera.wait_recording(1) camera.stop_recording(splitter_port=1) gpio.turnOff(gpio.RED) logger.info("Stopping record loop")
def openDoor(): gpio.setup(62, 'out') gpio.setwarnings(False) print 'Set gpio62 as 1\n' gpio.set(62, 1) time.sleep(1) gpio.set(62, 0)
def ler_sensor_ultrassonico(): MQTT_PORT = 1883 TOPICO = '/softway/iot' MQTT_TIMEOUT = 60 GPIO.setmode(GPIO.BCM) # Set GPIO pin numbering TRIG = 23 # Associate pin 23 to TRIG ECHO = 24 # Associate pin 24 to ECHO ID_LINE = 1 MQTT_ADDRESS = '10.17.0.2' GPIO.setup(TRIG, GPIO.OUT) # Set pin as GPIO out GPIO.setup(ECHO, GPIO.IN) # Set pin as GPIO in def send_message(msg, MQTT_ADDRESS): # Send MQTT Message client = mqtt.Client() client.connect(MQTT_ADDRESS, MQTT_PORT, MQTT_TIMEOUT) result, mid = client.publish(TOPICO, msg) print('Mensagem enviada ao canal: %d, [MQTT_ADDRESS: %s]' % (mid, MQTT_ADDRESS)) for numero in range(4): timeout = 0.8 * 60 * 60 # Horas em segundos (48 min) timeout_start = time.time() while time.time() < timeout_start + timeout: GPIO.output(TRIG, False) # Set TRIG as LOW time.sleep(2) # Delay of 2 seconds GPIO.output(TRIG, True) # Set TRIG as HIGH time.sleep(0.00001) # Delay of 0.00001 seconds GPIO.output(TRIG, False) # Set TRIG as LOW while GPIO.input(ECHO) == 0: # Check whether the ECHO is LOW pulse_start = time.time() # Saves the last known time of LOW pulse while GPIO.input(ECHO) == 1: # Check whether the ECHO is HIGH pulse_end = time.time() # Saves the last known time of HIGH pulse pulse_duration = pulse_end - pulse_start # Get pulse duration to a variable distance = pulse_duration * 17150 # Multiply pulse duration by 17150 to get distance distance = round(distance, 2) # Round to two decimal points if distance > 5: mensagem = "{\"id\":" + str(ID_LINE) + "}" print("++ MSG-SEND:", mensagem, "\n") send_message(mensagem, MQTT_ADDRESS) # Send message via MQTT protocol time.sleep(0.3) print("Resetando sensores...") time.sleep(0.3) print("Resetando sensores......") time.sleep(0.4) print("Resetando sensores.........")
def main(): factory = protocol.ServerFactory() factory.protocol = GPIO reactor.listenTCP(PORT, factory) print 'Setup' setup() print 'Listening on {0}'.format(PORT) reactor.run()
def unlock(locker): pin = str(locker_to_gpio[locker]) gpio.setup(pin, gpio.OUT) gpio.output(pin, 1) time.sleep(10) gpio.output(pin, 0) # gpio.cleanup(pin) return 0
def is_charging(): hw_v = get_hw_version_str() if hw_v == "gamma": chg_sense_gpio = 503 gpio.setup(chg_sense_gpio, gpio.IN) return bool(gpio.input(chg_sense_gpio)) else: raise NotImplementedException("Version not supported!")
def _set_state(self, name, state): g = self.gpios[name] gpio_num = g["num"] if not g["exported"]: gpio.setup(gpio_num, gpio.OUT) g["exported"] = True g["state"] = state gpio.set(gpio_num, state)
def setup(bit, num_bits): print("Initializing setup:") if len(bit) == num_bits: for i in range(0, num_bits): gpio.setup(bit[i], gpio.OUT) # Bit vector as OUTPUT else: print("Error : Non consisten counter length with number of bits") exit(-1) print("Setup done")
def dcdc_off_on(): global dcdc_exported if not dcdc_exported: #DC-DC GPIO not yet set up gpio.setup(dcdc_gpio, gpio.OUT) dcdc_exported = True gpio.set(dcdc_gpio, True) sleep(0.5) gpio.set(dcdc_gpio, False)
def reset(self): #self.RST = m.Gpio(36) #self.RST.dir(m.DIR_OUT) #self.RST.write(0) # reset the device gpio.setup(GPIO_RESET_PIN, gpio.OUT) gpio.set(GPIO_RESET_PIN, 0) time.sleep(0.01) gpio.set(GPIO_RESET_PIN, 1) #self.RST.write(1) # let the device out of reset time.sleep(2.01) # wait for the CC1110 to come up
def toggle(pin): if gpio.read(pin) == 0: gpio.setup(pin, gpio.OUT) gpio.set(pin, 1) elif gpio.read(pin) == 1: gpio.setup(pin, gpio.OUT) gpio.set(pin, 0) else: print('There was some sort of error, are you using the right pin?') print(gpio.read(pin))
def unlock(locker): print('unlocked ' + str(locker)) # pin = locker_to_gpio[locker] pin = str(locker) gpio.setup(pin, gpio.OUT) gpio.output(pin, 1) time.sleep(1) gpio.output(pin, 0) time.sleep(1) gpio.cleanup(pin) return 0
def set_state(self, state): if not self.gpio_exported: gpio.setup(self.gpio_num, gpio.OUT) self.gpio_exported = True self.gpio_state = state if self.switch_types[self.hw_v] == "gpio_inverted": gpio.set(self.gpio_num, not state) elif self.switch_types[self.hw_v] == "gpio": gpio.set(self.gpio_num, state) else: raise NotImplementedException("DC-DC switch type not supported!")
def __init__(self, baud_rate=1000000): if (Ax12.port == None): Ax12.port = Serial("/dev/ttyTHS2", baudrate=baud_rate, timeout=0.001) if (not Ax12.gpioSet): # GPIO.setwarnings(False) # GPIO.setmode(GPIO.BCM) gpio.setup(Ax12.DIRECTION_PIN, gpio.OUT) Ax12.gpioSet = True self.direction(Ax12.DIRECTION_RX)
def main(): for gpio_pin in GPIO_PINS: logger.info("setup output pin %s with state %s", gpio_pin, INITIAL_STATE) gpio.setup(gpio_pin, gpio.OUT, initial=INITIAL_STATE) time.sleep(SLEEP_DELAY) logger.info("drive output pin %s to state %s", gpio_pin, DRIVEN_STATE) gpio.output(gpio_pin, DRIVEN_STATE) time.sleep(SLEEP_DELAY) while True: logger.info("main script complete now sleep forever") time.sleep(60 * 5)
def test_basic(self): # with mock_open you have to remember that all files are the same # mock object. mopen = mock_open(read_data='0') with patch(bins + '.open', mopen, create=True) as m: gpio.setup(0, gpio.OUT) gpio.set(0, 0) assertInitialized(self, m) # So, "value" could be "direction" or any other file written = mockargs(gpio._open[0]['value'].write) expected = [('0',), ('out',), ('0',)] assertInitialized(self, m) self.assertListEqual(written, expected)
def get_gsm_reset_gpio(): hw_revs = [["Gamma", "gamma"], ["Delta/Delta-B", "delta"]] gpios = {"gamma":502, "delta":496} assert(all([hwr[1] in gpios.keys() for hwr in hw_revs])) # check after editing hwr = Listbox(hw_revs, i, o, name="Hardware setup app GSM FW picker").activate() if not hwr: return None if hwr == "delta": # Enable UARTs gpio.setup(500, gpio.OUT) gpio.set(500, False) gp = gpios[hwr] return gp
def initPins(self, GPIO): GPIO.setwarnings(False) # GPIO.setmode(GPIO.BOARD) GPIO.setup(out1, GPIO.OUT) GPIO.setup(out2, GPIO.OUT) GPIO.setup(out3, GPIO.OUT) GPIO.setup(out4, GPIO.OUT)
def __init__(self, baudrate=9600, port='/dev/ttyS1', timeout=1, tr=6): self.tr = tr # initialize pyserial self.serial = pyserial.Serial(port=port, timeout=timeout, baudrate=baudrate) # if serial is not open, open it. if not self.serial.isOpen(): self.serial.Open() # initialize GPIO GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(self.tr, 'out')
def cleanup_pids(): for name in os.listdir(configuration.pid_files): pid_file = pids.create_pid_file_path(name) pid_contents = pids.read_pid_file(pid_file) if pid_contents is not False: end = datetime.strptime(pid_contents["end"], '%Y-%m-%d %H:%M:%S.%f') if end < datetime.now(): gpio.setup(pid_contents["zone"]) gpio.off(pid_contents["zone"]) pids.kill(int(pid_contents["pid"])) pids.delete_status_file(pid_file) logger.info(LAWN_CRON, "Cleaned up pid {0}".format(pid_contents["pid"])) Timer(configuration.cleanup_frequency, cleanup_pids).start()
def start_launch(launch_name, stdscr): stdscr.nodelay(1) gpio.setup(396, gpio.IN) uuid = roslaunch.rlutil.get_or_generate_uuid(None, True) roslaunch.configure_logging(uuid) launch = roslaunch.parent.ROSLaunchParent(uuid, [ '/home/nvidia/catkin_ws/src/heron_software/src/launch/' + launch_name + '.launch' ]) launch.start() #Lance le launch while stdscr.getch() != 27 and gpio.read( 396 ) != 0: #Attend que "Echap" ou le bouton d'arrêt d'urgence soit appuyé pass launch.shutdown() #Arrête le launch
def parse_wgl_header(file): PIOMAP_list=[] line = file.readline() # GROUND - 39, 34, 30, 25, 20, 14, 09, 06 # DC POWER - 17, 04, 02, 01 # NC - 28, 27 GPIO_list=[40, 38, 37, 36, 35, 33, 32 ,31, 29, 26, 24, 23, 22, 21, 19, 18, 16, 15, 13, 12, 11, 10, 8, 7, 5, 3] GPIO_idx=0 while line: timeplate_line = re.search(r'^\s+\"(\w+)\"(\[\d+\])? := (input|output)\[(.*)\];', line) if timeplate_line: signal_name=timeplate_line.group(1) bus_idx=timeplate_line.group(2) signal_direction=timeplate_line.group(3) signal_timeplate=timeplate_line.group(4) if bus_idx is not None: signal_name=signal_name+bus_idx clock_timeplate = re.search('\d+\w+:D, \d+\w+:S, \d+\w+:D', signal_timeplate) if clock_timeplate: signal_direction='clock' if GPIO_idx >= len(GPIO_list): print('Error: Too many ports in pattern file:', file.name) return (1, []) saved_names = [pio['port_name'] for pio in PIOMAP_list] if signal_name in saved_names: print('Error: Pin', signal_name, 'defined more than once in pattern file:', file.name) return (1, []) PIOMAP_list.append({'port_name' : signal_name, 'direction' : signal_direction, 'GPIO' : GPIO_list[GPIO_idx]}) GPIO_idx = GPIO_idx + 1 break_line = re.search(r'pattern Chain_Scan_test\(',line) if break_line: gpio_status = gpio.setup(PIOMAP_list) return (gpio_status, PIOMAP_list) line = file.readline()
def main(): array = ["?", "?", "?", "?"] GPIO.setmode(GPIO.BOARD) GPIO.setup(status_led, GPIO.OUT) GPIO.output(status_led, GPIO.HIGH) while True: humidity, temperature = DHT.read_retry(DHT.DHT22, 10) array[0] = str(temperature) array[1] = str(humidity) array[2], array[3] = ds1820() print(array) senddata(array) for i in range(12): time.sleep(5) GPIO.output(status_led, GPIO.LOW) time.sleep(0.5) GPIO.output(status_led, GPIO.HIGH)
def __init__(self): ''' initialization of pins ''' GPIO.setmode(GPIO.BOARD) GPIO.setup(self.servoPin, GPIO.OUT) GPIO.setup(self.ENB, GPIO.OUT) GPIO.setup(self.IN3, GPIO.OUT) GPIO.setup(self.IN4, GPIO.OUT) # 50 and 40 are frequency self.servo = GPIO(self.servoPin, 50) self.motor = GPIO(self.ENB, 40)
def publish(): rospy.init_node('Leak') leakPub = rospy.Publisher('/leak', Bool, queue_size=1) diagPub = rospy.Publisher('/diagnostics', DiagnosticArray, queue_size=1) #GPIO.setmode(GPIO.BCM) #GPIO.setup(CHANNEL, GPIO.IN) gpio.setup(CHANNEL, gpio.IN) freq = rospy.Rate(1) leak = Bool() diag = DiagnosticArray() while not rospy.is_shutdown(): levelData=0 leak.data = gpio.input(CHANNEL) if (leak.data): levelData=2 diag.status = [DiagnosticStatus(name='Leak', message=str(leak.data), level=levelData)] leakPub.publish(leak) diagPub.publish(diag) freq.sleep()
def initFocuser(self): self.focuserRUN = 80 self.focuserIN = 73 self.focuserOUT = 69 gpio.setup(self.focuserRUN, gpio.OUT) gpio.setup(self.focuserIN, gpio.OUT) gpio.setup(self.focuserOUT, gpio.OUT)
def main(): gpio.setup(SW1, gpio.IN) gpio.setup(SW2, gpio.IN) gpio.setup(SW3, gpio.IN) while True: valueSW1 = gpio.read(SW1) valueSW2 = gpio.read(SW2) valueSW3 = gpio.read(SW3) if valueSW1 == 0: firebase.put('/' , "house1", {u'addr': addrSW1, u'id': idSW1, u'visible': "True", u'lat': latSW1, u'lng': lonSW1}) else: pass if valueSW2 == 0: firebase.put('/' , "house2", {u'addr': addrSW2, u'id': idSW2, u'visible': "True", u'lat': latSW2, u'lng': lonSW2}) else: pass if valueSW3 == 0: firebase.put('/' , "house1", {u'addr': addrSW1, u'id': idSW1, u'visible': "False", u'lat': latSW1, u'lng': lonSW1}) firebase.put('/' , "house2", {u'addr': addrSW2, u'id': idSW2, u'visible': "False", u'lat': latSW2, u'lng': lonSW2}) else: pass
def run(self, recording_length=-1): # recording_length: time (in sec) to spend recording data. # -1: record for indefinite amount of time, until terminated by pressing 'q' or powering off the system # initialize video capture cap = cv2.VideoCapture(0) data = [] recording_start = datetime.datetime.now() prevTime = datetime.datetime.now() timeLastUsed = datetime.datetime.now() finished = False alarm_signal = 0 #gpio stuff gpio.setup(57, gpio.OUT) gpio.set(57, 0) i = 0 #aruco stuff square_length = 6.35 markerLength = 5.08 dictionary = cv2.aruco.Dictionary_get(aruco.DICT_6X6_250) #AR tag dictionary board = cv2.aruco.CharucoBoard_create(4,2,square_length,markerLength,dictionary) while not finished: #show video with alarm state ret, frame = cap.read() gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) res = cv2.aruco.detectMarkers(gray,dictionary) #output: corners, ids,rejected imgpts cv2.aruco.drawDetectedMarkers(gray,res[0],res[1]) cv2.putText(frame, "Alarm is %s" %alarm_signal, (10,100), cv2.FONT_HERSHEY_COMPLEX_SMALL, 1, (255,0,0)) cv2.imshow('frame',gray) i += 1
def gpio_setup(self): """This sets the GPIO registers up""" for key, val in self.status_register.items(): gpio.setup(val, "in") for key, val in self.reset_register.items(): gpio.setup(val, "out") for key, val in self.control_register.items(): gpio.setup(val, "out") gpio.set(val, self.control_register_local[key])
import sys sys.path.append("..") print sys.path import gpio, bottle, json, droplets, thread PORT = 80 HOST = "192.168.178.49"#0.194" if __name__ == "__main__": gpio.setup() thread.start_new_thread(droplets.main, ()) @bottle.route('/static/<filepath:path>') def static(filepath): return bottle.static_file(filepath, root='www/static') @bottle.route("/") def index(): gpio.blink() data = {"title": "StripRevolution Control"} return bottle.template('www/index', data=data) @bottle.route("/engine/<filename>") def engine(filename): gpio.blink() data = {"title": filename} return bottle.template('www/engine', data=data)
def loop_master_connection(conn): #Run the master GPIO command interpereter over the socket conn run=1 got_OK=0 n=0 try: thread.start_new_thread(master_connection_init, (conn,)) while not got_OK: #Loop until connected n=n+1 print "CONNECTING (TRY "+str(n)+")" sendb(conn, 1, 1) #Send a 1 (acknowlage me!) time.sleep(4) except KeyboardInterrupt: print "Got OK, client connected" sendb(conn,10) while run: #recive command command=recvo(conn) if command==3: #3 is shutdown sendb(conn, 4) #4 is shutting down sendb(conn, 5)#tell the relay (if existant) to shut down conn.close() run=0 elif command==22: #22 is initilize pin as output ext=recvo(conn) #read pin to be initilized as output try: print "Initilizing pin "+str(ext)+" as output" gpio.setup(ext, gpio.OUT) #initilize as output sendb(conn, 10) #send back OK except BaseException as e: throw_error(4,e,0) #Throw ERROR4_GPIO_ERROR, dont quit the program, this is recoverable sendb(conn, 11) #Send back 11, error elif command==23: #23 is init as input ext=recvo(conn) #recive pin number to init try: print "Initilizing pin "+str(ext)+" as input" gpio.setup(ext, gpio.IN) #initilize as input sendb(conn, 10) except BaseException as e: throw_error(4,e,0) #Throw error sendb(conn, 11) elif command==24: #24 is read from pin ext=recvo(conn) #recive pin to read from try: print "Reading value from pin "+str(ext) sendb(conn, int(gpio.input(ext))) #read value and send sendb(conn, 10) except BaseException as e: throw_error(4,e,0) #Throw error, send 0 value in place of being read, send 11 so they know an error occoured, not just value is 0 sendb(conn, 0) sendb(conn, 11) elif command==25: #25 is turn pin on ext=recvo(conn) #recive pin# to turn on try: print "Turning pin "+str(ext)+" on" gpio.output(ext, 1) #turn on sendb(conn, 10) except BaseException as e: throw_error(4,e,0) #throw error sendb(conn, 11) elif command==26: #26 is turn pin off ext=recvo(conn) #recive pin# to turn off try: print "Turning pin "+str(ext)+" off" gpio.output(ext, 0) #turn off sendb(conn, 10) except BaseException as e: throw_error(4,e,0) #throw error sendb(conn, 11) elif command==30: #30 is a keepalive/ping signal, send back 10 (OK) so they know we are alive print "Client sent keep-alive/ ping" sendb(conn, 10)
# this script turns on the LED when button is pressed and turns it off when button is released import time as t # in VS import gpio as GPIO # on Rasp # import RPi.GPIO as GPIO print("Script started") _pin_output_led_red = 14 _pin_input_button = 15 GPIO.setmode(GPIO.BCM) GPIO.setup(_pin_output_led_red, GPIO.OUT) GPIO.setup(_pin_input_button, GPIO.IN, GPIO.PUD_UP) while True: if GPIO.input(_pin_input_button) == False: print("Button pressed") GPIO.output(_pin_output_led_red, GPIO.HIGH) else: print("Button released") GPIO.output(_pin_output_led_red, GPIO.LOW) t.sleep(0.01)
#!/usr/bin/env python3 import gpio import rospy import time from std_msgs.msg import Bool CHANNEL = 395 gpio.setup(CHANNEL, gpio.IN) if __name__ == '__main__': rospy.init_node("StartButton") start_pub = rospy.Publisher("/start", Bool, queue_size=10) r = rospy.Rate(4) while not rospy.is_shutdown(): if not gpio.input(CHANNEL): start_pub.publish(Bool(True)) r.sleep()
#!/usr/bin/env python3 import gpio import rospy import time from std_msgs.msg import Bool from diagnostic_msgs.msg import DiagnosticArray, DiagnosticStatus CHANNEL1 = 394 CHANNEL2 = 393 gpio.setup(CHANNEL1, gpio.OUT) gpio.setup(CHANNEL2, gpio.OUT) FIRETIME = 0.04 t1Last = False t2Last = False def fireTorp1(data): global t1Last if data.data and not t1Last: gpio.output(CHANNEL1, True) time.sleep(FIRETIME) gpio.output(CHANNEL1, False) t1Last = data.data def fireTorp2(data): global t2Last if data.data and not t2Last: gpio.output(CHANNEL2, True) time.sleep(FIRETIME) gpio.output(CHANNEL2, False)