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:
2026-02-07 11:40:04 +13:00
parent f35d8f7084
commit 43957adb28
14 changed files with 253 additions and 225 deletions

View File

@@ -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,17 +19,17 @@ 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 two-color transition
print("Test 1: Two-color transition (red <-> blue, delay=1000)")
p.edit("transition1", {
"pattern": "transition",
"brightness": 255,
"delay": 1000, # transition duration
"colors": [(255, 0, 0), (0, 0, 255)],
"auto": True
"p": "transition",
"b": 255,
"d": 1000, # transition duration
"c": [(255, 0, 0), (0, 0, 255)],
"a": True,
})
p.select("transition1")
run_for(p, wdt, 6000)
@@ -37,10 +37,10 @@ def main():
# Test 2: Multi-color transition
print("Test 2: Multi-color transition (red -> green -> blue -> white)")
p.edit("transition2", {
"pattern": "transition",
"delay": 800,
"colors": [(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 255)],
"auto": True
"p": "transition",
"d": 800,
"c": [(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 255)],
"a": True,
})
p.select("transition2")
run_for(p, wdt, 8000)
@@ -48,10 +48,10 @@ def main():
# Test 3: One-shot transition (auto=False)
print("Test 3: One-shot transition (auto=False)")
p.edit("transition3", {
"pattern": "transition",
"delay": 1000,
"colors": [(255, 0, 0), (0, 255, 0)],
"auto": False
"p": "transition",
"d": 1000,
"c": [(255, 0, 0), (0, 255, 0)],
"a": False,
})
p.select("transition3")
# Run long enough for a single transition step
@@ -60,17 +60,17 @@ def main():
# Test 4: Single-color behavior (should just stay on)
print("Test 4: Single-color transition (should hold color)")
p.edit("transition4", {
"pattern": "transition",
"colors": [(0, 0, 255)],
"delay": 500,
"auto": True
"p": "transition",
"c": [(0, 0, 255)],
"d": 500,
"a": True,
})
p.select("transition4")
run_for(p, wdt, 3000)
# 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)