Import led-driver app: pico/ and esp32/ layout
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
47
pico/test/patterns/on.py
Normal file
47
pico/test/patterns/on.py
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env python3
|
||||
import utime
|
||||
from machine import WDT
|
||||
from settings import Settings
|
||||
from presets import Presets
|
||||
|
||||
|
||||
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)
|
||||
|
||||
# Create presets for on and off using the short-key fields that Presets expects
|
||||
# Preset fields:
|
||||
# p = pattern name, b = brightness, d = delay, c = list of (r,g,b) colors
|
||||
p.edit("test_on", {
|
||||
"p": "on",
|
||||
"b": 64,
|
||||
"d": 120,
|
||||
"c": [(255, 0, 0), (0, 0, 255)],
|
||||
})
|
||||
p.edit("test_off", {"p": "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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user