Refactor patterns to use preset-based API and fix initialization order
- Fix initialization order: initialize self.presets before calling self.select() - Separate add() and edit() methods: add() creates new presets, edit() updates existing ones - Update all test files to use add() instead of edit() for creating presets - Add comprehensive auto/manual mode test - Remove tool.py (moved to led-tool project)
This commit is contained in:
@@ -24,41 +24,54 @@ def main():
|
||||
|
||||
# Test 1: Simple two-color transition
|
||||
print("Test 1: Two-color transition (red <-> blue, delay=1000)")
|
||||
p.set_param("br", 255)
|
||||
p.set_param("dl", 1000) # transition duration
|
||||
p.set_param("cl", [(255, 0, 0), (0, 0, 255)])
|
||||
p.set_param("auto", True)
|
||||
p.select("transition")
|
||||
p.add("transition1", {
|
||||
"pattern": "transition",
|
||||
"brightness": 255,
|
||||
"delay": 1000, # transition duration
|
||||
"colors": [(255, 0, 0), (0, 0, 255)],
|
||||
"auto": True
|
||||
})
|
||||
p.select("transition1")
|
||||
run_for(p, wdt, 6000)
|
||||
|
||||
# Test 2: Multi-color transition
|
||||
print("Test 2: Multi-color transition (red -> green -> blue -> white)")
|
||||
p.set_param("dl", 800)
|
||||
p.set_param("cl", [(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 255)])
|
||||
p.set_param("auto", True)
|
||||
p.select("transition")
|
||||
p.add("transition2", {
|
||||
"pattern": "transition",
|
||||
"delay": 800,
|
||||
"colors": [(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 255)],
|
||||
"auto": True
|
||||
})
|
||||
p.select("transition2")
|
||||
run_for(p, wdt, 8000)
|
||||
|
||||
# Test 3: One-shot transition (auto=False)
|
||||
print("Test 3: One-shot transition (auto=False)")
|
||||
p.set_param("dl", 1000)
|
||||
p.set_param("cl", [(255, 0, 0), (0, 255, 0)])
|
||||
p.set_param("auto", False)
|
||||
p.select("transition")
|
||||
p.add("transition3", {
|
||||
"pattern": "transition",
|
||||
"delay": 1000,
|
||||
"colors": [(255, 0, 0), (0, 255, 0)],
|
||||
"auto": False
|
||||
})
|
||||
p.select("transition3")
|
||||
# Run long enough for a single transition step
|
||||
run_for(p, wdt, 2000)
|
||||
|
||||
# Test 4: Single-color behavior (should just stay on)
|
||||
print("Test 4: Single-color transition (should hold color)")
|
||||
p.set_param("cl", [(0, 0, 255)])
|
||||
p.set_param("dl", 500)
|
||||
p.set_param("auto", True)
|
||||
p.select("transition")
|
||||
p.add("transition4", {
|
||||
"pattern": "transition",
|
||||
"colors": [(0, 0, 255)],
|
||||
"delay": 500,
|
||||
"auto": True
|
||||
})
|
||||
p.select("transition4")
|
||||
run_for(p, wdt, 3000)
|
||||
|
||||
# Cleanup
|
||||
print("Test complete, turning off")
|
||||
p.select("off")
|
||||
p.add("cleanup_off", {"pattern": "off"})
|
||||
p.select("cleanup_off")
|
||||
run_for(p, wdt, 200)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user