Catch a couple special cases

- Light the first pixel on timer start
- Wait to light the last pixel until timer has truly elapsed
This commit is contained in:
David Thurstenson 2022-10-15 07:10:32 -05:00
parent 5637ec322a
commit dcd0246843
1 changed files with 28 additions and 12 deletions

View File

@ -111,9 +111,25 @@ def countdown(
# Do update stuff # Do update stuff
# Calculate the current position
current_position = round(num_pixels * ((seconds - current_time) / seconds))
# Catch a couple of special cases
if current_position == 0:
# Light the first LED when the timer starts
# regardless of other factors
colorizer(0, colormode)
elif current_position == num_pixels and current_time > 0:
# If current_position calls for *all*
# pixels to be lit, and the timer
# hasn't expired yet, don't do anything.
# This should delay the last pixel from
# lighting until the timer has fully elapsed
pass
else:
# 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 * ((seconds - current_time) / seconds))): for pixel in range(current_position):
# Set pixel color stuff # Set pixel color stuff
if current_time < 0: if current_time < 0:
pass pass