big loud turn indicators

This commit is contained in:
legop3
2026-01-15 18:25:33 -05:00
parent f129449d5a
commit 705b38ea7b
10 changed files with 275 additions and 139 deletions
+16 -5
View File
@@ -120,6 +120,10 @@ export function ControlSystemProvider({ children }) {
[],
);
const recordControlIntent = useCallback(() => {
dispatch({ type: 'control/record-intent' });
}, []);
const setDriveVector = useCallback(
(vector, meta = {}) => {
const computed = computeDifferentialSpeeds(vector, meta.speedOptions);
@@ -127,9 +131,10 @@ export function ControlSystemProvider({ children }) {
type: 'control/update-drive',
payload: { ...computed, source: meta.source ?? null },
});
recordControlIntent();
pipeline.sendDriveDirect(computed.speeds);
},
[pipeline],
[pipeline, recordControlIntent],
);
const setAuxMotors = useCallback(
@@ -139,8 +144,9 @@ export function ControlSystemProvider({ children }) {
type: 'control/set-aux-motors',
payload,
});
recordControlIntent();
},
[pipeline],
[pipeline, recordControlIntent],
);
const updateKeyBinding = useCallback(
@@ -176,8 +182,9 @@ export function ControlSystemProvider({ children }) {
dispatch({ type: 'control/set-camera-angle', payload: clamped });
pipeline.sendServoAngle(clamped);
servoAngleRef.current = clamped;
recordControlIntent();
},
[pipeline],
[pipeline, recordControlIntent],
);
const nudgeServo = useCallback(
@@ -217,10 +224,13 @@ export function ControlSystemProvider({ children }) {
if (!session?.homeAssistant?.entities) {
pendingLightsRef.current = true;
}
recordControlIntent();
} else if (macroId === 'seek-dock') {
recordControlIntent();
}
await pipeline.runMacroSteps(macro);
},
[pipeline, state.macros, session?.homeAssistant?.entities, turnOnAllLights],
[pipeline, recordControlIntent, session?.homeAssistant?.entities, state.macros, turnOnAllLights],
);
const stopAllMotion = useCallback(() => {
@@ -256,7 +266,8 @@ export function ControlSystemProvider({ children }) {
const toggleNightVision = useCallback(() => {
pipeline.sendNightVision('toggle');
}, [pipeline]);
recordControlIntent();
}, [pipeline, recordControlIntent]);
const setSongNote = useCallback(
(note) => {
+8
View File
@@ -34,6 +34,7 @@ export const initialControlState = {
aux: createAuxState(),
camera: createCameraState(),
song: createSongState(),
lastControlIntentAt: 0,
macros: DEFAULT_MACROS,
keymap: DEFAULT_KEYMAP,
inputs: {},
@@ -48,6 +49,7 @@ export function controlReducer(state, action) {
drive: action.payload ? state.drive : createDriveState(),
aux: action.payload ? state.aux : createAuxState(),
song: action.payload ? state.song : createSongState(),
lastControlIntentAt: action.payload ? state.lastControlIntentAt : 0,
};
case 'control/set-mode':
return state.mode === action.payload
@@ -123,6 +125,12 @@ export function controlReducer(state, action) {
drive: createDriveState(),
aux: createAuxState(),
song: createSongState(),
lastControlIntentAt: 0,
};
case 'control/record-intent':
return {
...state,
lastControlIntentAt: Date.now(),
};
case 'control/set-song-note':
return {