Esempio n. 1
0
 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)
Esempio n. 2
0
 def led_on(value=1):
     """ Switch the proto shields LED
     :param value: 0/1 for off/on. Default is 1.
     :return: value
     :rtype : int
     """
     GPIO.output(BOARD2.LED, value)
     return value
Esempio n. 3
0
 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)
Esempio n. 4
0
 def reset():
     """ manual reset
     :return: 0
     """
     GPIO.output(BOARD2.RST, 0)
     time.sleep(.01)
     GPIO.output(BOARD2.RST, 1)
     time.sleep(.01)
     return 0
Esempio n. 5
0
 def teardown():
     """ Cleanup GPIO and SpiDev """
     GPIO.cleanup()
     BOARD.spi.close()
Esempio n. 6
0
 def setup():
     """ Configure the Raspberry GPIOs
     :rtype : None
     """
     GPIO.setmode(GPIO.BCM)
     # LED
     GPIO.setup(BOARD.LED, GPIO.OUT)
     GPIO.setup(BOARD.RST, GPIO.OUT)
     GPIO.output(BOARD.LED, 0)
     GPIO.output(BOARD.RST, 1)
     # switch
     #GPIO.setup(BOARD.SWITCH, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) 
     # DIOx
     for gpio_pin in [BOARD.DIO0, BOARD.DIO1, BOARD.DIO2, BOARD.DIO3]:
         GPIO.setup(gpio_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
     # blink 2 times to signal the board is set up
     BOARD.blink(.1, 2)
Esempio n. 7
0
 def led_off():
     """ Switch LED off
     :return: 0
     """
     GPIO.output(BOARD2.LED, 0)
     return 0