This commit is contained in:
legop3
2025-12-27 04:39:07 -05:00
parent ca1f7ef54a
commit a989f2029a
3 changed files with 22 additions and 21 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -11,7 +11,7 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="Multi Roomba Rover" />
<title>Multi Roomba Rover</title>
<script type="module" crossorigin src="/assets/index-CwYMo0lc.js"></script>
<script type="module" crossorigin src="/assets/index-BWhWA7En.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-COtFQYoW.css">
</head>
<body>
+15 -14
View File
@@ -1,6 +1,7 @@
import { useMemo } from 'react';
import { useSession } from '../context/SessionContext.jsx';
import { useTelemetryFrame } from '../context/TelemetryContext.jsx';
import { useDockIr } from '../hooks/useDockIr.js';
function formatMetric(value, fallback = '--') {
if (value == null || value === '') return fallback;
@@ -12,6 +13,7 @@ export default function TelemetryPanel() {
const roverId = session?.assignment?.roverId;
const frame = useTelemetryFrame(roverId);
const sensors = frame?.sensors || {};
const dockState = useDockIr(sensors);
const voltage = sensors.voltageMv != null ? `${(sensors.voltageMv / 1000).toFixed(2)} V` : null;
const current = sensors.currentMa != null ? `${sensors.currentMa} mA` : null;
const batteryTemp = sensors.batteryTemperatureC != null ? `${sensors.batteryTemperatureC} °C` : null;
@@ -115,7 +117,7 @@ function SensorDetails({ sensors }) {
<div className="grid gap-0.5 md:grid-cols-2">
<DetailCard title="Dock IR">
<DockMiniStatus sensors={sensors} />
<DockDebug sensors={sensors} />
<DockDebug state={dockState} />
</DetailCard>
<DetailCard title="Bumps & drops">
@@ -227,22 +229,21 @@ function DockMiniStatus({ sensors }) {
);
}
function DockDebug({ sensors }) {
if (!sensors) return null;
const left = sensors.infraredCharacterLeft;
const right = sensors.infraredCharacterRight;
const omni = sensors.infraredCharacterOmni;
const decode = (code, side) => {
const red = code && [161, 169, 173, 168].includes(code);
const green = code && [164, 172, 173, 168].includes(code);
const force = code && [165, 169, 172, 173].includes(code);
return `${side}: ${code ?? '--'} (${red ? 'R' : ''}${green ? 'G' : ''}${force ? 'F' : '' || 'none'})`;
function DockDebug({ state }) {
if (!state) return null;
const label = (entry) => {
const parts = [];
if (entry.red) parts.push('R');
if (entry.green) parts.push('G');
if (entry.force) parts.push('F');
return parts.length ? parts.join('') : 'none';
};
const age = (entry) => (entry.age != null ? `${entry.age}ms` : '--');
return (
<div className="text-[0.7rem] text-slate-400">
<div>{decode(left, 'Left')}</div>
<div>{decode(omni, 'Omni')}</div>
<div>{decode(right, 'Right')}</div>
<div>{`Left: ${state.left.code ?? '--'} (${label(state.left)}) · age ${age(state.left)}`}</div>
<div>{`Omni: ${state.omni.code ?? '--'} (${label(state.omni)}) · age ${age(state.omni)}`}</div>
<div>{`Right: ${state.right.code ?? '--'} (${label(state.right)}) · age ${age(state.right)}`}</div>
</div>
);
}