Add value sources for dynamic brightness control on LED targets
Introduces a new Value Source entity that produces a scalar float (0.0-1.0) for dynamic brightness modulation. Three subtypes: Static (constant), Animated (sine/triangle/square/sawtooth waveform), and Audio-reactive (RMS/peak/beat from mono audio source). Value sources can be optionally attached to LED targets to control brightness each frame. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@ class WledPictureTarget(PictureTarget):
|
||||
|
||||
device_id: str = ""
|
||||
color_strip_source_id: str = ""
|
||||
brightness_value_source_id: str = ""
|
||||
fps: int = 30 # target send FPS (1-90)
|
||||
keepalive_interval: float = 1.0 # seconds between keepalive sends when screen is static
|
||||
state_check_interval: int = DEFAULT_STATE_CHECK_INTERVAL
|
||||
@@ -29,11 +30,13 @@ class WledPictureTarget(PictureTarget):
|
||||
fps=self.fps,
|
||||
keepalive_interval=self.keepalive_interval,
|
||||
state_check_interval=self.state_check_interval,
|
||||
brightness_value_source_id=self.brightness_value_source_id,
|
||||
)
|
||||
|
||||
def sync_with_manager(self, manager, *, settings_changed: bool,
|
||||
css_changed: bool = False,
|
||||
device_changed: bool = False) -> None:
|
||||
device_changed: bool = False,
|
||||
brightness_vs_changed: bool = False) -> None:
|
||||
"""Push changed fields to the processor manager."""
|
||||
if settings_changed:
|
||||
manager.update_target_settings(self.id, {
|
||||
@@ -45,8 +48,11 @@ class WledPictureTarget(PictureTarget):
|
||||
manager.update_target_css(self.id, self.color_strip_source_id)
|
||||
if device_changed:
|
||||
manager.update_target_device(self.id, self.device_id)
|
||||
if brightness_vs_changed:
|
||||
manager.update_target_brightness_vs(self.id, self.brightness_value_source_id)
|
||||
|
||||
def update_fields(self, *, name=None, device_id=None, color_strip_source_id=None,
|
||||
brightness_value_source_id=None,
|
||||
fps=None, keepalive_interval=None, state_check_interval=None,
|
||||
description=None, **_kwargs) -> None:
|
||||
"""Apply mutable field updates for WLED targets."""
|
||||
@@ -55,6 +61,8 @@ class WledPictureTarget(PictureTarget):
|
||||
self.device_id = device_id
|
||||
if color_strip_source_id is not None:
|
||||
self.color_strip_source_id = color_strip_source_id
|
||||
if brightness_value_source_id is not None:
|
||||
self.brightness_value_source_id = brightness_value_source_id
|
||||
if fps is not None:
|
||||
self.fps = fps
|
||||
if keepalive_interval is not None:
|
||||
@@ -71,6 +79,7 @@ class WledPictureTarget(PictureTarget):
|
||||
d = super().to_dict()
|
||||
d["device_id"] = self.device_id
|
||||
d["color_strip_source_id"] = self.color_strip_source_id
|
||||
d["brightness_value_source_id"] = self.brightness_value_source_id
|
||||
d["fps"] = self.fps
|
||||
d["keepalive_interval"] = self.keepalive_interval
|
||||
d["state_check_interval"] = self.state_check_interval
|
||||
@@ -95,6 +104,7 @@ class WledPictureTarget(PictureTarget):
|
||||
target_type="led",
|
||||
device_id=data.get("device_id", ""),
|
||||
color_strip_source_id=css_id,
|
||||
brightness_value_source_id=data.get("brightness_value_source_id", ""),
|
||||
fps=data.get("fps", 30),
|
||||
keepalive_interval=data.get("keepalive_interval", data.get("standby_interval", 1.0)),
|
||||
state_check_interval=data.get("state_check_interval", DEFAULT_STATE_CHECK_INTERVAL),
|
||||
|
||||
Reference in New Issue
Block a user