Files
led-driver/test/patterns/on.py
jimmy a75d71d9f4 Update pattern tests for new preset-based API
- Replace add() calls with edit() for preset creation
- Update tests to work with merged patterns.py
- Ensure all tests use new Preset object structure
2026-01-27 00:42:33 +13:00

46 lines
945 B
Python

#!/usr/bin/env python3
import utime
from machine import WDT
from settings import Settings
from patterns import Patterns
def main():
s = Settings()
pin = s.get("led_pin", 10)
num = s.get("num_leds", 30)
p = Patterns(pin=pin, num_leds=num)
wdt = WDT(timeout=10000)
# Create presets for on and off
p.edit("test_on", {
"pattern": "on",
"brightness": 64,
"delay": 120,
"colors": [(255, 0, 0), (0, 0, 255)]
})
p.edit("test_off", {"pattern": "off"})
# ON phase
p.select("test_on")
start = utime.ticks_ms()
while utime.ticks_diff(utime.ticks_ms(), start) < 800:
wdt.feed()
p.tick()
utime.sleep_ms(10)
# OFF phase
p.select("test_off")
start = utime.ticks_ms()
while utime.ticks_diff(utime.ticks_ms(), start) < 100:
wdt.feed()
p.tick()
utime.sleep_ms(10)
if __name__ == "__main__":
main()