1
1
<template >
2
2
<div class =" pa-3" >
3
3
<v-card >
4
- <div class =" main-container d-flex flex-col " >
5
- <v-card outline class =" mr-2 mb-2 flex-shrink-1" >
4
+ <div class =" main-container d-flex flex-row " >
5
+ <v-card outline class =" mr-2 mb-2 flex-shrink-1 d-flex flex-col " >
6
6
<div class =" compass-container" >
7
7
<compass-display :compasses =" reordered_compasses" :colors =" compass_colors" />
8
8
</div >
9
- <v-card class =" pa-2 ma-2" width =" 300px" >
10
- <v-card-title >
11
- Declination
12
- </v-card-title >
13
- <v-card-text class =" flex-shrink-1" >
14
- <parameter-switch label =" Auto Declination" :parameter =" compass_autodec" />
15
- <p >
16
- If you enable this option, the autopilot will automatically set the declination based on your current
17
- location. A GPS or other absolute positioning system is required.
18
- </p >
19
- <v-text-field
20
- label =" Current Declination"
21
- :disabled =" compass_autodec?.value !== 0"
22
- :value =" printParam(compass_dec)"
23
- @click =" openParameterEditor(compass_dec)"
24
- />
25
- </v-card-text >
26
- </v-card >
27
9
</v-card >
10
+
28
11
<v-card outline class =" compass-calib-container mb-2" >
29
12
<v-card-title >
30
13
<h3 >Compass Calibration</h3 >
91
74
</div >
92
75
</v-card-text >
93
76
</v-card >
77
+ <v-card outline class =" mr-2 ml-2 mb-2" >
78
+ <div class =" d-block ma-3" style =" width : 400px ;" >
79
+ <v-expansion-panels focusable >
80
+ <v-expansion-panel >
81
+ <v-expansion-panel-header >
82
+ <b >Declination</b > ({{ declination_short }})
83
+ <v-spacer />
84
+ </v-expansion-panel-header >
85
+ <v-expansion-panel-content >
86
+ <parameter-switch label =" Auto Declination" :parameter =" compass_autodec" />
87
+ <p >
88
+ If you enable this option, the autopilot will automatically set the
89
+ declination based on your current location.
90
+ A GPS or other absolute positioning system is required.
91
+ </p >
92
+ <InlineParameterEditor v-if =" compass_autodec?.value === 0" auto-set :param =" compass_dec" />
93
+ </v-expansion-panel-content >
94
+ </v-expansion-panel >
95
+ <v-expansion-panel >
96
+ <v-expansion-panel-header >
97
+ <template #actions >
98
+ <v-icon v-if =" coordinates_valid" color =" success" >
99
+ mdi-check-circle
100
+ </v-icon >
101
+ <v-icon v-else color =" error" >
102
+ mdi-alert
103
+ </v-icon >
104
+ </template >
105
+
106
+ <b >Global Position</b >
107
+ <v-spacer />
108
+ </v-expansion-panel-header >
109
+ <v-expansion-panel-content >
110
+ <auto-coordinate-detector v-model =" coordinates" />
111
+ </v-expansion-panel-content >
112
+ </v-expansion-panel >
113
+ </v-expansion-panels >
114
+ </div >
115
+ </v-card >
94
116
</div >
95
117
<div class =" compass-reorder-container d-flex flex-row" >
96
118
<v-tabs v-model =" tab" vertical color =" primary" >
198
220
import Vue from ' vue'
199
221
import draggable from ' vuedraggable'
200
222
import {
201
- VCardText , VExpansionPanel , VTextField ,
223
+ VCardText , VExpansionPanel ,
202
224
} from ' vuetify/lib'
203
225
204
226
import ParameterSwitch from ' @/components/common/ParameterSwitch.vue'
227
+ import InlineParameterEditor from ' @/components/parameter-editor/InlineParameterEditor.vue'
205
228
import CompassDisplay from ' @/components/vehiclesetup/configuration/compass/CompassDisplay.vue'
206
229
import CompassParams from ' @/components/vehiclesetup/configuration/compass/CompassParams.vue'
207
230
import mavlink2rest from ' @/libs/MAVLink2Rest'
231
+ import Listener from ' @/libs/MAVLink2Rest/Listener'
208
232
import autopilot_data from ' @/store/autopilot'
209
233
import Parameter , { printParam } from ' @/types/autopilot/parameter'
210
234
import { Dictionary } from ' @/types/common'
@@ -237,20 +261,23 @@ export default Vue.extend({
237
261
CompassLearn ,
238
262
CompassParams ,
239
263
draggable ,
240
- VTextField ,
241
264
LargeVehicleCompassCalibrator ,
242
265
ParameterSwitch ,
243
266
VCardText ,
244
267
VExpansionPanel ,
245
268
FullCompassCalibrator ,
269
+ InlineParameterEditor ,
246
270
},
247
271
data() {
248
272
return {
249
273
tab: 0 ,
250
274
color_options: [' green' , ' blue' , ' purple' , ' red' , ' orange' , ' brown' , ' grey' , ' black' ],
275
+ coordinates: undefined as { lat: number , lon: number } | undefined ,
276
+ coordinates_valid: false ,
251
277
reordered_compasses: [] as deviceId [],
252
278
edited_param: undefined as (undefined | Parameter ),
253
279
edit_param_dialog: false ,
280
+ gps_listener: undefined as Listener | undefined ,
254
281
}
255
282
},
256
283
computed: {
@@ -265,6 +292,12 @@ export default Vue.extend({
265
292
results .GPS2 = ' black'
266
293
return results
267
294
},
295
+ declination_short(): string {
296
+ if (this .compass_autodec ?.value === 1 ) {
297
+ return ' Automatic Declination'
298
+ }
299
+ return ` ${this .compass_dec ?.value .toFixed (2 ) ?? ' N/A' } rad `
300
+ },
268
301
compass_autodec(): Parameter | undefined {
269
302
return autopilot_data .parameter (' COMPASS_AUTODEC' )
270
303
},
@@ -437,6 +470,15 @@ export default Vue.extend({
437
470
},
438
471
mounted() {
439
472
this .reordered_compasses = this .compasses
473
+ this .gps_listener = mavlink2rest .startListening (' GLOBAL_POSITION_INT' ).setCallback ((receivedMessage ) => {
474
+ if (receivedMessage .message .lat !== 0 || receivedMessage .message .lon !== 0 ) {
475
+ this .coordinates_valid = true
476
+ }
477
+ }).setFrequency (0 )
478
+ mavlink2rest .requestMessageRate (' GLOBAL_POSITION_INT' , 1 , autopilot_data .system_id )
479
+ },
480
+ beforeDestroy() {
481
+ this .gps_listener ?.discard ()
440
482
},
441
483
methods: {
442
484
printParam ,
0 commit comments