mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-07-31 08:19:16 +02:00
fix
This commit is contained in:
+4
-5
@@ -186,19 +186,18 @@ async def socket_handler(socket: asyncio.StreamReader, writer: asyncio.StreamWri
|
||||
while True:
|
||||
qdata, ws = await writer_q.get()
|
||||
if not qdata or not ws: break
|
||||
|
||||
try:
|
||||
writer.write(qdata)
|
||||
await writer.drain()
|
||||
|
||||
data = await socket.read(256)
|
||||
if not data:
|
||||
await ws.send(json.dumps({"event": "error", "error": "fm95 socket closed"}))
|
||||
break
|
||||
raise ConnectionResetError("fm95 socket closed") # ← let reconnect handle it
|
||||
await ws.send(json.dumps({"event": "fm95", "data": base64.b64encode(data).decode()}))
|
||||
except Exception as e:
|
||||
await ws.send(json.dumps({"event": "error", "error": str(e)}))
|
||||
break
|
||||
try: await ws.send(json.dumps({"event": "error", "error": str(e)}))
|
||||
except Exception: pass
|
||||
raise
|
||||
|
||||
def websocket_server_process(shared_data: dict, imc_q: multiprocessing.Queue, ws_q: multiprocessing.Queue):
|
||||
async def runner():
|
||||
|
||||
+1
-20
@@ -94,7 +94,6 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header>
|
||||
<h1>FM95 Processor</h1>
|
||||
<p>Live Status Monitor</p>
|
||||
@@ -145,13 +144,6 @@
|
||||
<option value="400">400 pts</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>Y scale:
|
||||
<select id="yscaleSel">
|
||||
<option value="1">-1 – 1</option>
|
||||
<option value="2">-2 – 2</option>
|
||||
<option value="auto" selected>Auto</option>
|
||||
</select>
|
||||
</label>
|
||||
<label style="margin-left:auto; display:flex; align-items:center; gap:6px;">
|
||||
<input type="checkbox" id="gridCb" checked> Grid
|
||||
</label>
|
||||
@@ -177,7 +169,6 @@ let histAgc = new Array(MAX_PTS).fill(null);
|
||||
const canvas = document.getElementById('scope');
|
||||
const ctx = canvas.getContext('2d');
|
||||
const histSel = document.getElementById('histSel');
|
||||
const yscaleSel= document.getElementById('yscaleSel');
|
||||
const gridCb = document.getElementById('gridCb');
|
||||
|
||||
function resizeCanvas() {
|
||||
@@ -188,27 +179,20 @@ function resizeCanvas() {
|
||||
canvas.width = w * r;
|
||||
canvas.height = 200 * r;
|
||||
ctx.scale(r, r);
|
||||
}
|
||||
resizeCanvas();
|
||||
} resizeCanvas();
|
||||
window.addEventListener('resize', () => { ctx.setTransform(1,0,0,1,0,0); resizeCanvas(); drawScope(); });
|
||||
|
||||
function drawScope() {
|
||||
const W = canvas.width / (window.devicePixelRatio || 1);
|
||||
const H = canvas.height / (window.devicePixelRatio || 1);
|
||||
const nPts = parseInt(histSel.value);
|
||||
const yscale = yscaleSel.value;
|
||||
const showGrid = gridCb.checked;
|
||||
|
||||
ctx.clearRect(0, 0, W, H);
|
||||
|
||||
// background
|
||||
ctx.fillStyle = '#060b14';
|
||||
ctx.fillRect(0, 0, W, H);
|
||||
|
||||
// determine y range
|
||||
let yMin = -1, yMax = 1;
|
||||
if (yscale === '2') { yMin = -2; yMax = 2; }
|
||||
else if (yscale === 'auto') {
|
||||
const vals = [...histInput, ...histAudio, ...histAgc].filter(v => v !== null);
|
||||
if (vals.length) {
|
||||
yMin = Math.min(...vals);
|
||||
@@ -216,7 +200,6 @@ function drawScope() {
|
||||
const pad = (yMax - yMin) * 0.1 || 0.05;
|
||||
yMin -= pad; yMax += pad;
|
||||
}
|
||||
}
|
||||
|
||||
const toY = v => H - ((v - yMin) / (yMax - yMin)) * H;
|
||||
|
||||
@@ -307,10 +290,8 @@ function updateUI(values) {
|
||||
}
|
||||
|
||||
histSel.addEventListener('change', drawScope);
|
||||
yscaleSel.addEventListener('change', drawScope);
|
||||
gridCb.addEventListener('change', drawScope);
|
||||
|
||||
// --- WebSocket ---
|
||||
function setStatus(state, text) {
|
||||
const dot = document.getElementById('status-dot');
|
||||
dot.className = '';
|
||||
|
||||
Reference in New Issue
Block a user