From e53a2e1f5c67921987b40d35998c01974059a123 Mon Sep 17 00:00:00 2001 From: arsen Date: Mon, 18 May 2026 11:54:54 +0700 Subject: [PATCH] feat(adr-121): mmWave radar pill in raw.html top bar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a hidden-by-default ๐Ÿ“ก mmWave pill next to the global badge + CV stat. Polls /api/v1/mmwave/latest at 5 Hz (~200 ms) โ€” well above the HLK-LD2402's 6 Hz native cadence so no information is lost. Pill shows: ๐Ÿ“ก mmWave 152 cm ยท 60 ms Distance + age (ms since last reading). Fades to 50% opacity when age >1.5 s, hides entirely when the server reports `available: false` (port absent or stale >2 s). Synced both copies โ€” ui/raw.html (deploy mirror) + static/raw.html (canonical source referenced by ADR-104 / ADR-107). Co-Authored-By: Claude Opus 4.7 --- ui/raw.html | 34 +++++++++++++++++++ .../static/raw.html | 34 +++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/ui/raw.html b/ui/raw.html index ceb9b414..22892b21 100644 --- a/ui/raw.html +++ b/ui/raw.html @@ -48,6 +48,12 @@ last: -- absent CV 0% + +
@@ -505,5 +511,33 @@ function connect() { }; } connect(); + +// โ”€โ”€ ADR-121: poll HLK-LD2402 mmWave radar @ 5 Hz โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ +const mmwavePill = document.getElementById('mmwavePill'); +const mmwaveDist = document.getElementById('mmwaveDist'); +const mmwaveAge = document.getElementById('mmwaveAge'); +let mmwaveBusy = false; +async function pollMmwave() { + if (mmwaveBusy) return; mmwaveBusy = true; + try { + const r = await fetch('/api/v1/mmwave/latest', { cache: 'no-store' }); + if (!r.ok) throw new Error('http ' + r.status); + const j = await r.json(); + if (j && j.available) { + mmwavePill.style.display = ''; + mmwaveDist.textContent = j.distance_cm + ' cm'; + const age = Math.round(j.age_ms || 0); + mmwaveAge.textContent = 'ยท ' + age + ' ms'; + // Fade pill if stale (>1.5 s) before server hides at 2 s. + mmwavePill.style.opacity = age > 1500 ? '0.5' : '1.0'; + } else { + mmwavePill.style.display = 'none'; + } + } catch (_) { + mmwavePill.style.display = 'none'; + } finally { mmwaveBusy = false; } +} +pollMmwave(); +setInterval(pollMmwave, 200); diff --git a/v2/crates/wifi-densepose-sensing-server/static/raw.html b/v2/crates/wifi-densepose-sensing-server/static/raw.html index ceb9b414..22892b21 100644 --- a/v2/crates/wifi-densepose-sensing-server/static/raw.html +++ b/v2/crates/wifi-densepose-sensing-server/static/raw.html @@ -48,6 +48,12 @@ last: -- absent CV 0% + +
@@ -505,5 +511,33 @@ function connect() { }; } connect(); + +// โ”€โ”€ ADR-121: poll HLK-LD2402 mmWave radar @ 5 Hz โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ +const mmwavePill = document.getElementById('mmwavePill'); +const mmwaveDist = document.getElementById('mmwaveDist'); +const mmwaveAge = document.getElementById('mmwaveAge'); +let mmwaveBusy = false; +async function pollMmwave() { + if (mmwaveBusy) return; mmwaveBusy = true; + try { + const r = await fetch('/api/v1/mmwave/latest', { cache: 'no-store' }); + if (!r.ok) throw new Error('http ' + r.status); + const j = await r.json(); + if (j && j.available) { + mmwavePill.style.display = ''; + mmwaveDist.textContent = j.distance_cm + ' cm'; + const age = Math.round(j.age_ms || 0); + mmwaveAge.textContent = 'ยท ' + age + ' ms'; + // Fade pill if stale (>1.5 s) before server hides at 2 s. + mmwavePill.style.opacity = age > 1500 ? '0.5' : '1.0'; + } else { + mmwavePill.style.display = 'none'; + } + } catch (_) { + mmwavePill.style.display = 'none'; + } finally { mmwaveBusy = false; } +} +pollMmwave(); +setInterval(pollMmwave, 200);