Refactor rainbow pattern to travel along the length of LED strip

- Modified rainbow() to distribute colors along the physical length
- Each LED gets a different hue based on its position
- n1 parameter controls how many times the rainbow cycles (nodes)
- Split rainbow tests into test/rainbow/ directory with 9 numbered test files
- Each test runs forever until interrupted
- Added main.py to run all tests in sequence repeatedly
This commit is contained in:
2025-10-26 20:19:21 +13:00
parent 15626431ce
commit dce2954114
13 changed files with 615 additions and 124 deletions

View File

@@ -117,8 +117,11 @@ class Patterns(PatternBase): # Inherit from PatternBase
pos -= 170
return (0, pos * 3, 255 - pos * 3)
# Rainbow travels along the length - each LED position gets a different color
for i in range(self.num_leds):
rc_index = (i * 256 // self.num_leds) + self.pattern_step
# Map LED position along strip to rainbow color
# Full 256 color range distributed along the strip length
rc_index = ((i * 256 // self.num_leds) + self.pattern_step) % 256
self.n[i] = self.apply_brightness(wheel(rc_index & 255))
self.n.write()
self.pattern_step = (self.pattern_step + 1) % 256