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 <noreply@anthropic.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user