def add_event_detect(dio_number, callback): """ Wraps around the GPIO.add_event_detect function :param dio_number: DIO pin 0...5 :param callback: The function to call when the DIO triggers an IRQ. :return: None """ GPIO.add_event_detect(dio_number, GPIO.RISING, callback=callback)
def add_events(cb_dio0, cb_dio1, cb_dio2, cb_dio3, cb_dio4, cb_dio5, switch_cb=None): BOARD2.add_event_detect(BOARD2.DIO0, callback=cb_dio0) BOARD2.add_event_detect(BOARD2.DIO1, callback=cb_dio1) BOARD2.add_event_detect(BOARD2.DIO2, callback=cb_dio2) BOARD2.add_event_detect(BOARD2.DIO3, callback=cb_dio3) # the modtronix inAir9B does not expose DIO4 and DIO5 if switch_cb is not None: GPIO.add_event_detect(BOARD2.SWITCH, GPIO.RISING, callback=switch_cb, bouncetime=300)