- 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
57 lines
1.2 KiB
Python
57 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Rainbow test 8: Many nodes (20), slow cycle (2 seconds), full brightness
|
|
Runs forever
|
|
Run with: mpremote run test/rainbow/8.py
|
|
"""
|
|
|
|
import patterns
|
|
import utime
|
|
from settings import Settings
|
|
from machine import WDT
|
|
|
|
print("Starting Rainbow Test 8: Many nodes (20), slow cycle (2 seconds)")
|
|
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=2000 # 2 second cycle
|
|
)
|
|
|
|
# Configure test parameters
|
|
p.n1 = 20 # 20 nodes
|
|
p.delay = 2000 # 2 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")
|
|
|