Fix n_chase pattern to properly chase through all LED positions
- Replace oscillating behavior with proper chasing movement - Use pattern_step for internal tracking instead of controller's step - Calculate position relative to chase head: (i - pattern_step) % num_leds - Chase head moves through all LED positions with n3 step multiplier - n1 controls width of lit chase segment
This commit is contained in:
@@ -89,13 +89,21 @@ class Patterns(PatternBase): # Inherit from PatternBase
|
||||
self.last_update = current_time
|
||||
return self.delay
|
||||
|
||||
# Use pattern_step for internal chasing, not the controller's step
|
||||
if not hasattr(self, 'pattern_step'):
|
||||
self.pattern_step = 0
|
||||
|
||||
for i in range(self.num_leds):
|
||||
if (i + self.pattern_step) % segment_length < self.n1:
|
||||
# Calculate position relative to the chase head
|
||||
pos_from_head = (i - self.pattern_step) % self.num_leds
|
||||
if pos_from_head < self.n1:
|
||||
self.n[i] = self.apply_brightness(self.colors[0])
|
||||
else:
|
||||
self.n[i] = (0, 0, 0)
|
||||
self.n.write()
|
||||
self.pattern_step = (self.pattern_step + step_rate) % segment_length
|
||||
|
||||
# Update internal pattern step for chasing
|
||||
self.pattern_step = (self.pattern_step + step_rate) % self.num_leds
|
||||
self.last_update = current_time
|
||||
return self.delay
|
||||
|
||||
@@ -129,7 +137,7 @@ class Patterns(PatternBase): # Inherit from PatternBase
|
||||
self.n[i] = active_color
|
||||
|
||||
self.n.write()
|
||||
self.step = (self.step + 1) % 2
|
||||
# Don't update step - use the step value sent from controller for synchronization
|
||||
return max(1, int(self.delay // 2))
|
||||
|
||||
|
||||
@@ -189,10 +197,10 @@ class Patterns(PatternBase): # Inherit from PatternBase
|
||||
|
||||
step_rate = max(1, int(self.n3))
|
||||
for i in range(self.num_leds):
|
||||
rc_index = (i * 256 // max(1, self.num_leds)) + self.pattern_step
|
||||
rc_index = (i * 256 // max(1, self.num_leds)) + self.step
|
||||
self.n[i] = self.apply_brightness(wheel(rc_index & 255))
|
||||
self.n.write()
|
||||
self.pattern_step = (self.pattern_step + step_rate) % 256
|
||||
self.step = (self.step + step_rate) % 256
|
||||
return max(1, int(self.delay // 5))
|
||||
|
||||
def specto(self):
|
||||
|
Reference in New Issue
Block a user