mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
hud adjustments
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Drive Dock Action
|
||||
// Purpose: Defines the Drive Dock Action module and the local helpers/components used in this file.
|
||||
// Scope: Keeps behavior unchanged while isolating this concern into a clear, single-responsibility unit.
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { useControlSystem } from '../../controls/index.js';
|
||||
import { useTelemetryFrame } from '../../context/TelemetryContext.jsx';
|
||||
import { formatKeyLabel } from '../../controls/keymapUtils.js';
|
||||
@@ -138,6 +138,12 @@ export default function DriveDockAction({
|
||||
const chargeValue = charging ? 'Charging' : docked ? 'Charging soon...' : '—';
|
||||
const chargeTone = charging ? 'good' : docked ? 'warn' : 'bad';
|
||||
|
||||
useEffect(() => {
|
||||
if (!manualAssistActive) return;
|
||||
if (!docked) return;
|
||||
actions.setManualDockAssistActive(false);
|
||||
}, [actions, docked, manualAssistActive]);
|
||||
|
||||
const handleReturnToDrive = async () => {
|
||||
if (!roverId || pending) return;
|
||||
setPending('drive');
|
||||
|
||||
@@ -1,21 +1,40 @@
|
||||
import React from 'react';
|
||||
import { useControlSystem } from '../../../controls/index.js';
|
||||
import { useSessionSelector } from '../../../context/SessionContext.jsx';
|
||||
import { useTelemetryFrame } from '../../../context/TelemetryContext.jsx';
|
||||
|
||||
function ManualDockAssistOverlay({ mobileHud = false }) {
|
||||
const {
|
||||
state: { manualDockAssist },
|
||||
} = useControlSystem();
|
||||
const roverId = useSessionSelector((state) => state.session?.assignment?.roverId ?? null);
|
||||
const frame = useTelemetryFrame(roverId);
|
||||
const sensors = frame?.sensors || {};
|
||||
const chargingLabel = sensors?.chargingState?.label || '';
|
||||
const docked = Boolean(sensors?.chargingSources?.homeBase);
|
||||
const charging = docked && chargingLabel.toLowerCase() !== 'not charging' && chargingLabel !== '';
|
||||
const active = Boolean(manualDockAssist?.active);
|
||||
if (!active) return null;
|
||||
if (!active && !docked) return null;
|
||||
|
||||
const status = charging
|
||||
? 'Docked and charging'
|
||||
: docked
|
||||
? 'Docked'
|
||||
: 'Docking assist active';
|
||||
const toneClass = charging
|
||||
? 'border-emerald-200/70 bg-emerald-900/85 text-emerald-50'
|
||||
: docked
|
||||
? 'border-amber-200/70 bg-amber-900/85 text-amber-50'
|
||||
: 'border-indigo-200/70 bg-indigo-900/85 text-indigo-50';
|
||||
|
||||
return (
|
||||
<div className="pointer-events-none absolute inset-0">
|
||||
<div
|
||||
className={`absolute left-2 rounded-lg border border-amber-200/70 bg-amber-900/85 px-2 py-1 font-semibold tracking-wide text-amber-50 shadow-lg ${
|
||||
mobileHud ? 'top-2 text-[0.65rem]' : 'top-2 text-xs'
|
||||
className={`absolute right-2 top-1/2 -translate-y-1/2 rounded-lg border px-2 py-1 font-semibold shadow-lg ${toneClass} ${
|
||||
mobileHud ? 'text-[0.65rem]' : 'text-xs'
|
||||
}`}
|
||||
>
|
||||
DOCKING ASSIST ACTIVE
|
||||
{status}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -12,7 +12,7 @@ export const DRIVE_LIMITS = {
|
||||
boostSpeed: 400,
|
||||
};
|
||||
|
||||
export const MANUAL_DOCK_ASSIST_MAX_SPEED = 85;
|
||||
export const MANUAL_DOCK_ASSIST_MAX_SPEED = 70;
|
||||
|
||||
export const COMMAND_DELAY_MS = 100;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user