From 0cd8304004ffee6d43f6472e376a38e665e3ab03 Mon Sep 17 00:00:00 2001 From: "alexei.dolgolyov" Date: Tue, 24 Feb 2026 20:45:44 +0300 Subject: [PATCH] Resend frames when dynamic brightness changes on static CSS The processing loop skipped resending when the CSS frame was unchanged (static source). With a dynamic brightness value source (e.g. audio), brightness can change every frame while colors stay the same. Now compare effective brightness against previous value and resend when it differs. Co-Authored-By: Claude Opus 4.6 --- .../core/processing/wled_target_processor.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/src/wled_controller/core/processing/wled_target_processor.py b/server/src/wled_controller/core/processing/wled_target_processor.py index 3f2231c..956bd1d 100644 --- a/server/src/wled_controller/core/processing/wled_target_processor.py +++ b/server/src/wled_controller/core/processing/wled_target_processor.py @@ -486,6 +486,7 @@ class WledTargetProcessor(TargetProcessor): stream = self._css_stream prev_frame_ref = None has_any_frame = False + _prev_brightness = -1 # force first send # Pre-allocate brightness scratch (uint16 intermediate + uint8 output) _bright_u16: Optional[np.ndarray] = None @@ -574,14 +575,16 @@ class WledTargetProcessor(TargetProcessor): await asyncio.sleep(frame_time) continue - if frame is prev_frame_ref: - # Same frame — keepalive or skip + cur_brightness = _effective_brightness(device_info) + + if frame is prev_frame_ref and cur_brightness == _prev_brightness: + # Same frame + same brightness — keepalive or skip if self._needs_keepalive and has_any_frame and (loop_start - last_send_time) >= keepalive_interval: if not self._is_running or self._led_client is None: break send_colors = _cached_brightness( self._fit_to_device(prev_frame_ref, _total_leds), - _effective_brightness(device_info), + cur_brightness, ) if self._led_client.supports_fast_send: self._led_client.send_pixels_fast(send_colors) @@ -605,10 +608,11 @@ class WledTargetProcessor(TargetProcessor): prev_frame_ref = frame has_any_frame = True + _prev_brightness = cur_brightness # Fit to device LED count and apply brightness device_colors = self._fit_to_device(frame, _total_leds) - send_colors = _cached_brightness(device_colors, _effective_brightness(device_info)) + send_colors = _cached_brightness(device_colors, cur_brightness) # Send to LED device if not self._is_running or self._led_client is None: