horn button light up

This commit is contained in:
legop3
2026-01-31 15:37:46 -05:00
parent 7eeb9d13e4
commit 5916520b1a
9 changed files with 159 additions and 131 deletions
+4 -2
View File
@@ -365,13 +365,15 @@ export function ControlSystemProvider({ children }) {
const startHorn = useCallback(() => {
if (!pipeline.horn) return;
pipeline.sendHorn({ action: 'start', ...normalizedHornSettings });
dispatch({ type: 'control/set-horn-active', payload: true });
recordControlIntent();
}, [normalizedHornSettings, pipeline, recordControlIntent]);
}, [dispatch, normalizedHornSettings, pipeline, recordControlIntent]);
const stopHorn = useCallback(() => {
if (!pipeline.horn) return;
pipeline.sendHorn({ action: 'stop' });
}, [pipeline]);
dispatch({ type: 'control/set-horn-active', payload: false });
}, [dispatch, pipeline]);
const registerInputState = useCallback((source, data) => {
dispatch({ type: 'control/register-input-state', payload: { source, state: data } });
+17
View File
@@ -27,6 +27,12 @@ function createSongState() {
};
}
function createHornState() {
return {
active: false,
};
}
export const initialControlState = {
roverId: null,
mode: 'drive',
@@ -34,6 +40,7 @@ export const initialControlState = {
aux: createAuxState(),
camera: createCameraState(),
song: createSongState(),
horn: createHornState(),
lastControlIntentAt: 0,
macros: DEFAULT_MACROS,
keymap: DEFAULT_KEYMAP,
@@ -49,6 +56,7 @@ export function controlReducer(state, action) {
drive: action.payload ? state.drive : createDriveState(),
aux: action.payload ? state.aux : createAuxState(),
song: action.payload ? state.song : createSongState(),
horn: action.payload ? state.horn : createHornState(),
lastControlIntentAt: action.payload ? state.lastControlIntentAt : 0,
};
case 'control/set-mode':
@@ -125,8 +133,17 @@ export function controlReducer(state, action) {
drive: createDriveState(),
aux: createAuxState(),
song: createSongState(),
horn: createHornState(),
lastControlIntentAt: 0,
};
case 'control/set-horn-active':
return {
...state,
horn: {
...(state.horn || createHornState()),
active: Boolean(action.payload),
},
};
case 'control/record-intent':
return {
...state,