[fix](trx-frontend): add peak hold off and scale waterfall floor

Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
2026-03-01 18:38:17 +01:00
parent 0244839a4f
commit fbd881af7b
2 changed files with 8 additions and 3 deletions
@@ -536,7 +536,7 @@ function setStyle(style) {
}
if (overviewPeakHoldEl) {
if (!Number.isFinite(overviewPeakHoldMs) || overviewPeakHoldMs <= 0) {
if (!Number.isFinite(overviewPeakHoldMs) || overviewPeakHoldMs < 0) {
overviewPeakHoldMs = 2000;
}
overviewPeakHoldEl.value = String(overviewPeakHoldMs);
@@ -1020,8 +1020,12 @@ function drawOverviewSignalHistory(ctx, w, h, pal) {
}
function waterfallColor(db, pal) {
const clamped = Math.max(-120, Math.min(-10, Number.isFinite(db) ? db : -120));
const t = (clamped + 120) / 110;
const minDb = Number.isFinite(spectrumFloor) ? spectrumFloor : -115;
const maxDb = minDb + Math.max(20, Number.isFinite(spectrumRange) ? spectrumRange : 90);
const safeDb = Number.isFinite(db) ? db : minDb;
const clamped = Math.max(minDb, Math.min(maxDb, safeDb));
const span = Math.max(1, maxDb - minDb);
const t = (clamped - minDb) / span;
const hue = pal.waterfallHue[0] + t * (pal.waterfallHue[1] - pal.waterfallHue[0]);
const light = pal.waterfallLight[0] + t * (pal.waterfallLight[1] - pal.waterfallLight[0]);
const alpha = pal.waterfallAlpha[0] + t * (pal.waterfallAlpha[1] - pal.waterfallAlpha[0]);
@@ -92,6 +92,7 @@
<div id="spectrum-level-row">
<label class="overview-control" id="spectrum-peak-hold-label">Peak Hold
<select id="overview-peak-hold" class="status-input">
<option value="0">Off</option>
<option value="500">0.5 s</option>
<option value="1000">1 s</option>
<option value="2000" selected>2 s</option>