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

56
test/rainbow/7.py Normal file
View File

@@ -0,0 +1,56 @@
#!/usr/bin/env python3
"""
Rainbow test 7: Twelve nodes (fine gradation), 0.4 second cycle, full brightness
Runs forever
Run with: mpremote run test/rainbow/7.py
"""
import patterns
import utime
from settings import Settings
from machine import WDT
print("Starting Rainbow Test 7: Twelve nodes (fine gradation), 0.4 second cycle")
print("Press Ctrl+C to stop")
# Load settings
settings = Settings()
# Initialize patterns using settings
p = patterns.Patterns(
pin=settings["led_pin"],
num_leds=settings["num_leds"],
brightness=255,
delay=400 # 0.4 second cycle
)
# Configure test parameters
p.n1 = 12 # 12 nodes
p.delay = 400 # 0.4 second cycle
p.brightness = 255 # Full brightness
print(f"LED Pin: {settings['led_pin']}")
print(f"LEDs: {settings['num_leds']}")
print(f"Brightness: {p.brightness}")
print(f"Delay: {p.delay}ms")
print(f"Nodes: {p.n1}")
# Initialize watchdog timer
wdt = WDT(timeout=10000)
wdt.feed()
# Start pattern
p.select("rb")
print("Pattern started. Running forever...")
# Run forever
try:
while True:
wdt.feed()
utime.sleep_ms(100)
except KeyboardInterrupt:
print("\nStopping...")
p.run = False
p.off()
print("LEDs turned off")