Skip to content

Disco Tie - fix for animating while disconnected #982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions Disco_Tie/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,23 @@ def change_speed(mod, old_speed):
new_speed = constrain(old_speed + mod, 1.0, 10.0)
return(new_speed, map_value(new_speed, 10.0, 0.0, 0.01, 0.3))

def animate(pause, top):
# Determine animation based on mode
if mode == 0:
top = audio_meter(top)
elif mode == 1:
rainbow_cycle(0.001)
elif mode == 2:
larsen(pause)
elif mode == 3:
solid(user_color)
return top

while True:
ble.start_advertising(advertisement)
while not ble.connected:
pass
# Animate while disconnected
peak = animate(wait, peak)

# While BLE is connected
while ble.connected:
Expand Down Expand Up @@ -232,12 +245,5 @@ def change_speed(mod, old_speed):
elif packet.button == ButtonPacket.BUTTON_4:
mode = 3

# Determine animation based on mode
if mode == 0:
peak = audio_meter(peak)
elif mode == 1:
rainbow_cycle(0.001)
elif mode == 2:
larsen(wait)
elif mode == 3:
solid(user_color)
# Animate while connected
peak = animate(wait, peak)