feat(patterns): merge pattern styles and add mode support
Consolidate legacy pattern ids into meteor, particles, sparkle, chase, and colour_cycle with n6/mode style selection; add pattern_modes helper, self-contained tests/all.py, and preset mode alias on wire. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
794f1a2841
commit
55a97ac51c
44 files changed
+998
-1539
No files matched your search
+37
-8
@@ -70,8 +70,29 @@ class Presets:
|
||||
except Exception as e:
|
||||
print("Pattern init failed:", module_name, e)
|
||||
|
||||
self._apply_pattern_aliases(loaded)
|
||||
return loaded
|
||||
|
||||
def _apply_pattern_aliases(self, loaded):
|
||||
"""Legacy pattern ids -> merged implementations (same generator)."""
|
||||
aliases = (
|
||||
("rainbow", "colour_cycle"),
|
||||
("gradient_scroll", "colour_cycle"),
|
||||
("meteor_rain", "meteor"),
|
||||
("comet_dual", "meteor"),
|
||||
("scanner", "meteor"),
|
||||
("snowfall", "particles"),
|
||||
("starfall", "particles"),
|
||||
("sparkle_trail", "sparkle"),
|
||||
("ice_sparkle", "sparkle"),
|
||||
("fireflies", "sparkle"),
|
||||
("marquee", "chase"),
|
||||
("northern_wave", "aurora"),
|
||||
)
|
||||
for old, new in aliases:
|
||||
if new in loaded and old not in loaded:
|
||||
loaded[old] = loaded[new]
|
||||
|
||||
def save(self):
|
||||
"""Save the presets to a file."""
|
||||
with open("presets.json", "w") as f:
|
||||
@@ -112,16 +133,24 @@ class Presets:
|
||||
"""Create or update a preset with the given name."""
|
||||
if name in self.presets:
|
||||
# Update existing preset
|
||||
was_auto = self.presets[name].a
|
||||
self.presets[name].edit(data)
|
||||
# Editing the live preset (e.g. toggling auto/manual) must reset runtime
|
||||
# state; re-select alone keeps step because preset name is unchanged.
|
||||
# Editing the live preset: auto still re-selects (one tick) so the strip
|
||||
# restarts without a separate select message (controller often sends both).
|
||||
# Manual must NOT call select() here — presets-only pushes (e.g. zone sequence
|
||||
# arming the first step) would otherwise run select's first tick and consume a
|
||||
# beat/step. Manual advances only on explicit select from the controller.
|
||||
if self.selected == name:
|
||||
self.step = 0
|
||||
self.generator = None
|
||||
self.fill((0, 0, 0))
|
||||
# Re-start pattern so manual/auto and other edits apply without a
|
||||
# separate select message (controller usually sends both).
|
||||
self.select(name)
|
||||
preset = self.presets[name]
|
||||
if preset.a:
|
||||
self.step = 0
|
||||
self.generator = None
|
||||
self.fill((0, 0, 0))
|
||||
self.select(name)
|
||||
elif was_auto:
|
||||
self.step = 0
|
||||
self.generator = None
|
||||
self.fill((0, 0, 0))
|
||||
else:
|
||||
if len(self.presets) >= MAX_PRESETS and name not in ("on", "off"):
|
||||
print("Preset limit reached:", MAX_PRESETS)
|
||||
|
||||
Reference in new issue
Block a user