mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
tweak
This commit is contained in:
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user