Rename patterns module to presets
Rename the driver module and update imports so tests and main entry use the new presets naming, while moving Preset to its own file. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import utime
|
||||
from machine import WDT
|
||||
from settings import Settings
|
||||
from patterns import Patterns
|
||||
from presets import Presets
|
||||
|
||||
|
||||
def run_for(p, wdt, ms):
|
||||
@@ -19,20 +19,20 @@ def main():
|
||||
pin = s.get("led_pin", 10)
|
||||
num = s.get("num_leds", 30)
|
||||
|
||||
p = Patterns(pin=pin, num_leds=num)
|
||||
p = Presets(pin=pin, num_leds=num)
|
||||
wdt = WDT(timeout=10000)
|
||||
|
||||
# Test 1: Simple single-color pulse
|
||||
print("Test 1: Single-color pulse (attack=500, hold=500, decay=500, delay=500)")
|
||||
p.edit("pulse1", {
|
||||
"pattern": "pulse",
|
||||
"brightness": 255,
|
||||
"colors": [(255, 0, 0)],
|
||||
"p": "pulse",
|
||||
"b": 255,
|
||||
"c": [(255, 0, 0)],
|
||||
"n1": 500, # attack ms
|
||||
"n2": 500, # hold ms
|
||||
"n3": 500, # decay ms
|
||||
"delay": 500, # delay ms between pulses
|
||||
"auto": True
|
||||
"d": 500, # delay ms between pulses
|
||||
"a": True,
|
||||
})
|
||||
p.select("pulse1")
|
||||
run_for(p, wdt, 5000)
|
||||
@@ -40,12 +40,12 @@ def main():
|
||||
# Test 2: Faster pulse
|
||||
print("Test 2: Fast pulse (attack=100, hold=100, decay=100, delay=100)")
|
||||
p.edit("pulse2", {
|
||||
"pattern": "pulse",
|
||||
"p": "pulse",
|
||||
"n1": 100,
|
||||
"n2": 100,
|
||||
"n3": 100,
|
||||
"delay": 100,
|
||||
"colors": [(0, 255, 0)]
|
||||
"d": 100,
|
||||
"c": [(0, 255, 0)],
|
||||
})
|
||||
p.select("pulse2")
|
||||
run_for(p, wdt, 4000)
|
||||
@@ -53,13 +53,13 @@ def main():
|
||||
# Test 3: Multi-color pulse cycle
|
||||
print("Test 3: Multi-color pulse (red -> green -> blue)")
|
||||
p.edit("pulse3", {
|
||||
"pattern": "pulse",
|
||||
"p": "pulse",
|
||||
"n1": 300,
|
||||
"n2": 300,
|
||||
"n3": 300,
|
||||
"delay": 200,
|
||||
"colors": [(255, 0, 0), (0, 255, 0), (0, 0, 255)],
|
||||
"auto": True
|
||||
"d": 200,
|
||||
"c": [(255, 0, 0), (0, 255, 0), (0, 0, 255)],
|
||||
"a": True,
|
||||
})
|
||||
p.select("pulse3")
|
||||
run_for(p, wdt, 6000)
|
||||
@@ -67,13 +67,13 @@ def main():
|
||||
# Test 4: One-shot pulse (auto=False)
|
||||
print("Test 4: Single pulse, auto=False")
|
||||
p.edit("pulse4", {
|
||||
"pattern": "pulse",
|
||||
"p": "pulse",
|
||||
"n1": 400,
|
||||
"n2": 0,
|
||||
"n3": 400,
|
||||
"delay": 0,
|
||||
"colors": [(255, 255, 255)],
|
||||
"auto": False
|
||||
"d": 0,
|
||||
"c": [(255, 255, 255)],
|
||||
"a": False,
|
||||
})
|
||||
p.select("pulse4")
|
||||
# Run long enough to allow one full pulse cycle
|
||||
@@ -81,7 +81,7 @@ def main():
|
||||
|
||||
# Cleanup
|
||||
print("Test complete, turning off")
|
||||
p.edit("cleanup_off", {"pattern": "off"})
|
||||
p.edit("cleanup_off", {"p": "off"})
|
||||
p.select("cleanup_off")
|
||||
run_for(p, wdt, 200)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user