|
| 1 | +#!/usr/bin/env python3 |
| 2 | +import depthai as dai |
| 3 | +import time |
| 4 | + |
| 5 | +pipeline = dai.Pipeline() |
| 6 | + |
| 7 | +script = pipeline.create(dai.node.Script) |
| 8 | +script.setScript(""" |
| 9 | +import GPIO |
| 10 | +import time |
| 11 | +
|
| 12 | +# Configure AUX_GPIO_3V3 mode as output, or input if False |
| 13 | +auxOutput = True |
| 14 | +# auxOutput = False |
| 15 | +
|
| 16 | +FSYNC_GPIO = 41 # Note: inverted due to isolation circuitry |
| 17 | +AUX_GPIO_3V3 = 52 # or 61, or 63 |
| 18 | +AUX_GPIO_DIR = 6 |
| 19 | +
|
| 20 | +if 1: # Fix up GPIO 61 being driven output-low from FW initialization |
| 21 | + GPIO.setup(61, GPIO.IN, GPIO.PULL_NONE) |
| 22 | +
|
| 23 | +if auxOutput: |
| 24 | + outVal = 0 |
| 25 | + GPIO.setup(AUX_GPIO_3V3, GPIO.OUT, GPIO.PULL_NONE) |
| 26 | + GPIO.setup(AUX_GPIO_DIR, GPIO.OUT, GPIO.PULL_NONE) |
| 27 | + GPIO.write(AUX_GPIO_DIR, 1) |
| 28 | +else: |
| 29 | + GPIO.setup(AUX_GPIO_3V3, GPIO.IN, GPIO.PULL_NONE) |
| 30 | +
|
| 31 | +GPIO.setup(FSYNC_GPIO, GPIO.IN, GPIO.PULL_NONE) |
| 32 | +
|
| 33 | +while True: |
| 34 | + node.warn('') # separator |
| 35 | + if auxOutput: |
| 36 | + GPIO.write(AUX_GPIO_3V3, outVal) |
| 37 | + node.warn(f'AUX output ({AUX_GPIO_3V3}) set to: {outVal}') |
| 38 | + outVal = 1 - outVal # toggle for next iteration |
| 39 | + else: |
| 40 | + val = GPIO.read(AUX_GPIO_3V3) |
| 41 | + node.warn(f'AUX input ({AUX_GPIO_3V3}) is: {val}') |
| 42 | +
|
| 43 | + val = GPIO.read(FSYNC_GPIO) |
| 44 | + node.warn(f'FSYNC input ({FSYNC_GPIO}) is: {val}') |
| 45 | +
|
| 46 | + time.sleep(1) |
| 47 | +""") |
| 48 | + |
| 49 | +with dai.Device(pipeline) as device: |
| 50 | + while True: |
| 51 | + time.sleep(0.1) |
0 commit comments