| | |
| | | export function useManualControl (deviceTopicInfo: DeviceTopicInfo, isCurrentFlightController: Ref<boolean>) { |
| | | const activeCodeKey = ref(null) as Ref<KeyCode | null> |
| | | const mqttHooks = useMqtt(deviceTopicInfo) |
| | | |
| | | let seq = 0 |
| | | function handlePublish (params: DroneControlProtocol) { |
| | | const body = { |
| | | method: DRC_METHOD.DRONE_CONTROL, |
| | |
| | | } |
| | | handleClearInterval() |
| | | myInterval = setInterval(() => { |
| | | body.data.seq = seq++ |
| | | seq++ |
| | | window.console.log('keyCode>>>>', activeCodeKey.value, body) |
| | | body.data.seq = new Date().getTime() |
| | | mqttHooks?.publishMqtt(deviceTopicInfo.pubTopic, body, { qos: 0 }) |
| | | }, 50) |
| | | } |
| | |
| | | const SPEED = 5 // check |
| | | const HEIGHT = 5 // check |
| | | const W_SPEED = 20 // 机头角速度 |
| | | seq = 0 |
| | | switch (keyCode) { |
| | | case 'KeyA': |
| | | if (activeCodeKey.value === keyCode) return |
| | |
| | | |
| | | function resetControlState () { |
| | | activeCodeKey.value = null |
| | | seq = 0 |
| | | handleClearInterval() |
| | | } |
| | | |