Add Pico presets engine, patterns, and tests.
Wire the Pico to UART-driven preset selection, add pattern modules and presets data, remove old p2p/settings code, and update tests and LED driver. Made-with: Cursor
This commit is contained in:
28
pico/src/patterns/test.py
Normal file
28
pico/src/patterns/test.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""Test pattern: strip i has (i+1) LEDs on at the start (indices 0..i) plus the midpoint LED on. 50% red."""
|
||||
|
||||
BRIGHTNESS = 0.50
|
||||
|
||||
RED = (255, 0, 0)
|
||||
|
||||
|
||||
def _scale(color, factor):
|
||||
return tuple(int(c * factor) for c in color)
|
||||
|
||||
|
||||
class Test:
|
||||
def __init__(self, driver):
|
||||
self.driver = driver
|
||||
|
||||
def run(self, preset):
|
||||
strips = self.driver.strips
|
||||
red = _scale(RED, BRIGHTNESS)
|
||||
for strip_idx, strip in enumerate(strips):
|
||||
n = strip.num_leds
|
||||
mid = self.driver.strip_midpoints[strip_idx] # from STRIP_CONFIG
|
||||
strip.fill((0, 0, 0))
|
||||
# First (strip_idx + 1) LEDs on: indices 0..strip_idx
|
||||
for i in range(min(strip_idx + 1, n)):
|
||||
strip.set(i, red)
|
||||
# Midpoint LED on
|
||||
strip.set(mid, red)
|
||||
strip.show()
|
||||
Reference in New Issue
Block a user