Import led-driver app: pico/ and esp32/ layout

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-02-19 18:14:17 +13:00
parent 86b28a1b9c
commit 0c73d56ab5
31 changed files with 2907 additions and 54 deletions

View File

@@ -0,0 +1,113 @@
#!/usr/bin/env python3
import utime
from machine import WDT
from settings import Settings
from presets import Presets
def run_for(p, wdt, ms):
"""Helper: run current pattern for given ms using tick()."""
start = utime.ticks_ms()
while utime.ticks_diff(utime.ticks_ms(), start) < ms:
wdt.feed()
p.tick()
utime.sleep_ms(10)
def main():
s = Settings()
pin = s.get("led_pin", 10)
num = s.get("num_leds", 30)
p = Presets(pin=pin, num_leds=num)
wdt = WDT(timeout=10000)
# Test 1: Basic circle (n1=50, n2=100, n3=200, n4=0)
print("Test 1: Basic circle (n1=50, n2=100, n3=200, n4=0)")
p.edit("circle1", {
"p": "circle",
"b": 255,
"n1": 50, # Head moves 50 LEDs/second
"n2": 100, # Max length 100 LEDs
"n3": 200, # Tail moves 200 LEDs/second
"n4": 0, # Min length 0 LEDs
"c": [(255, 0, 0)], # Red
})
p.select("circle1")
run_for(p, wdt, 5000)
# Test 2: Slow growth, fast shrink (n1=20, n2=50, n3=100, n4=0)
print("Test 2: Slow growth, fast shrink (n1=20, n2=50, n3=100, n4=0)")
p.edit("circle2", {
"p": "circle",
"n1": 20,
"n2": 50,
"n3": 100,
"n4": 0,
"c": [(0, 255, 0)], # Green
})
p.select("circle2")
run_for(p, wdt, 5000)
# Test 3: Fast growth, slow shrink (n1=100, n2=30, n3=20, n4=0)
print("Test 3: Fast growth, slow shrink (n1=100, n2=30, n3=20, n4=0)")
p.edit("circle3", {
"p": "circle",
"n1": 100,
"n2": 30,
"n3": 20,
"n4": 0,
"c": [(0, 0, 255)], # Blue
})
p.select("circle3")
run_for(p, wdt, 5000)
# Test 4: With minimum length (n1=50, n2=40, n3=100, n4=10)
print("Test 4: With minimum length (n1=50, n2=40, n3=100, n4=10)")
p.edit("circle4", {
"p": "circle",
"n1": 50,
"n2": 40,
"n3": 100,
"n4": 10,
"c": [(255, 255, 0)], # Yellow
})
p.select("circle4")
run_for(p, wdt, 5000)
# Test 5: Very fast (n1=200, n2=20, n3=200, n4=0)
print("Test 5: Very fast (n1=200, n2=20, n3=200, n4=0)")
p.edit("circle5", {
"p": "circle",
"n1": 200,
"n2": 20,
"n3": 200,
"n4": 0,
"c": [(255, 0, 255)], # Magenta
})
p.select("circle5")
run_for(p, wdt, 3000)
# Test 6: Very slow (n1=10, n2=25, n3=10, n4=0)
print("Test 6: Very slow (n1=10, n2=25, n3=10, n4=0)")
p.edit("circle6", {
"p": "circle",
"n1": 10,
"n2": 25,
"n3": 10,
"n4": 0,
"c": [(0, 255, 255)], # Cyan
})
p.select("circle6")
run_for(p, wdt, 5000)
# Cleanup
print("Test complete, turning off")
p.edit("cleanup_off", {"p": "off"})
p.select("cleanup_off")
run_for(p, wdt, 100)
if __name__ == "__main__":
main()