import { useControlSystem } from '../controls/index.js'; import { formatKeyLabel } from '../controls/keymapUtils.js'; import NightVisionControl from './NightVisionControl.jsx'; import HornControl from './HornControl.jsx'; import CameraTiltControl from './CameraTiltControl.jsx'; const SLIDER_THROTTLE_MS = 150; export default function CameraServoPanel() { const { state: { roverId, camera, keymap, horn }, pipeline, actions: { setServoAngle, setNightVision, startHorn, stopHorn }, } = useControlSystem(); const config = camera?.config; const enabled = Boolean(roverId && camera?.enabled && config); const nightVisionAvailable = Boolean(roverId && pipeline?.nightVision); const nightVisionState = pipeline?.nightVisionState; const hornAvailable = Boolean(roverId && pipeline?.horn); const nightVisionKey = formatKeyLabel(keymap?.nightVisionToggle?.[0]); const hornKey = formatKeyLabel(keymap?.hornHonk?.[0]); const hornBlocked = horn?.overheated; const min = typeof config?.minAngle === 'number' ? config.minAngle : -30; const max = typeof config?.maxAngle === 'number' ? config.maxAngle : 30; const value = typeof camera?.angle === 'number' ? camera.angle : typeof config?.homeAngle === 'number' ? config.homeAngle : (min + max) / 2; if (!enabled && !nightVisionAvailable && !hornAvailable) return null; const handleNightVisionToggle = (nextOn) => { if (!nightVisionAvailable) return; setNightVision(nextOn); }; return (
{nightVisionAvailable && ( )} {hornAvailable && ( )} {enabled && ( )} {/*
*/} {/*

Step: {formatDegrees(step)} ยท Pin GPIO {config?.pin}

*/}
); }