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:
56
test/rainbow/5.py
Normal file
56
test/rainbow/5.py
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Rainbow test 5: Six nodes (ROYGBP), 0.8 second cycle, full brightness
|
||||
Runs forever
|
||||
Run with: mpremote run test/rainbow/5.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting Rainbow Test 5: Six nodes (ROYGBP), 0.8 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=800 # 0.8 second cycle
|
||||
)
|
||||
|
||||
# Configure test parameters
|
||||
p.n1 = 6 # 6 nodes
|
||||
p.delay = 800 # 0.8 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")
|
||||
|
||||
Reference in New Issue
Block a user