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:
38
pico/src/patterns/calibration.py
Normal file
38
pico/src/patterns/calibration.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""Calibration: strips 2 and 6 only. First 10 green, then alternating 10 blue / 10 red. 10% brightness."""
|
||||
|
||||
BRIGHTNESS = 0.10
|
||||
BLOCK = 10
|
||||
STRIPS_ON = (2, 6) # 0-based: 3rd and 7th strip only
|
||||
|
||||
GREEN = (0, 255, 0)
|
||||
RED = (255, 0, 0)
|
||||
BLUE = (0, 0, 255)
|
||||
|
||||
|
||||
def _scale(color, factor):
|
||||
return tuple(int(c * factor) for c in color)
|
||||
|
||||
|
||||
class Calibration:
|
||||
def __init__(self, driver):
|
||||
self.driver = driver
|
||||
|
||||
def run(self, preset):
|
||||
strips = self.driver.strips
|
||||
green = _scale(GREEN, BRIGHTNESS)
|
||||
red = _scale(RED, BRIGHTNESS)
|
||||
blue = _scale(BLUE, BRIGHTNESS)
|
||||
on_set = set(STRIPS_ON)
|
||||
for strip_idx, strip in enumerate(strips):
|
||||
n = strip.num_leds
|
||||
if strip_idx not in on_set:
|
||||
strip.fill((0, 0, 0))
|
||||
strip.show()
|
||||
continue
|
||||
for i in range(n):
|
||||
if i < BLOCK:
|
||||
strip.set(i, green)
|
||||
else:
|
||||
block = (i - BLOCK) // BLOCK
|
||||
strip.set(i, blue if block % 2 == 0 else red)
|
||||
strip.show()
|
||||
Reference in New Issue
Block a user