Add overlay toggle to calibration dialog, fix serial reconnect on edge test
Add a 💡 button in the calibration modal header (CSS mode only) that toggles the LED overlay visualization. Auto-stops overlay on modal close if started from the dialog. Checks and reflects current overlay status on modal open. Fix serial devices creating a new connection on every edge test toggle, which triggered Arduino bootloader resets. Now reuses the cached idle client for all device types. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -641,32 +641,15 @@ class ProcessorManager:
|
||||
pixels = [(0, 0, 0)] * ds.led_count
|
||||
await self._send_pixels_to_device(device_id, pixels)
|
||||
|
||||
def _is_serial_device(self, device_id: str) -> bool:
|
||||
"""Check if a device uses a serial (COM) connection."""
|
||||
ds = self._devices.get(device_id)
|
||||
return ds is not None and ds.device_type not in ("wled",)
|
||||
|
||||
async def _send_pixels_to_device(self, device_id: str, pixels) -> None:
|
||||
"""Send pixels to a device.
|
||||
"""Send pixels to a device via cached idle client.
|
||||
|
||||
Serial devices: temporary connection (open, send, close).
|
||||
WLED devices: cached idle client.
|
||||
Reuses a cached connection to avoid repeated serial reconnections
|
||||
(which trigger Arduino bootloader reset on Adalight devices).
|
||||
"""
|
||||
ds = self._devices[device_id]
|
||||
try:
|
||||
if self._is_serial_device(device_id):
|
||||
client = create_led_client(
|
||||
ds.device_type, ds.device_url,
|
||||
led_count=ds.led_count, baud_rate=ds.baud_rate,
|
||||
)
|
||||
try:
|
||||
await client.connect()
|
||||
await client.send_pixels(pixels)
|
||||
finally:
|
||||
await client.close()
|
||||
else:
|
||||
client = await self._get_idle_client(device_id)
|
||||
await client.send_pixels(pixels)
|
||||
client = await self._get_idle_client(device_id)
|
||||
await client.send_pixels(pixels)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to send pixels to {device_id}: {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user