convert blink to use a thread
This commit is contained in:
40
test/blink.py
Normal file
40
test/blink.py
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script for blink pattern
|
||||
Run with: mpremote run test/blink.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
|
||||
def test_blink():
|
||||
print("Testing blink pattern...")
|
||||
|
||||
# Initialize patterns with LED pin 10 and 59 LEDs at 20% brightness
|
||||
p = patterns.Patterns(pin=10, num_leds=59, brightness=51, delay=500)
|
||||
|
||||
# Set a bright red color
|
||||
p.colors = [(255, 0, 0)] # Red
|
||||
|
||||
print(f"LEDs: {p.num_leds}")
|
||||
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
|
||||
utime.sleep(5)
|
||||
|
||||
# Stop the pattern
|
||||
p.run = False
|
||||
print("Blink test completed")
|
||||
|
||||
# Turn off LEDs
|
||||
p.off()
|
||||
print("LEDs turned off")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_blink()
|
||||
Reference in New Issue
Block a user