Commit a6a03675 authored by vertighel's avatar vertighel
Browse files

Revert "Fix teccam loop stripe artifacts: use device.image for Mako"

This reverts commit 69d99067.
parent 69d99067
Loading
Loading
Loading
Loading
Loading
+8 −15
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ The key must match the URL segment ``<station>/<camera>``.

# System modules
import asyncio
import base64
import configparser
from pathlib import Path

@@ -190,7 +189,7 @@ async def _run_loop(device, exposure: float, station: str, camera: str):
    try:
        while True:
            if is_stx:
                # STX Guider: trigger exposure, poll ready, then grab matrix → viridis
                # STX Guider: trigger exposure, poll ready, then grab matrix
                await ev.run_in_executor(None, device.start, exposure, 1)
                deadline = ev.time() + exposure + 30.0
                while ev.time() < deadline:
@@ -198,19 +197,13 @@ async def _run_loop(device, exposure: float, station: str, camera: str):
                    if ready == 1:
                        break
                    await asyncio.sleep(0.3)

            data = await ev.run_in_executor(None, lambda: device.matrix)
            if data is not None:
                await streamer._broadcast_preview(station, camera, np.squeeze(data))
            else:
                # Mako: device.image uses array_to_png(matrix, vmin=0, vmax=255),
                # identical to the HTTP stream — no viridis auto-range amplification
                png = await ev.run_in_executor(None, lambda: device.image)
                if png is not None:
                    encoded = base64.b64encode(png).decode('utf-8')
                    await streamer.broadcaster.broadcast(
                        "fits-preview",
                        {"station": station, "camera": camera, "png": encoded},
                    )

            if not is_stx:
                # Mako: broadcast first frame immediately, then wait before next
                await asyncio.sleep(exposure)
    except asyncio.CancelledError:
        pass