diff --git a/ui/index.html b/ui/index.html index 0df21e3..a9c1998 100644 --- a/ui/index.html +++ b/ui/index.html @@ -115,8 +115,63 @@ input[type=range] { cursor: pointer; }
PKT/s: --
- -
+ +
+ +
+ + + + +
+ + +
+ + + + + + + + + +
@@ -838,6 +893,284 @@ async function readLoop() { } } catch(e) { setStatus('Read err: ' + e.message); } } + +// ── Sensor feed tab switching ────────────────────────────────────────────────── +window.switchSensorView = function(view) { + // Hide all views + document.querySelectorAll('.sensor-view').forEach(el => el.classList.add('hidden')); + // Show selected view + document.getElementById(view + '-view').classList.remove('hidden'); + // Update tab buttons + document.querySelectorAll('.sensor-tab-btn').forEach(btn => { + btn.classList.add('bg-gray-900', 'border-gray-700', 'text-gray-400'); + btn.classList.remove('bg-cyan-950', 'border-cyan-800', 'text-cyan-300'); + }); + event.target.classList.remove('bg-gray-900', 'border-gray-700', 'text-gray-400'); + event.target.classList.add('bg-cyan-950', 'border-cyan-800', 'text-cyan-300'); + + // Initialize sensor if needed + if (view === 'gps') initGPS(); + else if (view === 'lidar') initLIDAR(); + else if (view === 'realsense') initRealSense(); +}; + +// ── GPS Map fetcher ─────────────────────────────────────────────────────────── +let gpsInitialized = false; +function initGPS() { + if (gpsInitialized) return; + gpsInitialized = true; + + async function fetchGPS() { + try { + const resp = await fetch('http://localhost:8888/gps', { mode: 'cors', cache: 'no-store' }); + if (!resp.ok) throw new Error(`HTTP ${resp.status}`); + const data = await resp.json(); + // data: { lat, lon, alt, accuracy, timestamp } + if (data.lat !== undefined && data.lon !== undefined) { + document.getElementById('gps-loading').classList.add('hidden'); + document.getElementById('gps-status').textContent = 'LIVE'; + document.getElementById('gps-coords').textContent = `${data.lat.toFixed(6)}, ${data.lon.toFixed(6)}`; + if (data.alt !== undefined) { + document.getElementById('gps-alt').textContent = `Alt: ${data.alt.toFixed(1)}m`; + } + + // Render simple map iframe (OSM + marker) + const mapHtml = ` + + +