Compare commits
No commits in common. "dcd0246843a2da7bdd6dd6a195e7e55372f7620a" and "fb617a5eecb00f6c988a296713f714c285b730c8" have entirely different histories.
dcd0246843
...
fb617a5eec
|
@ -111,34 +111,18 @@ def countdown(
|
||||||
|
|
||||||
# Do update stuff
|
# Do update stuff
|
||||||
|
|
||||||
# Calculate the current position
|
# Loop over every pixel ID that should be lit
|
||||||
current_position = round(num_pixels * ((seconds - current_time) / seconds))
|
# based on the elapsed time
|
||||||
|
for pixel in range(round(num_pixels * ((seconds - current_time) / seconds))):
|
||||||
# Catch a couple of special cases
|
# Set pixel color stuff
|
||||||
if current_position == 0:
|
if current_time < 0:
|
||||||
# Light the first LED when the timer starts
|
pass
|
||||||
# regardless of other factors
|
elif current_time <= redtime:
|
||||||
colorizer(0, colormode)
|
colorizer(pixel, colormode, red=True)
|
||||||
elif current_position == num_pixels and current_time > 0:
|
elif current_time <= yellowtime:
|
||||||
# If current_position calls for *all*
|
colorizer(pixel, colormode, yellow=True)
|
||||||
# pixels to be lit, and the timer
|
else:
|
||||||
# hasn't expired yet, don't do anything.
|
colorizer(pixel, colormode)
|
||||||
# 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
|
|
||||||
# based on the elapsed time
|
|
||||||
for pixel in range(current_position):
|
|
||||||
# Set pixel color stuff
|
|
||||||
if current_time < 0:
|
|
||||||
pass
|
|
||||||
elif current_time <= redtime:
|
|
||||||
colorizer(pixel, colormode, red=True)
|
|
||||||
elif current_time <= yellowtime:
|
|
||||||
colorizer(pixel, colormode, yellow=True)
|
|
||||||
else:
|
|
||||||
colorizer(pixel, colormode)
|
|
||||||
|
|
||||||
# Display the result IRL
|
# Display the result IRL
|
||||||
pixels.show()
|
pixels.show()
|
||||||
|
@ -147,13 +131,9 @@ def countdown(
|
||||||
current_time -= update_interval
|
current_time -= update_interval
|
||||||
|
|
||||||
# Massage the current_time seconds count into human-readable minutes:seconds
|
# Massage the current_time seconds count into human-readable minutes:seconds
|
||||||
display_time = str(datetime.timedelta(seconds=abs(current_time)))[3:]
|
display_time = divmod(abs(current_time), 60)
|
||||||
if current_time < 0:
|
if current_time < 0:
|
||||||
display_time_sign = "-"
|
display_time_sign = "-"
|
||||||
else:
|
else:
|
||||||
display_time_sign = " "
|
display_time_sign = " "
|
||||||
print("current time: " + display_time_sign + display_time)
|
print("current time: " + display_time_sign + str(display_time[0]) + ":" + str(display_time[1]))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue