diff --git a/src/patterns/blink.py b/src/patterns/blink.py index 8a63fe5..4137754 100644 --- a/src/patterns/blink.py +++ b/src/patterns/blink.py @@ -28,6 +28,6 @@ class Blink: # "Off" phase: turn all LEDs off self.driver.fill((0, 0, 0)) state = not state - last_update = current_time + last_update = utime.ticks_add(last_update, delay_ms) # Yield once per tick so other logic can run yield diff --git a/src/patterns/chase.py b/src/patterns/chase.py index 837ac21..6edb4c8 100644 --- a/src/patterns/chase.py +++ b/src/patterns/chase.py @@ -118,7 +118,8 @@ class Chase: # Increment step step_count += 1 self.driver.step = step_count - last_update = current_time + last_update = utime.ticks_add(last_update, transition_duration) + transition_duration = max(10, int(preset.d)) # Yield once per tick so other logic can run yield diff --git a/src/patterns/circle.py b/src/patterns/circle.py index f063724..f31d699 100644 --- a/src/patterns/circle.py +++ b/src/patterns/circle.py @@ -62,7 +62,9 @@ class Circle: # Move head continuously at n1 LEDs per second if utime.ticks_diff(current_time, last_head_move) >= head_delay: head = (head + 1) % self.driver.num_leds - last_head_move = current_time + last_head_move = utime.ticks_add(last_head_move, head_delay) + head_rate = max(1, int(preset.n1)) + head_delay = 1000 // head_rate # Tail behavior based on phase if phase == "growing": @@ -73,7 +75,9 @@ class Circle: # Shrinking phase: move tail forward at n3 LEDs per second if utime.ticks_diff(current_time, last_tail_move) >= tail_delay: tail = (tail + 1) % self.driver.num_leds - last_tail_move = current_time + last_tail_move = utime.ticks_add(last_tail_move, tail_delay) + tail_rate = max(1, int(preset.n3)) + tail_delay = 1000 // tail_rate # Check if we've reached min length current_length = (head - tail) % self.driver.num_leds diff --git a/src/patterns/rainbow.py b/src/patterns/rainbow.py index 64c54e9..a49670e 100644 --- a/src/patterns/rainbow.py +++ b/src/patterns/rainbow.py @@ -46,6 +46,6 @@ class Rainbow: self.driver.n.write() step = (step + step_amount) % 256 self.driver.step = step - last_update = current_time + last_update = utime.ticks_add(last_update, sleep_ms) # Yield once per tick so other logic can run yield