claude, make no mistakes

This commit is contained in:
2026-05-10 15:21:27 +02:00
parent 7da4fb90d2
commit 9983927ccf
+16 -21
View File
@@ -54,8 +54,6 @@
.bar-wrap { margin-top: 10px; background: #0a0e1a; border-radius: 4px; height: 5px; overflow: hidden; } .bar-wrap { margin-top: 10px; background: #0a0e1a; border-radius: 4px; height: 5px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--accent, #7eb8f7); width: 0%; transition: width 0.4s ease; } .bar-fill { height: 100%; border-radius: 4px; background: var(--accent, #7eb8f7); width: 0%; transition: width 0.4s ease; }
.card-desc { font-size: 0.68rem; color: #2e4060; margin-top: 6px; } .card-desc { font-size: 0.68rem; color: #2e4060; margin-top: 6px; }
/* Oscilloscope */
.scope-wrap { .scope-wrap {
width: 100%; width: 100%;
max-width: 960px; max-width: 960px;
@@ -89,7 +87,6 @@
background: #111827; color: #7eb8f7; border: 1px solid #1e2d45; background: #111827; color: #7eb8f7; border: 1px solid #1e2d45;
border-radius: 6px; padding: 3px 8px; font-size: 0.72rem; border-radius: 6px; padding: 3px 8px; font-size: 0.72rem;
} }
#last-update { font-size: 0.7rem; color: #2e4060; } #last-update { font-size: 0.7rem; color: #2e4060; }
</style> </style>
</head> </head>
@@ -125,7 +122,6 @@
</div> </div>
</div> </div>
<!-- Oscilloscope -->
<div class="scope-wrap"> <div class="scope-wrap">
<div class="scope-header"> <div class="scope-header">
<div class="scope-title">Oscilloscope — Input &amp; Audio Level</div> <div class="scope-title">Oscilloscope — Input &amp; Audio Level</div>
@@ -166,10 +162,10 @@
let histAudio = new Array(MAX_PTS).fill(null); let histAudio = new Array(MAX_PTS).fill(null);
let histAgc = new Array(MAX_PTS).fill(null); let histAgc = new Array(MAX_PTS).fill(null);
// animation state
let targets = { input: null, audio: null, agc: null }; let targets = { input: null, audio: null, agc: null };
let current = { input: null, audio: null, agc: null }; let current = { input: null, audio: null, agc: null };
let rafId = null; let rafId = null;
const LERP = 0.18; const LERP = 0.18;
function animateTo(key, target) { function animateTo(key, target) {
@@ -193,7 +189,7 @@
} }
} }
// only push to history when the tip actually moves // update only the tip of each history array
histInput[histInput.length - 1] = current.input; histInput[histInput.length - 1] = current.input;
histAudio[histAudio.length - 1] = current.audio; histAudio[histAudio.length - 1] = current.audio;
histAgc[histAgc.length - 1] = current.agc; histAgc[histAgc.length - 1] = current.agc;
@@ -215,7 +211,8 @@
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() {
@@ -225,12 +222,10 @@
const showGrid = gridCb.checked; const showGrid = gridCb.checked;
ctx.clearRect(0, 0, W, H); ctx.clearRect(0, 0, W, H);
ctx.fillStyle = '#060b14'; ctx.fillStyle = '#060b14';
ctx.fillRect(0, 0, W, H); ctx.fillRect(0, 0, W, H);
let yMax = 1; let yMin = -1, yMax = 1;
let yMin = -1;
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);
@@ -241,7 +236,6 @@
const toY = v => H - ((v - yMin) / (yMax - yMin)) * H; const toY = v => H - ((v - yMin) / (yMax - yMin)) * H;
// grid
if (showGrid) { if (showGrid) {
ctx.strokeStyle = 'rgba(255,255,255,0.05)'; ctx.strokeStyle = 'rgba(255,255,255,0.05)';
ctx.lineWidth = 1; ctx.lineWidth = 1;
@@ -259,7 +253,6 @@
const x = (i / vLines) * W; const x = (i / vLines) * W;
ctx.beginPath(); ctx.moveTo(x, 0); ctx.lineTo(x, H); ctx.stroke(); ctx.beginPath(); ctx.moveTo(x, 0); ctx.lineTo(x, H); ctx.stroke();
} }
// zero line
if (yMin < 0 && yMax > 0) { if (yMin < 0 && yMax > 0) {
const y0 = toY(0); const y0 = toY(0);
ctx.strokeStyle = 'rgba(255,255,255,0.15)'; ctx.strokeStyle = 'rgba(255,255,255,0.15)';
@@ -269,7 +262,6 @@
} }
} }
// draw series
function drawLine(hist, color) { function drawLine(hist, color) {
const slice = hist.slice(-nPts); const slice = hist.slice(-nPts);
const step = W / (nPts - 1); const step = W / (nPts - 1);
@@ -285,15 +277,15 @@
else ctx.lineTo(x, y); else ctx.lineTo(x, y);
} }
ctx.stroke(); ctx.stroke();
// glow
ctx.strokeStyle = color + '44'; ctx.strokeStyle = color + '44';
ctx.lineWidth = 4; ctx.lineWidth = 4;
ctx.stroke(); ctx.stroke();
} }
// FIX: was drawing histInput three times
drawLine(histInput, '#f472b6'); drawLine(histInput, '#f472b6');
drawLine(histInput, '#38bdf8'); drawLine(histAudio, '#38bdf8');
drawLine(histInput, '#fb923c'); drawLine(histAgc, '#fb923c');
} }
function decode(b64) { function decode(b64) {
@@ -309,7 +301,7 @@
values.forEach((v, i) => { values.forEach((v, i) => {
const key = FIELDS[i]; const key = FIELDS[i];
const cfg = FIELD_CFG[key]; const cfg = FIELD_CFG[key];
if(cfg) { if (cfg) {
const el = document.getElementById(key); const el = document.getElementById(key);
const bar = document.getElementById('bar_' + key); const bar = document.getElementById('bar_' + key);
el.innerHTML = `${cfg.fmt(v)}${cfg.unit ? `<span class="card-unit">${cfg.unit}</span>` : ''}`; el.innerHTML = `${cfg.fmt(v)}${cfg.unit ? `<span class="card-unit">${cfg.unit}</span>` : ''}`;
@@ -318,10 +310,13 @@
} }
}); });
// replace the three histX.push() lines with: // FIX: use the raw values as the initial push, not current.* which may be null
histInput.push(current.input ?? values[3]); if (histInput.length > MAX_PTS) histInput.shift(); const iv = current.input ?? values[3];
histAudio.push(current.audio ?? values[4]); if (histAudio.length > MAX_PTS) histAudio.shift(); const av = current.audio ?? values[4];
histAgc.push(current.agc ?? values[2]); if (histAgc.length > MAX_PTS) histAgc.shift(); const gv = current.agc ?? values[2];
histInput.push(iv); if (histInput.length > MAX_PTS) histInput.shift();
histAudio.push(av); if (histAudio.length > MAX_PTS) histAudio.shift();
histAgc.push(gv); if (histAgc.length > MAX_PTS) histAgc.shift();
animateTo('input', values[3]); animateTo('input', values[3]);
animateTo('audio', values[4]); animateTo('audio', values[4]);