Skip to content

Commit

Permalink
Fix pulse animation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwohlbruck committed May 11, 2022
1 parent 55c6f8b commit 80be1dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions micro/app/led.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def set(state):
def set_effect(name):
global effect
effect = None
if effect:
if name:
sleep_ms(1)
effect = name

Expand Down Expand Up @@ -472,14 +472,15 @@ def flash(color=None):
def pulse(color=None, state=None):
if color:
set_gradient(set_color_gradient(color))

set_effect(EFFECT_PULSE)

state = state or copy()
start_new_thread(pulse_thread, (state,))

def pulse_thread(state):
global effect
while (effect == EFFECT_PULSE):
print('pulsing')
# Fade out from 100% to 50%
for i in range(20):
for j in range(led_count):
Expand Down
2 changes: 1 addition & 1 deletion micro/app/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def counter(callback_id, current_time, callback_memory):

def start_updater_chron():
mcron.init_timer()
mcron.insert(15 * 1000, {0}, '15m', counter) # Check update every 15 minutes
mcron.insert(15 * 60 * 1000, {0}, '15m', counter) # Check update every 15 minutes

def my_exception_processor(e):
print(e)
Expand Down

0 comments on commit 80be1dd

Please sign in to comment.