try:
import board
import neopixel
from adafruit_apds9960.apds9960 import APDS9960
import touchio
from src.interact import run
# Setup board
i2c = board.I2C()
apds = APDS9960(i2c)
pixels = neopixel.NeoPixel(board.NEOPIXEL, 2)
touch = touchio.TouchIn(board.TOUCH2)
apds.enable_proximity = True
print("Loaded Trinkey...")
# Try/except is unnecessary in this case, but when code is controlling physical systems
# it is good practice to catch all exceptions and handle shutdown gracefully
try:
# Run engine
run(pixels, adps, touch)
except Exception as e:
pixels.fill((0, 0, 0))
print("Exception has occurred! Shutting down...")
raise (e)
# Outer try/except clause so code can be tested outside the Trinkey.
except ModuleNotFoundError:
pass
-
Adam Blank authored1e7de354