Remove led_count from static, gradient, color_cycle, and effect CSS sources
These types always auto-size from the connected device — the explicit led_count override was unused clutter. Streams now use getattr fallback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -573,8 +573,9 @@ class StaticColorStripStream(ColorStripStream):
|
||||
def _update_from_source(self, source) -> None:
|
||||
color = source.color if isinstance(source.color, list) and len(source.color) == 3 else [255, 255, 255]
|
||||
self._source_color = color # stored separately so configure() can rebuild
|
||||
self._auto_size = not source.led_count # True when led_count == 0
|
||||
led_count = source.led_count if source.led_count and source.led_count > 0 else 1
|
||||
_lc = getattr(source, "led_count", 0)
|
||||
self._auto_size = not _lc
|
||||
led_count = _lc if _lc and _lc > 0 else 1
|
||||
self._led_count = led_count
|
||||
self._animation = source.animation # dict or None; read atomically by _animate_loop
|
||||
self._rebuild_colors()
|
||||
@@ -798,8 +799,9 @@ class ColorCycleColorStripStream(ColorStripStream):
|
||||
self._color_list = [
|
||||
c for c in raw if isinstance(c, list) and len(c) == 3
|
||||
] or default
|
||||
self._auto_size = not source.led_count
|
||||
self._led_count = source.led_count if source.led_count > 0 else 1
|
||||
_lc = getattr(source, "led_count", 0)
|
||||
self._auto_size = not _lc
|
||||
self._led_count = _lc if _lc > 0 else 1
|
||||
self._rebuild_colors()
|
||||
|
||||
def _rebuild_colors(self) -> None:
|
||||
@@ -950,8 +952,9 @@ class GradientColorStripStream(ColorStripStream):
|
||||
|
||||
def _update_from_source(self, source) -> None:
|
||||
self._stops = list(source.stops) if source.stops else []
|
||||
self._auto_size = not source.led_count
|
||||
led_count = source.led_count if source.led_count and source.led_count > 0 else 1
|
||||
_lc = getattr(source, "led_count", 0)
|
||||
self._auto_size = not _lc
|
||||
led_count = _lc if _lc and _lc > 0 else 1
|
||||
self._led_count = led_count
|
||||
self._animation = source.animation # dict or None; read atomically by _animate_loop
|
||||
self._rebuild_colors()
|
||||
|
||||
@@ -203,8 +203,9 @@ class EffectColorStripStream(ColorStripStream):
|
||||
|
||||
def _update_from_source(self, source) -> None:
|
||||
self._effect_type = getattr(source, "effect_type", "fire")
|
||||
self._auto_size = not source.led_count
|
||||
self._led_count = source.led_count if source.led_count and source.led_count > 0 else 1
|
||||
_lc = getattr(source, "led_count", 0)
|
||||
self._auto_size = not _lc
|
||||
self._led_count = _lc if _lc and _lc > 0 else 1
|
||||
self._palette_name = getattr(source, "palette", None) or _EFFECT_DEFAULT_PALETTE.get(self._effect_type, "fire")
|
||||
self._palette_lut = _build_palette_lut(self._palette_name)
|
||||
color = getattr(source, "color", None)
|
||||
|
||||
Reference in New Issue
Block a user