diff --git a/src/stores/mainVehicle.ts b/src/stores/mainVehicle.ts index 77061f8b7..d1db7a457 100644 --- a/src/stores/mainVehicle.ts +++ b/src/stores/mainVehicle.ts @@ -254,6 +254,15 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => { return (vehicle as ArduPilot) || undefined } + function getStringFromValue(map: Map, value: number): string | undefined { + for (const [key, val] of map.entries()) { + if (val === value) { + return key; + } + } + return undefined; + } + VehicleFactory.onVehicles.once((vehicles: WeakRef[]) => { mainVehicle.value = getAutoPilot(vehicles) modes.value = mainVehicle.value.modesAvailable() @@ -303,6 +312,9 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => { firmwareType.value = heartbeat.autopilot.type vehicleType.value = heartbeat.mavtype.type lastHeartbeat.value = new Date() + if (modes.value !== undefined) { + mode.value = getStringFromValue(modes.value, heartbeat.custom_mode); + } }) // eslint-disable-next-line @typescript-eslint/no-explicit-any getAutoPilot(vehicles).onMode.add((vehicleMode: any) => {