From b044fa3fb797b627d685ec2b9ee8b4cfcf120331 Mon Sep 17 00:00:00 2001 From: Eric Date: Sat, 10 Feb 2024 11:09:34 -0800 Subject: [PATCH] altitude-slider: added altitude slider component --- src/App.vue | 2 ++ src/components/AltitudeSlider.vue | 44 +++++++++++++++++++++++++ src/libs/altitude-slider.ts | 11 +++++++ src/libs/vehicle/ardupilot/ardupilot.ts | 5 +-- src/stores/mainVehicle.ts | 6 ++++ 5 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 src/components/AltitudeSlider.vue create mode 100644 src/libs/altitude-slider.ts diff --git a/src/App.vue b/src/App.vue index 37d407b72..5d5908275 100644 --- a/src/App.vue +++ b/src/App.vue @@ -101,6 +101,7 @@ {{ format(timeNow, 'E LLL do HH:mm') }} +
@@ -155,6 +156,7 @@ import { } from '@/libs/joystick/protocols/cockpit-actions' import { useMissionStore } from '@/stores/mission' +import AltitudeSlider from './components/AltitudeSlider.vue' import Dialog from './components/Dialog.vue' import EditMenu from './components/EditMenu.vue' import MiniWidgetContainer from './components/MiniWidgetContainer.vue' diff --git a/src/components/AltitudeSlider.vue b/src/components/AltitudeSlider.vue new file mode 100644 index 000000000..4b8892f7b --- /dev/null +++ b/src/components/AltitudeSlider.vue @@ -0,0 +1,44 @@ + + + + diff --git a/src/libs/altitude-slider.ts b/src/libs/altitude-slider.ts new file mode 100644 index 000000000..9d5d4e26e --- /dev/null +++ b/src/libs/altitude-slider.ts @@ -0,0 +1,11 @@ +import { ref, watch } from 'vue' + +export const showAltitudeSlider = ref(false) +export const altitude_setpoint = ref(0) + +/** + * Watches the altitude value for changes and updates the altitude accordingly. + */ +watch(altitude_setpoint, (newValue, oldValue) => { + console.log(`Altitude changed from ${oldValue} to ${newValue}`) +}) diff --git a/src/libs/vehicle/ardupilot/ardupilot.ts b/src/libs/vehicle/ardupilot/ardupilot.ts index f6afc23fb..fb2b340c2 100644 --- a/src/libs/vehicle/ardupilot/ardupilot.ts +++ b/src/libs/vehicle/ardupilot/ardupilot.ts @@ -398,9 +398,10 @@ export abstract class ArduPilotVehicle extends Vehicle.AbstractVehicle extends Vehicle.AbstractVehicle { if (!mainVehicle.value) { throw new Error('No vehicle available for takeoff') } + + showAltitudeSlider.value = true + const confirmed = await slideToConfirm('Confirm Takeoff', 'Takeoff Command Confirmed') + showAltitudeSlider.value = false + if (confirmed) { mainVehicle.value.takeoff(altitude_setpoint.value) } else {