import os, sys, inspect, logging, time lib_folder = os.path.join( os.path.split(inspect.getfile(inspect.currentframe()))[0], '..') lib_load = os.path.realpath(os.path.abspath(lib_folder)) if lib_load not in sys.path: sys.path.insert(0, lib_load) import capablerobot_usbhub hub = capablerobot_usbhub.USBHub() ## Input enabled here on the output so that reading the output's current state works hub.gpio.configure(ios=[0], output=True, input=True) hub.gpio.configure(ios=[1], input=True, pull_down=True) while True: hub.gpio.io0 = True print("IO {} {}".format(*hub.gpio.io)) time.sleep(1) hub.gpio.io0 = False print("IO {} {}".format(*hub.gpio.io)) time.sleep(1)
BEAT = 0.05 LED_BRIGHT = 80 def stdout(*args): if supervisor.runtime.serial_connected: print(*args) stdout("... booted ...") i2c1 = busio.I2C(board.SCL, board.SDA) i2c2 = busio.I2C(board.SCL2, board.SDA2) stdout("... configuring hub ...") usb = capablerobot_usbhub.USBHub(i2c1, i2c2) ucs = capablerobot_ucs2113.Ports(i2c1) stdout("... configuring leds ...") BRIGHT = 20 led_pwr = capablerobot_tlc59116.TLC59116(i2c1, 0x61, pwm=BRIGHT) led_data = capablerobot_tlc59116.TLC59116(i2c1, 0x62, pwm=BRIGHT) stdout() stdout("Unit SKU : %s" % usb.unit_sku) stdout("Revision : %s" % usb.unit_revision) stdout(" Serial : %s" % usb.unit_serial) stdout() upstream_state = 'reset' upstream_last_time = boot_time