Add brightness overlay and enlarge LED preview on target cards
Show effective brightness percentage on the LED preview when a value source dims below 100%. Prepend a brightness byte to the preview WebSocket wire format. Increase preview height to 32px. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -433,12 +433,16 @@ class WledTargetProcessor(TargetProcessor):
|
||||
if ws in self._preview_clients:
|
||||
self._preview_clients.remove(ws)
|
||||
|
||||
async def _broadcast_led_preview(self, colors: np.ndarray) -> None:
|
||||
"""Broadcast LED colors as binary RGB bytes to preview WebSocket clients."""
|
||||
async def _broadcast_led_preview(self, colors: np.ndarray, brightness: int = 255) -> None:
|
||||
"""Broadcast LED colors as binary RGB bytes to preview WebSocket clients.
|
||||
|
||||
Wire format: [brightness_byte] [R G B R G B ...]
|
||||
First byte is the effective brightness (0-255), rest is RGB pixel data.
|
||||
"""
|
||||
if not self._preview_clients:
|
||||
return
|
||||
|
||||
data = colors.astype(np.uint8).tobytes()
|
||||
data = bytes([brightness]) + colors.astype(np.uint8).tobytes()
|
||||
|
||||
async def _send_safe(ws):
|
||||
try:
|
||||
@@ -605,7 +609,7 @@ class WledTargetProcessor(TargetProcessor):
|
||||
send_timestamps.append(now)
|
||||
self._metrics.frames_keepalive += 1
|
||||
if self._preview_clients and (now - _last_preview_broadcast) >= 0.066:
|
||||
await self._broadcast_led_preview(send_colors)
|
||||
await self._broadcast_led_preview(send_colors, cur_brightness)
|
||||
_last_preview_broadcast = now
|
||||
self._metrics.frames_skipped += 1
|
||||
while send_timestamps and send_timestamps[0] < now - 1.0:
|
||||
@@ -640,7 +644,7 @@ class WledTargetProcessor(TargetProcessor):
|
||||
|
||||
# Broadcast to LED preview WebSocket clients (throttled to ~15 fps)
|
||||
if self._preview_clients and (now - _last_preview_broadcast) >= 0.066:
|
||||
await self._broadcast_led_preview(send_colors)
|
||||
await self._broadcast_led_preview(send_colors, cur_brightness)
|
||||
_last_preview_broadcast = now
|
||||
|
||||
self._metrics.timing_send_ms = send_ms
|
||||
|
||||
Reference in New Issue
Block a user