laser locking and idle

This commit is contained in:
legop3
2026-06-27 18:06:24 -04:00
parent 0cfc16528b
commit 4ee4f7d06e
9 changed files with 256 additions and 152 deletions
@@ -10,9 +10,11 @@ import { AUX_ZERO } from './constants.js';
import VacuumControls from './VacuumControls.jsx';
import VerticalCameraTilt from './VerticalCameraTilt.jsx';
import { trackAnalyticsEvent } from '../../analytics/index.js';
import { useSessionSelector } from '../../context/SessionContext.jsx';
function AuxColumnContent() {
const roverId = useControlSelector((control) => control.state.roverId);
const roomLightsLockedOn = useSessionSelector((state) => Boolean(state.session?.homeAssistant?.lightPolicy?.lockedOn));
const camera = useControlSelector((control) => control.state.camera);
const horn = useControlSelector((control) => control.state.horn);
const headlight = useControlSelector((control) => control.pipeline?.headlight);
@@ -120,7 +122,7 @@ function AuxColumnContent() {
<GPIOToggleControl
label="Laser"
on={laserState?.laserOn}
disabled={disabled}
disabled={disabled || roomLightsLockedOn}
onToggle={handleLaserToggle}
heightClass="h-full"
/>
+2 -1
View File
@@ -59,6 +59,7 @@ function TopDownMapPanel() {
function DriveDockPanel() {
const roverId = useControlSelector((control) => control.state.roverId);
const roomLightsLockedOn = useSessionSelector((state) => Boolean(state.session?.homeAssistant?.lightPolicy?.lockedOn));
const keymap = useControlSelector((control) => control.state.keymap);
const camera = useControlSelector((control) => control.state.camera);
const horn = useControlSelector((control) => control.state.horn);
@@ -136,7 +137,7 @@ function DriveDockPanel() {
<GPIOToggleControl
label="Laser"
on={laserState?.laserOn}
disabled={!roverId}
disabled={!roverId || roomLightsLockedOn}
onToggle={trackedControls.setLaser}
keyLabel={laserLabel}
/>
+3 -1
View File
@@ -166,6 +166,7 @@ export function ControlSystemProvider({ children }) {
: true;
const roverId = useSessionSelector((state) => state.session?.assignment?.roverId ?? null);
const homeAssistantEntities = useSessionSelector((state) => state.session?.homeAssistant?.entities ?? []);
const roomLightsLockedOn = useSessionSelector((state) => Boolean(state.session?.homeAssistant?.lightPolicy?.lockedOn));
const { homeAssistantSetState } = useSessionActions();
const overcurrentLimiter = useOvercurrentLimiter(roverId);
const driveTransform = useCallback(
@@ -491,13 +492,14 @@ export function ControlSystemProvider({ children }) {
const setLaser = useCallback(
(laserOn) => {
if (!pipeline.laser) return;
if (roomLightsLockedOn && laserOn !== false) return;
// The laser shares the same logical toggle contract as the headlight; it
// is separate only because it has its own GPIO pin, UI control, and keybind.
const action = typeof laserOn === 'boolean' ? (laserOn ? 'on' : 'off') : 'toggle';
pipeline.sendLaser(action);
recordControlIntent();
},
[pipeline, recordControlIntent],
[pipeline, recordControlIntent, roomLightsLockedOn],
);
const toggleLaser = useCallback(() => {