59 lines
1.3 KiB
Python
59 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Circle loading test 2: n1=10, n2=30, n3=20, n4=5 (Green)
|
|
Runs forever
|
|
Run with: mpremote run test/circle/2.py
|
|
"""
|
|
|
|
import patterns
|
|
import utime
|
|
from settings import Settings
|
|
from machine import WDT
|
|
|
|
print("Starting Circle Loading Test 2: n1=10, n2=30, n3=20, n4=5 (Green)")
|
|
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
|
|
)
|
|
|
|
# Configure test parameters
|
|
p.n1 = 10 # Head moves 10 LEDs/second
|
|
p.n2 = 30 # Max length 30 LEDs
|
|
p.n3 = 20 # Tail moves 20 LEDs/second
|
|
p.n4 = 5 # Min length 5 LEDs
|
|
p.colors = [(0, 255, 0)] # Green
|
|
|
|
print(f"LED Pin: {settings['led_pin']}")
|
|
print(f"LEDs: {settings['num_leds']}")
|
|
print(f"Brightness: {p.brightness}")
|
|
print(f"Parameters: n1={p.n1}, n2={p.n2}, n3={p.n3}, n4={p.n4}")
|
|
print(f"Color: {p.colors[0]}")
|
|
|
|
# Initialize watchdog timer
|
|
wdt = WDT(timeout=10000)
|
|
wdt.feed()
|
|
|
|
# Start pattern
|
|
p.select("cl")
|
|
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")
|
|
|