From c2deee3ebd525615c228431788e95ba090dd705e Mon Sep 17 00:00:00 2001 From: David Thurstenson Date: Thu, 10 Aug 2023 09:41:36 -0500 Subject: [PATCH] Added neopixel on rotary encoder breakout board for user feedback --- colorbar-fastloop.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/colorbar-fastloop.py b/colorbar-fastloop.py index 0db7894..617e8c7 100644 --- a/colorbar-fastloop.py +++ b/colorbar-fastloop.py @@ -3,6 +3,7 @@ import board import neopixel import adafruit_datetime as datetime from adafruit_seesaw import seesaw, rotaryio, digitalio +from adafruit_seesaw import neopixel as seesaw_neopixel from adafruit_debouncer import Button import busio import displayio @@ -85,16 +86,24 @@ pixels = neopixel.NeoPixel( pixel_order="GRBW" ) +# Set up user-facing neopixel on rotary breakout +userpixel = seesaw_neopixel.NeoPixel(seesaw, 6, 1, + brightness=brightness, + auto_write=False) + + # Colors used in this script # FORMAT: (R, G, B, W) RED = (255, 0, 0, 0) YELLOW = (255, 150, 0, 0) GREEN = (0, 255, 0, 0) -BLANK = (0, 0, 0) +BLANK = (0, 0, 0, 0) # Turn all pixels off pixels.fill(BLANK) pixels.show() +userpixel.fill(BLANK) +userpixel.show() # END Neopixel setup #### @@ -182,6 +191,8 @@ def countdown( # Turn all pixels off pixels.fill(BLANK) pixels.show() + userpixel.fill(BLANK) + userpixel.show() # Init the update interval tracking variable last_update_time = -1 @@ -228,6 +239,7 @@ def countdown( # Light the first LED when the timer starts # regardless of other factors colorizer(0, colormode) + userpixel.fill(GREEN) elif current_position == num_pixels and current_time > 0: # If current_position calls for *all* # pixels to be lit, and the timer @@ -248,14 +260,18 @@ def countdown( pass elif current_time <= redtime: colorizer(pixel, colormode, red=True) + userpixel.fill(RED) elif current_time <= yellowtime: colorizer(pixel, colormode, yellow=True) + userpixel.fill(YELLOW) else: colorizer(pixel, colormode) + userpixel.fill(GREEN) # All the pixels have now been set based on the # specified colormode, now display the result IRL. pixels.show() + userpixel.show() # Increment the elapsed time variable current_time -= update_interval @@ -328,3 +344,5 @@ while True: # Turn off all pixels pixels.fill(BLANK) pixels.show() + userpixel.fill(BLANK) + userpixel.show()