Compare commits
2 Commits
58e5c94d8a
...
fb617a5eec
Author | SHA1 | Date |
---|---|---|
David Thurstenson | fb617a5eec | |
David Thurstenson | 7097136a57 |
|
@ -43,7 +43,7 @@ pixels.show()
|
||||||
# or red parameters should be set to True. Behavior when
|
# or red parameters should be set to True. Behavior when
|
||||||
# red and yellow are both set to True depends on how the
|
# red and yellow are both set to True depends on how the
|
||||||
# colormode is configured.
|
# colormode is configured.
|
||||||
def colorizer(pxnum, colormode, yellow=False, red=False):
|
def colorizer(pxnum, colormode="fill", yellow=False, red=False):
|
||||||
# Every pixel from lowest to currently highest
|
# Every pixel from lowest to currently highest
|
||||||
if colormode == "fill":
|
if colormode == "fill":
|
||||||
if red:
|
if red:
|
||||||
|
@ -86,8 +86,8 @@ def countdown(
|
||||||
# Init the update interval tracking variable
|
# Init the update interval tracking variable
|
||||||
last_update_time = -1
|
last_update_time = -1
|
||||||
|
|
||||||
# Init the elapsed time variable
|
# Init the current time variable
|
||||||
elapsed_time = 0
|
current_time = seconds
|
||||||
|
|
||||||
# This begins what I like to call the "Are We There Yet?"
|
# This begins what I like to call the "Are We There Yet?"
|
||||||
# loop. Instead of making the script wait for an interval
|
# loop. Instead of making the script wait for an interval
|
||||||
|
@ -113,11 +113,13 @@ def countdown(
|
||||||
|
|
||||||
# Loop over every pixel ID that should be lit
|
# Loop over every pixel ID that should be lit
|
||||||
# based on the elapsed time
|
# based on the elapsed time
|
||||||
for pixel in range(round(num_pixels * (elapsed_time / seconds))):
|
for pixel in range(round(num_pixels * ((seconds - current_time) / seconds))):
|
||||||
# Set pixel color stuff
|
# Set pixel color stuff
|
||||||
if elapsed_time >= seconds - redtime:
|
if current_time < 0:
|
||||||
|
pass
|
||||||
|
elif current_time <= redtime:
|
||||||
colorizer(pixel, colormode, red=True)
|
colorizer(pixel, colormode, red=True)
|
||||||
elif elapsed_time >= seconds - yellowtime:
|
elif current_time <= yellowtime:
|
||||||
colorizer(pixel, colormode, yellow=True)
|
colorizer(pixel, colormode, yellow=True)
|
||||||
else:
|
else:
|
||||||
colorizer(pixel, colormode)
|
colorizer(pixel, colormode)
|
||||||
|
@ -126,4 +128,12 @@ def countdown(
|
||||||
pixels.show()
|
pixels.show()
|
||||||
|
|
||||||
# Increment the elapsed time variable
|
# Increment the elapsed time variable
|
||||||
elapsed_time += update_interval
|
current_time -= update_interval
|
||||||
|
|
||||||
|
# Massage the current_time seconds count into human-readable minutes:seconds
|
||||||
|
display_time = divmod(abs(current_time), 60)
|
||||||
|
if current_time < 0:
|
||||||
|
display_time_sign = "-"
|
||||||
|
else:
|
||||||
|
display_time_sign = " "
|
||||||
|
print("current time: " + display_time_sign + str(display_time[0]) + ":" + str(display_time[1]))
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
import time
|
||||||
|
import board
|
||||||
|
import digitalio
|
||||||
|
import neopixel
|
||||||
|
from adafruit_led_animation.animation.rainbow import Rainbow
|
||||||
|
|
||||||
|
pixel_pin = board.GP28
|
||||||
|
num_pixels = 1
|
||||||
|
brightness = 0.2
|
||||||
|
|
||||||
|
|
||||||
|
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=brightness, auto_write=False)
|
||||||
|
|
||||||
|
rainbow = Rainbow(pixels, 0.01, period=10)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
rainbow.animate()
|
Loading…
Reference in New Issue