Compare commits
5 Commits
espnow
...
b13ec01561
| Author | SHA1 | Date | |
|---|---|---|---|
| b13ec01561 | |||
| 83cb34d6a8 | |||
| c9449a6d86 | |||
| 059bd41a59 | |||
| 9fad8b1ae5 |
49
src/main.py
49
src/main.py
@@ -17,10 +17,6 @@ def main():
|
||||
settings = Settings()
|
||||
print(settings)
|
||||
|
||||
if settings.get("color_order", "rgb") == "rbg":
|
||||
color_order = (1, 5, 3)
|
||||
else:
|
||||
color_order = (1, 3, 5)
|
||||
patterns = Patterns(settings["led_pin"], settings["num_leds"], selected="off")
|
||||
|
||||
sta_if = network.WLAN(network.STA_IF)
|
||||
@@ -57,31 +53,30 @@ def main():
|
||||
message_type = defaults.get("t", "b") # Default to beat if not specified
|
||||
|
||||
# Always update parameters from message
|
||||
patterns.brightness = bar.get("br", defaults.get("br", patterns.brightness))
|
||||
patterns.delay = bar.get("dl", defaults.get("dl", patterns.delay))
|
||||
patterns.colors = bar.get("cl", defaults.get("cl", patterns.colors))
|
||||
patterns.n1 = bar.get("n1", defaults.get("n1", patterns.n1))
|
||||
patterns.n2 = bar.get("n2", defaults.get("n2", patterns.n2))
|
||||
patterns.n3 = bar.get("n3", defaults.get("n3", patterns.n3))
|
||||
patterns.n4 = bar.get("n4", defaults.get("n4", patterns.n4))
|
||||
patterns.step = bar.get("s", defaults.get("s", patterns.step))
|
||||
param_mapping = {
|
||||
"br": "brightness",
|
||||
"dl": "delay",
|
||||
"cl": "colors",
|
||||
"n1": "n1",
|
||||
"n2": "n2",
|
||||
"n3": "n3",
|
||||
"n4": "n4",
|
||||
"s": "step"
|
||||
}
|
||||
|
||||
# Iterate through values in bar and update parameters
|
||||
print("Bar values:")
|
||||
for key, value in bar.items():
|
||||
print(f" {key}: {value}")
|
||||
|
||||
# Update parameter if it exists in param_mapping
|
||||
if key in param_mapping:
|
||||
attr_name = param_mapping[key]
|
||||
current_value = getattr(patterns, attr_name)
|
||||
new_value = bar.get(key, defaults.get(key, current_value))
|
||||
setattr(patterns, attr_name, new_value)
|
||||
|
||||
# Print received parameters
|
||||
print(f"Params: br={patterns.brightness}, dl={patterns.delay}, n1={patterns.n1}, n2={patterns.n2}, n3={patterns.n3}, n4={patterns.n4}, step={patterns.step}")
|
||||
|
||||
# Only execute pattern if it's a beat message
|
||||
if message_type == "b": # Beat message
|
||||
selected_pattern = bar.get("pt", defaults.get("pt", "off"))
|
||||
if selected_pattern in patterns.patterns:
|
||||
# Run the selected pattern ONCE in response to this beat message
|
||||
patterns.patterns[selected_pattern]()
|
||||
else:
|
||||
print(f"Pattern {selected_pattern} not found")
|
||||
elif message_type == "u": # Update message
|
||||
# Just update parameters, don't execute pattern
|
||||
print(f"Parameters updated: brightness={patterns.brightness}, delay={patterns.delay}")
|
||||
else:
|
||||
print(f"Unknown message type: {message_type}")
|
||||
except Exception as ex:
|
||||
print(f"Failed to load espnow data {last_msg}: {ex}")
|
||||
continue
|
||||
|
||||
20
src/p2p.py
20
src/p2p.py
@@ -1,20 +0,0 @@
|
||||
import asyncio
|
||||
import aioespnow
|
||||
import json
|
||||
|
||||
async def p2p(settings, patterns):
|
||||
e = aioespnow.AIOESPNow() # Returns AIOESPNow enhanced with async support
|
||||
e.active(True)
|
||||
async for mac, msg in e:
|
||||
try:
|
||||
data = json.loads(msg)
|
||||
except:
|
||||
print(f"Failed to load espnow data {msg}")
|
||||
continue
|
||||
print(data)
|
||||
if "names" not in data or settings.get("name") in data.get("names", []):
|
||||
if "step" in settings and isinstance(settings["step"], int):
|
||||
patterns.set_pattern_step(settings["step"])
|
||||
else:
|
||||
settings.set_settings(data.get("settings", {}), patterns, data.get("save", False))
|
||||
print("should not print")
|
||||
1071
src/patterns.py
1071
src/patterns.py
File diff suppressed because it is too large
Load Diff
58
test/blink.py
Normal file
58
test/blink.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/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()
|
||||
58
test/circle/1.py
Normal file
58
test/circle/1.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Circle loading test 1: n1=50, n2=100, n3=200, n4=0 (Red)
|
||||
Runs forever
|
||||
Run with: mpremote run test/circle/1.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting Circle Loading Test 1: n1=50, n2=100, n3=200, n4=0 (Red)")
|
||||
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 = 50 # Head moves 50 LEDs/second
|
||||
p.n2 = 100 # Max length 100 LEDs
|
||||
p.n3 = 200 # Tail moves 200 LEDs/second
|
||||
p.n4 = 0 # Min length 0 LEDs
|
||||
p.colors = [(255, 0, 0)] # Red
|
||||
|
||||
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")
|
||||
|
||||
58
test/circle/2.py
Normal file
58
test/circle/2.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/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")
|
||||
|
||||
58
test/circle/3.py
Normal file
58
test/circle/3.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Circle loading test 3: n1=15, n2=25, n3=15, n4=3 (Blue)
|
||||
Runs forever
|
||||
Run with: mpremote run test/circle/3.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting Circle Loading Test 3: n1=15, n2=25, n3=15, n4=3 (Blue)")
|
||||
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 = 15 # Head moves 15 LEDs/second
|
||||
p.n2 = 25 # Max length 25 LEDs
|
||||
p.n3 = 15 # Tail moves 15 LEDs/second
|
||||
p.n4 = 3 # Min length 3 LEDs
|
||||
p.colors = [(0, 0, 255)] # Blue
|
||||
|
||||
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")
|
||||
|
||||
58
test/circle/4.py
Normal file
58
test/circle/4.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Circle loading test 4: n1=30, n2=40, n3=5, n4=8 (Yellow)
|
||||
Runs forever
|
||||
Run with: mpremote run test/circle/4.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting Circle Loading Test 4: n1=30, n2=40, n3=5, n4=8 (Yellow)")
|
||||
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 = 30 # Head moves 30 LEDs/second
|
||||
p.n2 = 40 # Max length 40 LEDs
|
||||
p.n3 = 5 # Tail moves 5 LEDs/second
|
||||
p.n4 = 8 # Min length 8 LEDs
|
||||
p.colors = [(255, 255, 0)] # Yellow
|
||||
|
||||
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")
|
||||
|
||||
58
test/circle/5.py
Normal file
58
test/circle/5.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Circle loading test 5: n1=25, n2=60, n3=30, n4=2 (Magenta)
|
||||
Runs forever
|
||||
Run with: mpremote run test/circle/5.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting Circle Loading Test 5: n1=25, n2=60, n3=30, n4=2 (Magenta)")
|
||||
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 = 25 # Head moves 25 LEDs/second
|
||||
p.n2 = 60 # Max length 60 LEDs
|
||||
p.n3 = 30 # Tail moves 30 LEDs/second
|
||||
p.n4 = 2 # Min length 2 LEDs
|
||||
p.colors = [(255, 0, 255)] # Magenta
|
||||
|
||||
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")
|
||||
|
||||
58
test/circle/6.py
Normal file
58
test/circle/6.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Circle loading test 6: n1=5, n2=20, n3=40, n4=1 (Cyan)
|
||||
Runs forever
|
||||
Run with: mpremote run test/circle/6.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting Circle Loading Test 6: n1=5, n2=20, n3=40, n4=1 (Cyan)")
|
||||
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 = 5 # Head moves 5 LEDs/second
|
||||
p.n2 = 20 # Max length 20 LEDs
|
||||
p.n3 = 40 # Tail moves 40 LEDs/second
|
||||
p.n4 = 1 # Min length 1 LED
|
||||
p.colors = [(0, 255, 255)] # Cyan
|
||||
|
||||
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")
|
||||
|
||||
58
test/circle/7.py
Normal file
58
test/circle/7.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Circle loading test 7: n1=12, n2=15, n3=18, n4=4 (Orange)
|
||||
Runs forever
|
||||
Run with: mpremote run test/circle/7.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting Circle Loading Test 7: n1=12, n2=15, n3=18, n4=4 (Orange)")
|
||||
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 = 12 # Head moves 12 LEDs/second
|
||||
p.n2 = 15 # Max length 15 LEDs
|
||||
p.n3 = 18 # Tail moves 18 LEDs/second
|
||||
p.n4 = 4 # Min length 4 LEDs
|
||||
p.colors = [(255, 128, 0)] # Orange
|
||||
|
||||
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")
|
||||
|
||||
58
test/circle/8.py
Normal file
58
test/circle/8.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Circle loading test 8: n1=100, n2=50, n3=150, n4=10 (Purple)
|
||||
Runs forever
|
||||
Run with: mpremote run test/circle/8.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting Circle Loading Test 8: n1=100, n2=50, n3=150, n4=10 (Purple)")
|
||||
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 = 100 # Head moves 100 LEDs/second
|
||||
p.n2 = 50 # Max length 50 LEDs
|
||||
p.n3 = 150 # Tail moves 150 LEDs/second
|
||||
p.n4 = 10 # Min length 10 LEDs
|
||||
p.colors = [(128, 0, 255)] # Purple
|
||||
|
||||
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")
|
||||
|
||||
128
test/circle_loading.py
Normal file
128
test/circle_loading.py
Normal file
@@ -0,0 +1,128 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script for circle loading pattern with multiple test cases
|
||||
Run with: mpremote run test/circle_loading.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
def run_test_case(p, test_name, duration_ms=5000):
|
||||
"""Run a test case for specified duration"""
|
||||
print(f"\n--- {test_name} ---")
|
||||
print(f"Parameters: n1={p.n1} head/sec, n2={p.n2} max length, n3={p.n3} tail/sec, n4={p.n4} min length")
|
||||
print(f"Color: {p.colors[0]}")
|
||||
print(f"Running for {duration_ms//1000} seconds...")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("cl")
|
||||
|
||||
# Run for specified duration
|
||||
start_time = utime.ticks_ms()
|
||||
while utime.ticks_diff(utime.ticks_ms(), start_time) < duration_ms:
|
||||
wdt.feed()
|
||||
utime.sleep_ms(100)
|
||||
|
||||
# Stop pattern
|
||||
p.run = False
|
||||
print(f"{test_name} completed")
|
||||
|
||||
# Brief pause between tests
|
||||
utime.sleep_ms(500)
|
||||
|
||||
def test_circle_loading():
|
||||
print("Testing circle loading pattern with multiple configurations...")
|
||||
|
||||
# Load settings
|
||||
settings = Settings()
|
||||
|
||||
# Initialize patterns using settings
|
||||
p = patterns.Patterns(
|
||||
pin=settings["led_pin"],
|
||||
num_leds=settings["num_leds"],
|
||||
brightness=255,
|
||||
delay=2000 # Base cycle time
|
||||
)
|
||||
|
||||
print(f"LED Pin: {settings['led_pin']}")
|
||||
print(f"LEDs: {settings['num_leds']}")
|
||||
print(f"Brightness: {p.brightness}")
|
||||
|
||||
# Test Case 1: Your specified parameters
|
||||
p.n1 = 50
|
||||
p.n2 = 100
|
||||
p.n3 = 200
|
||||
p.n4 = 0
|
||||
p.colors = [(255, 0, 0)] # Red
|
||||
run_test_case(p, "Test 1: n1=50, n2=100, n3=200, n4=0", 15000)
|
||||
|
||||
# Test Case 2: Slow head, fast tail
|
||||
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
|
||||
run_test_case(p, "Test 2: n1=10, n2=30, n3=20, n4=5", 10000)
|
||||
|
||||
# Test Case 3: Equal head and tail speed
|
||||
p.n1 = 15 # Head moves 15 LEDs/second
|
||||
p.n2 = 25 # Max length 25 LEDs
|
||||
p.n3 = 15 # Tail moves 15 LEDs/second
|
||||
p.n4 = 3 # Min length 3 LEDs
|
||||
p.colors = [(0, 0, 255)] # Blue
|
||||
run_test_case(p, "Test 3: n1=15, n2=25, n3=15, n4=3", 8000)
|
||||
|
||||
# Test Case 4: Very fast head, slow tail
|
||||
p.n1 = 30 # Head moves 30 LEDs/second
|
||||
p.n2 = 40 # Max length 40 LEDs
|
||||
p.n3 = 5 # Tail moves 5 LEDs/second
|
||||
p.n4 = 8 # Min length 8 LEDs
|
||||
p.colors = [(255, 255, 0)] # Yellow
|
||||
run_test_case(p, "Test 4: n1=30, n2=40, n3=5, n4=8", 12000)
|
||||
|
||||
# Test Case 5: Long segment, fast cycle
|
||||
p.n1 = 25 # Head moves 25 LEDs/second
|
||||
p.n2 = 60 # Max length 60 LEDs
|
||||
p.n3 = 30 # Tail moves 30 LEDs/second
|
||||
p.n4 = 2 # Min length 2 LEDs
|
||||
p.colors = [(255, 0, 255)] # Magenta
|
||||
run_test_case(p, "Test 5: n1=25, n2=60, n3=30, n4=2", 10000)
|
||||
|
||||
# Test Case 6: Very slow head, very fast tail
|
||||
p.n1 = 5 # Head moves 5 LEDs/second
|
||||
p.n2 = 20 # Max length 20 LEDs
|
||||
p.n3 = 40 # Tail moves 40 LEDs/second
|
||||
p.n4 = 1 # Min length 1 LED
|
||||
p.colors = [(0, 255, 255)] # Cyan
|
||||
run_test_case(p, "Test 6: n1=5, n2=20, n3=40, n4=1", 8000)
|
||||
|
||||
# Test Case 7: Medium speeds, short segment
|
||||
p.n1 = 12 # Head moves 12 LEDs/second
|
||||
p.n2 = 15 # Max length 15 LEDs
|
||||
p.n3 = 18 # Tail moves 18 LEDs/second
|
||||
p.n4 = 4 # Min length 4 LEDs
|
||||
p.colors = [(255, 128, 0)] # Orange
|
||||
run_test_case(p, "Test 7: n1=12, n2=15, n3=18, n4=4", 6000)
|
||||
|
||||
# Test Case 8: Ultra fast everything
|
||||
p.n1 = 100 # Head moves 100 LEDs/second
|
||||
p.n2 = 50 # Max length 50 LEDs
|
||||
p.n3 = 150 # Tail moves 150 LEDs/second
|
||||
p.n4 = 10 # Min length 10 LEDs
|
||||
p.colors = [(128, 0, 255)] # Purple
|
||||
run_test_case(p, "Test 8: n1=100, n2=50, n3=150, n4=10", 5000)
|
||||
|
||||
print("\n=== All tests completed ===")
|
||||
|
||||
# Turn off LEDs
|
||||
p.off()
|
||||
print("LEDs turned off")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_circle_loading()
|
||||
56
test/flicker/1.py
Normal file
56
test/flicker/1.py
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Flicker test 1: Red, delay=50ms, min brightness=50
|
||||
Runs forever
|
||||
Run with: mpremote run test/flicker/1.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting Flicker Test 1: Red, delay=50ms, min brightness=50")
|
||||
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=50
|
||||
)
|
||||
|
||||
# Configure test parameters
|
||||
p.n1 = 50 # Min brightness 50
|
||||
p.colors = [(255, 0, 0)] # Red
|
||||
|
||||
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"Min brightness: {p.n1}")
|
||||
print(f"Color: {p.colors[0]}")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("fl")
|
||||
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")
|
||||
|
||||
56
test/flicker/2.py
Normal file
56
test/flicker/2.py
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Flicker test 2: Green, delay=100ms, min brightness=100
|
||||
Runs forever
|
||||
Run with: mpremote run test/flicker/2.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting Flicker Test 2: Green, delay=100ms, min brightness=100")
|
||||
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=100
|
||||
)
|
||||
|
||||
# Configure test parameters
|
||||
p.n1 = 100 # Min brightness 100
|
||||
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"Delay: {p.delay}ms")
|
||||
print(f"Min brightness: {p.n1}")
|
||||
print(f"Color: {p.colors[0]}")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("fl")
|
||||
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")
|
||||
|
||||
56
test/flicker/3.py
Normal file
56
test/flicker/3.py
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Flicker test 3: Blue, delay=200ms, min brightness=20
|
||||
Runs forever
|
||||
Run with: mpremote run test/flicker/3.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting Flicker Test 3: Blue, delay=200ms, min brightness=20")
|
||||
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=200
|
||||
)
|
||||
|
||||
# Configure test parameters
|
||||
p.n1 = 20 # Min brightness 20
|
||||
p.colors = [(0, 0, 255)] # Blue
|
||||
|
||||
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"Min brightness: {p.n1}")
|
||||
print(f"Color: {p.colors[0]}")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("fl")
|
||||
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")
|
||||
|
||||
56
test/flicker/4.py
Normal file
56
test/flicker/4.py
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Flicker test 4: White, delay=80ms, min brightness=150
|
||||
Runs forever
|
||||
Run with: mpremote run test/flicker/4.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting Flicker Test 4: White, delay=80ms, min brightness=150")
|
||||
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=80
|
||||
)
|
||||
|
||||
# Configure test parameters
|
||||
p.n1 = 150 # Min brightness 150
|
||||
p.colors = [(255, 255, 255)] # White
|
||||
|
||||
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"Min brightness: {p.n1}")
|
||||
print(f"Color: {p.colors[0]}")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("fl")
|
||||
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")
|
||||
|
||||
56
test/flicker/5.py
Normal file
56
test/flicker/5.py
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Flicker test 5: Yellow, delay=150ms, min brightness=30
|
||||
Runs forever
|
||||
Run with: mpremote run test/flicker/5.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting Flicker Test 5: Yellow, delay=150ms, min brightness=30")
|
||||
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=150
|
||||
)
|
||||
|
||||
# Configure test parameters
|
||||
p.n1 = 30 # Min brightness 30
|
||||
p.colors = [(255, 255, 0)] # Yellow
|
||||
|
||||
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"Min brightness: {p.n1}")
|
||||
print(f"Color: {p.colors[0]}")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("fl")
|
||||
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")
|
||||
|
||||
56
test/flicker/6.py
Normal file
56
test/flicker/6.py
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Flicker test 6: Magenta, delay=60ms, min brightness=80
|
||||
Runs forever
|
||||
Run with: mpremote run test/flicker/6.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting Flicker Test 6: Magenta, delay=60ms, min brightness=80")
|
||||
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=60
|
||||
)
|
||||
|
||||
# Configure test parameters
|
||||
p.n1 = 80 # Min brightness 80
|
||||
p.colors = [(255, 0, 255)] # Magenta
|
||||
|
||||
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"Min brightness: {p.n1}")
|
||||
print(f"Color: {p.colors[0]}")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("fl")
|
||||
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")
|
||||
|
||||
56
test/flicker/7.py
Normal file
56
test/flicker/7.py
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Flicker test 7: Cyan, delay=120ms, min brightness=5
|
||||
Runs forever
|
||||
Run with: mpremote run test/flicker/7.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting Flicker Test 7: Cyan, delay=120ms, min brightness=5")
|
||||
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=120
|
||||
)
|
||||
|
||||
# Configure test parameters
|
||||
p.n1 = 5 # Min brightness 5
|
||||
p.colors = [(0, 255, 255)] # Cyan
|
||||
|
||||
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"Min brightness: {p.n1}")
|
||||
print(f"Color: {p.colors[0]}")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("fl")
|
||||
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")
|
||||
|
||||
56
test/flicker/8.py
Normal file
56
test/flicker/8.py
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Flicker test 8: Orange, delay=40ms, min brightness=180
|
||||
Runs forever
|
||||
Run with: mpremote run test/flicker/8.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting Flicker Test 8: Orange, delay=40ms, min brightness=180")
|
||||
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=40
|
||||
)
|
||||
|
||||
# Configure test parameters
|
||||
p.n1 = 180 # Min brightness 180
|
||||
p.colors = [(255, 128, 0)] # Orange
|
||||
|
||||
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"Min brightness: {p.n1}")
|
||||
print(f"Color: {p.colors[0]}")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("fl")
|
||||
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")
|
||||
|
||||
@@ -75,7 +75,7 @@ async def run_suite(uri: str):
|
||||
i,
|
||||
delay=cfg.get("delay"),
|
||||
colors=cfg.get("colors"),
|
||||
brightness=cfg.get("brightness", 127),
|
||||
brightness=cfg.get("brightness", 255),
|
||||
num_leds=cfg.get("num_leds"),
|
||||
n1=cfg.get("n1"),
|
||||
n2=cfg.get("n2"),
|
||||
|
||||
58
test/n_chase/1.py
Normal file
58
test/n_chase/1.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
N-chase test 1: Red, on=5, off=5, delay=100ms
|
||||
Runs forever
|
||||
Run with: mpremote run test/n_chase/1.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting N-Chase Test 1: Red, on=5, off=5, delay=100ms")
|
||||
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=100
|
||||
)
|
||||
|
||||
# Configure test parameters
|
||||
p.n1 = 5 # On width 5
|
||||
p.n2 = 5 # Off width 5
|
||||
p.colors = [(255, 0, 0)] # Red
|
||||
|
||||
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"On width: {p.n1}")
|
||||
print(f"Off width: {p.n2}")
|
||||
print(f"Color: {p.colors[0]}")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("nc")
|
||||
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")
|
||||
|
||||
58
test/n_chase/2.py
Normal file
58
test/n_chase/2.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
N-chase test 2: Green, on=10, off=5, delay=150ms
|
||||
Runs forever
|
||||
Run with: mpremote run test/n_chase/2.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting N-Chase Test 2: Green, on=10, off=5, delay=150ms")
|
||||
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=150
|
||||
)
|
||||
|
||||
# Configure test parameters
|
||||
p.n1 = 10 # On width 10
|
||||
p.n2 = 5 # Off width 5
|
||||
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"Delay: {p.delay}ms")
|
||||
print(f"On width: {p.n1}")
|
||||
print(f"Off width: {p.n2}")
|
||||
print(f"Color: {p.colors[0]}")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("nc")
|
||||
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")
|
||||
|
||||
58
test/n_chase/3.py
Normal file
58
test/n_chase/3.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
N-chase test 3: Blue, on=3, off=10, delay=80ms
|
||||
Runs forever
|
||||
Run with: mpremote run test/n_chase/3.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting N-Chase Test 3: Blue, on=3, off=10, delay=80ms")
|
||||
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=80
|
||||
)
|
||||
|
||||
# Configure test parameters
|
||||
p.n1 = 3 # On width 3
|
||||
p.n2 = 10 # Off width 10
|
||||
p.colors = [(0, 0, 255)] # Blue
|
||||
|
||||
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"On width: {p.n1}")
|
||||
print(f"Off width: {p.n2}")
|
||||
print(f"Color: {p.colors[0]}")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("nc")
|
||||
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")
|
||||
|
||||
58
test/n_chase/4.py
Normal file
58
test/n_chase/4.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
N-chase test 4: Yellow, on=7, off=7, delay=120ms
|
||||
Runs forever
|
||||
Run with: mpremote run test/n_chase/4.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting N-Chase Test 4: Yellow, on=7, off=7, delay=120ms")
|
||||
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=120
|
||||
)
|
||||
|
||||
# Configure test parameters
|
||||
p.n1 = 7 # On width 7
|
||||
p.n2 = 7 # Off width 7
|
||||
p.colors = [(255, 255, 0)] # Yellow
|
||||
|
||||
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"On width: {p.n1}")
|
||||
print(f"Off width: {p.n2}")
|
||||
print(f"Color: {p.colors[0]}")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("nc")
|
||||
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")
|
||||
|
||||
58
test/n_chase/5.py
Normal file
58
test/n_chase/5.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
N-chase test 5: White, on=2, off=8, delay=200ms
|
||||
Runs forever
|
||||
Run with: mpremote run test/n_chase/5.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting N-Chase Test 5: White, on=2, off=8, delay=200ms")
|
||||
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=200
|
||||
)
|
||||
|
||||
# Configure test parameters
|
||||
p.n1 = 2 # On width 2
|
||||
p.n2 = 8 # Off width 8
|
||||
p.colors = [(255, 255, 255)] # White
|
||||
|
||||
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"On width: {p.n1}")
|
||||
print(f"Off width: {p.n2}")
|
||||
print(f"Color: {p.colors[0]}")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("nc")
|
||||
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")
|
||||
|
||||
58
test/n_chase/6.py
Normal file
58
test/n_chase/6.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
N-chase test 6: Magenta, on=15, off=3, delay=60ms
|
||||
Runs forever
|
||||
Run with: mpremote run test/n_chase/6.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting N-Chase Test 6: Magenta, on=15, off=3, delay=60ms")
|
||||
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=60
|
||||
)
|
||||
|
||||
# Configure test parameters
|
||||
p.n1 = 15 # On width 15
|
||||
p.n2 = 3 # Off width 3
|
||||
p.colors = [(255, 0, 255)] # Magenta
|
||||
|
||||
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"On width: {p.n1}")
|
||||
print(f"Off width: {p.n2}")
|
||||
print(f"Color: {p.colors[0]}")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("nc")
|
||||
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")
|
||||
|
||||
58
test/n_chase/7.py
Normal file
58
test/n_chase/7.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
N-chase test 7: Cyan, on=4, off=12, delay=180ms
|
||||
Runs forever
|
||||
Run with: mpremote run test/n_chase/7.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting N-Chase Test 7: Cyan, on=4, off=12, delay=180ms")
|
||||
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=180
|
||||
)
|
||||
|
||||
# Configure test parameters
|
||||
p.n1 = 4 # On width 4
|
||||
p.n2 = 12 # Off width 12
|
||||
p.colors = [(0, 255, 255)] # Cyan
|
||||
|
||||
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"On width: {p.n1}")
|
||||
print(f"Off width: {p.n2}")
|
||||
print(f"Color: {p.colors[0]}")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("nc")
|
||||
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")
|
||||
|
||||
58
test/n_chase/8.py
Normal file
58
test/n_chase/8.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
N-chase test 8: Orange, on=1, off=20, delay=250ms
|
||||
Runs forever
|
||||
Run with: mpremote run test/n_chase/8.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
print("Starting N-Chase Test 8: Orange, on=1, off=20, delay=250ms")
|
||||
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=250
|
||||
)
|
||||
|
||||
# Configure test parameters
|
||||
p.n1 = 1 # On width 1
|
||||
p.n2 = 20 # Off width 20
|
||||
p.colors = [(255, 128, 0)] # Orange
|
||||
|
||||
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"On width: {p.n1}")
|
||||
print(f"Off width: {p.n2}")
|
||||
print(f"Color: {p.colors[0]}")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("nc")
|
||||
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")
|
||||
|
||||
117
test/rainbow.py
Normal file
117
test/rainbow.py
Normal file
@@ -0,0 +1,117 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script for rainbow pattern
|
||||
Run with: mpremote run test/rainbow.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
def run_test_case(p, test_name, duration_ms=5000):
|
||||
"""Run a test case for specified duration"""
|
||||
print(f"\n--- {test_name} ---")
|
||||
print(f"Parameters: n1={p.n1} nodes, delay={p.delay}ms cycle time, brightness={p.brightness}")
|
||||
print(f"Running for {duration_ms//1000} seconds...")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("rb")
|
||||
|
||||
# Run for specified duration
|
||||
start_time = utime.ticks_ms()
|
||||
while utime.ticks_diff(utime.ticks_ms(), start_time) < duration_ms:
|
||||
wdt.feed()
|
||||
utime.sleep_ms(100)
|
||||
|
||||
# Stop pattern
|
||||
p.run = False
|
||||
print(f"{test_name} completed")
|
||||
|
||||
# Brief pause between tests
|
||||
utime.sleep_ms(500)
|
||||
|
||||
def test_rainbow():
|
||||
print("Testing rainbow pattern with multiple configurations...")
|
||||
|
||||
# Load settings
|
||||
settings = Settings()
|
||||
|
||||
# Initialize patterns using settings
|
||||
p = patterns.Patterns(
|
||||
pin=settings["led_pin"],
|
||||
num_leds=settings["num_leds"],
|
||||
brightness=255, # Full brightness
|
||||
delay=1000 # Base cycle time
|
||||
)
|
||||
|
||||
print(f"LED Pin: {settings['led_pin']}")
|
||||
print(f"LEDs: {settings['num_leds']}")
|
||||
print(f"Base Brightness: {p.brightness}")
|
||||
|
||||
# Test Case 1: Single node rainbow (full spectrum)
|
||||
p.n1 = 1 # 1 node (full spectrum)
|
||||
p.delay = 3000 # 3 second cycle
|
||||
p.brightness = 255 # Full brightness
|
||||
run_test_case(p, "Test 1: Single node (full spectrum)", 12000)
|
||||
|
||||
# Test Case 2: Two node rainbow (red/green)
|
||||
p.n1 = 2 # 2 nodes
|
||||
p.delay = 2000 # 2 second cycle
|
||||
p.brightness = 255 # Full brightness
|
||||
run_test_case(p, "Test 2: Two nodes (red/green)", 10000)
|
||||
|
||||
# Test Case 3: Three node rainbow (RGB)
|
||||
p.n1 = 3 # 3 nodes
|
||||
p.delay = 1500 # 1.5 second cycle
|
||||
p.brightness = 255 # Full brightness
|
||||
run_test_case(p, "Test 3: Three nodes (RGB)", 9000)
|
||||
|
||||
# Test Case 4: Four node rainbow (RYGB)
|
||||
p.n1 = 4 # 4 nodes
|
||||
p.delay = 1000 # 1 second cycle
|
||||
p.brightness = 255 # Full brightness
|
||||
run_test_case(p, "Test 4: Four nodes (RYGB)", 8000)
|
||||
|
||||
# Test Case 5: Six node rainbow (ROYGBP)
|
||||
p.n1 = 6 # 6 nodes
|
||||
p.delay = 800 # 0.8 second cycle
|
||||
p.brightness = 255 # Full brightness
|
||||
run_test_case(p, "Test 5: Six nodes (ROYGBP)", 8000)
|
||||
|
||||
# Test Case 6: Eight node rainbow
|
||||
p.n1 = 8 # 8 nodes
|
||||
p.delay = 600 # 0.6 second cycle
|
||||
p.brightness = 255 # Full brightness
|
||||
run_test_case(p, "Test 6: Eight nodes", 6000)
|
||||
|
||||
# Test Case 7: Twelve node rainbow (fine gradation)
|
||||
p.n1 = 12 # 12 nodes
|
||||
p.delay = 400 # 0.4 second cycle
|
||||
p.brightness = 255 # Full brightness
|
||||
run_test_case(p, "Test 7: Twelve nodes (fine gradation)", 6000)
|
||||
|
||||
# Test Case 8: Many nodes, slow cycle
|
||||
p.n1 = 20 # 20 nodes
|
||||
p.delay = 2000 # 2 second cycle
|
||||
p.brightness = 255 # Full brightness
|
||||
run_test_case(p, "Test 8: Many nodes, slow cycle", 10000)
|
||||
|
||||
# Test Case 9: One second cycle
|
||||
p.n1 = 5 # 5 nodes
|
||||
p.delay = 1000 # 1 second cycle
|
||||
p.brightness = 255 # Full brightness
|
||||
run_test_case(p, "Test 9: One second cycle (5 nodes)", 6000)
|
||||
|
||||
print("\n=== All tests completed ===")
|
||||
|
||||
# Turn off LEDs
|
||||
p.off()
|
||||
print("LEDs turned off")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_rainbow()
|
||||
120
test/sine_brightness.py
Normal file
120
test/sine_brightness.py
Normal file
@@ -0,0 +1,120 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script for sine brightness pattern
|
||||
Run with: mpremote run test/sine_brightness.py
|
||||
"""
|
||||
|
||||
import patterns
|
||||
import utime
|
||||
from settings import Settings
|
||||
from machine import WDT
|
||||
|
||||
def run_test_case(p, test_name, duration_ms=5000):
|
||||
"""Run a test case for specified duration"""
|
||||
print(f"\n--- {test_name} ---")
|
||||
print(f"Parameters: n1={p.n1} min brightness, brightness={p.brightness} max brightness, delay={p.delay}ms wavelength")
|
||||
print(f"Color: {p.colors[0]}")
|
||||
print(f"Running for {duration_ms//1000} seconds...")
|
||||
|
||||
# Initialize watchdog timer
|
||||
wdt = WDT(timeout=10000)
|
||||
wdt.feed()
|
||||
|
||||
# Start pattern
|
||||
p.select("sb")
|
||||
|
||||
# Run for specified duration
|
||||
start_time = utime.ticks_ms()
|
||||
while utime.ticks_diff(utime.ticks_ms(), start_time) < duration_ms:
|
||||
wdt.feed()
|
||||
utime.sleep_ms(100)
|
||||
|
||||
# Stop pattern
|
||||
p.run = False
|
||||
print(f"{test_name} completed")
|
||||
|
||||
# Brief pause between tests
|
||||
utime.sleep_ms(500)
|
||||
|
||||
def test_sine_brightness():
|
||||
print("Testing sine brightness pattern with multiple configurations...")
|
||||
|
||||
# Load settings
|
||||
settings = Settings()
|
||||
|
||||
# Initialize patterns using settings
|
||||
p = patterns.Patterns(
|
||||
pin=settings["led_pin"],
|
||||
num_leds=settings["num_leds"],
|
||||
brightness=255, # Full brightness
|
||||
delay=1000 # Base wavelength
|
||||
)
|
||||
|
||||
print(f"LED Pin: {settings['led_pin']}")
|
||||
print(f"LEDs: {settings['num_leds']}")
|
||||
print(f"Base Brightness: {p.brightness}")
|
||||
|
||||
# Test Case 1: Slow breathing
|
||||
p.n1 = 50 # Min brightness 50
|
||||
p.brightness = 255 # Max brightness 255
|
||||
p.delay = 3000 # 3 second cycle
|
||||
p.colors = [(255, 0, 0)] # Red
|
||||
run_test_case(p, "Test 1: Slow breathing (50-255 brightness)", 12000)
|
||||
|
||||
# Test Case 2: Fast pulsing
|
||||
p.n1 = 100 # Min brightness 100
|
||||
p.brightness = 255 # Max brightness 255
|
||||
p.delay = 500 # 0.5 second cycle
|
||||
p.colors = [(0, 255, 0)] # Green
|
||||
run_test_case(p, "Test 2: Fast pulsing (100-255 brightness)", 8000)
|
||||
|
||||
# Test Case 3: Medium breathing
|
||||
p.n1 = 80 # Min brightness 80
|
||||
p.brightness = 255 # Max brightness 255
|
||||
p.delay = 1500 # 1.5 second cycle
|
||||
p.colors = [(0, 0, 255)] # Blue
|
||||
run_test_case(p, "Test 3: Medium breathing (80-255 brightness)", 10000)
|
||||
|
||||
# Test Case 4: Very slow breathing
|
||||
p.n1 = 150 # Min brightness 150
|
||||
p.brightness = 255 # Max brightness 255
|
||||
p.delay = 5000 # 5 second cycle
|
||||
p.colors = [(255, 255, 0)] # Yellow
|
||||
run_test_case(p, "Test 4: Very slow breathing (150-255 brightness)", 15000)
|
||||
|
||||
# Test Case 5: Very fast pulsing
|
||||
p.n1 = 50 # Min brightness 50
|
||||
p.brightness = 255 # Max brightness 255
|
||||
p.delay = 200 # 0.2 second cycle
|
||||
p.colors = [(255, 0, 255)] # Magenta
|
||||
run_test_case(p, "Test 5: Very fast pulsing (50-255 brightness)", 6000)
|
||||
|
||||
# Test Case 6: Low range, slow cycle
|
||||
p.n1 = 200 # Min brightness 200
|
||||
p.brightness = 255 # Max brightness 255
|
||||
p.delay = 4000 # 4 second cycle
|
||||
p.colors = [(0, 255, 255)] # Cyan
|
||||
run_test_case(p, "Test 6: Low range, slow cycle (200-255 brightness)", 12000)
|
||||
|
||||
# Test Case 7: High range, medium cycle
|
||||
p.n1 = 100 # Min brightness 100
|
||||
p.brightness = 255 # Max brightness 255
|
||||
p.delay = 1000 # 1 second cycle
|
||||
p.colors = [(255, 128, 0)] # Orange
|
||||
run_test_case(p, "Test 7: High range, medium cycle (100-255 brightness)", 8000)
|
||||
|
||||
# Test Case 8: Ultra fast strobe
|
||||
p.n1 = 100 # Min brightness 100
|
||||
p.brightness = 255 # Max brightness 255
|
||||
p.delay = 100 # 0.1 second cycle
|
||||
p.colors = [(128, 0, 255)] # Purple
|
||||
run_test_case(p, "Test 8: Ultra fast strobe (100-255 brightness)", 4000)
|
||||
|
||||
print("\n=== All tests completed ===")
|
||||
|
||||
# Turn off LEDs
|
||||
p.off()
|
||||
print("LEDs turned off")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_sine_brightness()
|
||||
Reference in New Issue
Block a user