59 lines
1.4 KiB
Python
59 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script for blink pattern
|
|
Run with: mpremote run test/blink.py
|
|
"""
|
|
|
|
import patterns
|
|
import utime
|
|
from settings import Settings
|
|
from machine import WDT
|
|
|
|
def test_blink():
|
|
print("Testing blink pattern...")
|
|
|
|
# Initialize watchdog timer
|
|
wdt = WDT(timeout=10000) # 10 second timeout
|
|
wdt.feed()
|
|
|
|
# Load settings
|
|
settings = Settings()
|
|
|
|
# Initialize patterns using settings
|
|
p = patterns.Patterns(
|
|
pin=settings["led_pin"],
|
|
num_leds=settings["num_leds"], # Set to 200 LEDs for test
|
|
brightness=255, # Full brightness
|
|
delay=500
|
|
)
|
|
|
|
# Set a bright red color
|
|
p.colors = [(255, 0, 0)] # Red
|
|
|
|
print(f"LED Pin: {settings['led_pin']}")
|
|
print(f"LEDs: {p.num_leds} (test override: 200)")
|
|
print(f"Brightness: {p.brightness}")
|
|
print(f"Delay: {p.delay}ms")
|
|
print(f"Color: {p.colors[0]}")
|
|
|
|
# Test blink pattern
|
|
print("Starting blink pattern for 5 seconds...")
|
|
p.select("bl")
|
|
|
|
# Let it run for 5 seconds with WDT feeding
|
|
start_time = utime.ticks_ms()
|
|
while utime.ticks_diff(utime.ticks_ms(), start_time) < 5000:
|
|
wdt.feed()
|
|
utime.sleep_ms(100)
|
|
|
|
# Stop the pattern
|
|
p.run = False
|
|
print("Blink test completed")
|
|
|
|
# Turn off LEDs
|
|
p.off()
|
|
print("LEDs turned off")
|
|
|
|
if __name__ == "__main__":
|
|
test_blink()
|