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