QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
APMAirspeedComponent.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.FactControls
7import QGroundControl.Controls
8
9SetupPage {
10 id: airspeedPage
11
12 pageComponent: airspeedPageComponent
13
14 Component {
15 id: airspeedPageComponent
16
17 ColumnLayout {
18 id: mainLayout
19 spacing: ScreenTools.defaultFontPixelHeight
20
21 // Sensor type constants
22 readonly property int _typeNone: 0
23 readonly property int _typeAnalog: 2
24 readonly property int _typeSDP3X: 7
25 readonly property int _typeDroneCAN: 8
26 readonly property int _typeDLVR: 9
27 readonly property int _typeASP5033: 10
28 readonly property int _typeMS5525_Addr1: 11
29 readonly property int _typeMS5525_Addr2: 12
30 readonly property int _typeNMEA: 13
31 readonly property int _typeMSP: 14
32 readonly property int _typeExtAHRS: 16
33 readonly property int _typeSDPx1: 17
34 readonly property int _typeSDPx2: 18
35 readonly property int _typeSDPx3: 19
36
37 readonly property real _margins: ScreenTools.defaultFontPixelWidth / 2
38 readonly property real _comboWidth: ScreenTools.defaultFontPixelWidth * 30
39 readonly property real _textFieldWidth: ScreenTools.defaultFontPixelWidth * 15
40
41 // Primary sensor
42 readonly property bool _arspdTypeAvailable: controller.parameterExists(-1, "ARSPD_TYPE")
43 readonly property Fact _arspdType: _arspdTypeAvailable ? controller.getParameterFact(-1, "ARSPD_TYPE") : null
44 readonly property int _sensorType: _arspdType ? _arspdType.rawValue : 0
45 readonly property bool _sensorEnabled: _arspdTypeAvailable && _sensorType !== _typeNone
46
47 // Second sensor
48 readonly property bool _arspd2TypeAvailable: controller.parameterExists(-1, "ARSPD2_TYPE")
49 readonly property Fact _arspd2Type: _arspd2TypeAvailable ? controller.getParameterFact(-1, "ARSPD2_TYPE") : null
50 readonly property int _sensor2Type: _arspd2Type ? _arspd2Type.rawValue : 0
51 readonly property bool _sensor2Enabled: _arspd2TypeAvailable && _sensor2Type !== _typeNone
52
53 readonly property var _nonI2CTypes: [_typeNone, _typeAnalog, _typeDroneCAN, _typeNMEA, _typeMSP, _typeExtAHRS]
54 readonly property var _nonPitotTypes: [_typeNone, _typeNMEA, _typeMSP, _typeExtAHRS]
55
56 readonly property var _psiRangeTypes: [_typeSDP3X, _typeDLVR, _typeASP5033, _typeMS5525_Addr1, _typeMS5525_Addr2, _typeSDPx1, _typeSDPx2, _typeSDPx3]
57
58 function _isAnalog(sType) { return sType === _typeAnalog }
59 function _isI2C(sType) { return _nonI2CTypes.indexOf(sType) === -1 }
60 function _isPitot(sType) { return _nonPitotTypes.indexOf(sType) === -1 }
61 function _hasPsiRange(sType) { return _psiRangeTypes.indexOf(sType) !== -1 }
62
63 FactPanelController { id: controller }
64 QGCPalette { id: qgcPal; colorGroupEnabled: true }
65
66 QGCGroupBox {
67 Layout.maximumWidth: availableWidth
68 showDividers: false
69
70 // ─── Basic Tab ───
71
72 QGCGroupBoxTab {
73 title: qsTr("Basic")
74
75 Flow {
76 Layout.fillWidth: true
77 spacing: ScreenTools.defaultFontPixelHeight
78
79 // ─── Shared Basic Sensor Configuration Component ───
80
81 Component {
82 id: basicSensorSettingsComponent
83
84 ColumnLayout {
85 spacing: _margins
86
87 LabelledFactComboBox {
88 label: qsTr("Sensor type")
89 fact: sensorTypeFact
90 indexModel: false
91 comboBoxPreferredWidth: _comboWidth
92 Layout.fillWidth: true
93 }
94
95 ColumnLayout {
96 spacing: _margins
97 visible: sensorTypeFact.rawValue !== _typeNone
98
99 LabelledFactComboBox {
100 label: qsTr("Use airspeed")
101 fact: controller.getParameterFact(-1, paramPrefix + "USE", false)
102 indexModel: false
103 comboBoxPreferredWidth: _comboWidth
104 Layout.fillWidth: true
105 visible: controller.parameterExists(-1, paramPrefix + "USE")
106 }
107
108 LabelledFactTextField {
109 label: qsTr("Airspeed ratio")
110 fact: controller.getParameterFact(-1, paramPrefix + "RATIO", false)
111 textFieldPreferredWidth: _textFieldWidth
112 textFieldShowUnits: true
113 Layout.fillWidth: true
114 visible: _isPitot(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "RATIO")
115 }
116
117 FactCheckBox {
118 text: qsTr("Auto calibrate ratio in flight")
119 fact: controller.getParameterFact(-1, paramPrefix + "AUTOCAL", false)
120 visible: _isPitot(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "AUTOCAL")
121 }
122 }
123 }
124 }
125
126 // ─── Primary Sensor Configuration ───
127
128 QGCGroupBox {
129 heading: qsTr("Primary Airspeed Sensor")
130 visible: _arspdTypeAvailable
131
132 Loader {
133 sourceComponent: basicSensorSettingsComponent
134 property string paramPrefix: "ARSPD_"
135 property Fact sensorTypeFact: _arspdType
136 }
137 }
138
139 // ─── Second Sensor Configuration ───
140
141 QGCGroupBox {
142 heading: qsTr("Second Airspeed Sensor")
143 visible: _arspd2TypeAvailable
144
145 Loader {
146 sourceComponent: basicSensorSettingsComponent
147 property string paramPrefix: "ARSPD2_"
148 property Fact sensorTypeFact: _arspd2Type
149 }
150 }
151
152 // ─── Multi-Sensor Options ───
153
154 QGCGroupBox {
155 heading: qsTr("Multi-Sensor Options")
156 visible: _sensorEnabled && _sensor2Enabled
157
158 ColumnLayout {
159 spacing: _margins
160
161 LabelledFactComboBox {
162 label: qsTr("Primary sensor")
163 fact: controller.getParameterFact(-1, "ARSPD_PRIMARY", false)
164 indexModel: false
165 comboBoxPreferredWidth: _comboWidth
166 Layout.fillWidth: true
167 visible: controller.parameterExists(-1, "ARSPD_PRIMARY")
168 }
169 }
170 }
171
172 // ─── Airspeed Limits ───
173
174 QGCGroupBox {
175 heading: qsTr("Airspeed Limits")
176 visible: _sensorEnabled && controller.parameterExists(-1, "AIRSPEED_CRUISE")
177
178 ColumnLayout {
179 spacing: _margins
180
181 LabelledFactTextField {
182 label: qsTr("Cruise airspeed")
183 fact: controller.getParameterFact(-1, "AIRSPEED_CRUISE", false)
184 textFieldPreferredWidth: _textFieldWidth
185 textFieldShowUnits: true
186 Layout.fillWidth: true
187 visible: controller.parameterExists(-1, "AIRSPEED_CRUISE")
188 }
189
190 LabelledFactTextField {
191 label: qsTr("Minimum airspeed")
192 fact: controller.getParameterFact(-1, "AIRSPEED_MIN", false)
193 textFieldPreferredWidth: _textFieldWidth
194 textFieldShowUnits: true
195 Layout.fillWidth: true
196 visible: controller.parameterExists(-1, "AIRSPEED_MIN")
197 }
198
199 LabelledFactTextField {
200 label: qsTr("Maximum airspeed")
201 fact: controller.getParameterFact(-1, "AIRSPEED_MAX", false)
202 textFieldPreferredWidth: _textFieldWidth
203 textFieldShowUnits: true
204 Layout.fillWidth: true
205 visible: controller.parameterExists(-1, "AIRSPEED_MAX")
206 }
207
208 LabelledFactTextField {
209 label: qsTr("Stall airspeed")
210 fact: controller.getParameterFact(-1, "AIRSPEED_STALL", false)
211 textFieldPreferredWidth: _textFieldWidth
212 textFieldShowUnits: true
213 Layout.fillWidth: true
214 visible: controller.parameterExists(-1, "AIRSPEED_STALL")
215 }
216 }
217 }
218 }
219 }
220
221 // ─── Advanced Tab ───
222
223 QGCGroupBoxTab {
224 title: qsTr("Advanced")
225
226 Flow {
227 Layout.fillWidth: true
228 spacing: ScreenTools.defaultFontPixelHeight
229
230 // ─── Shared Advanced Sensor Configuration Component ───
231
232 Component {
233 id: advancedSensorSettingsComponent
234
235 ColumnLayout {
236 spacing: _margins
237
238 QGCLabel {
239 text: sensorLabel
240 font.bold: true
241 }
242
243 LabelledFactTextField {
244 label: qsTr("Airspeed offset")
245 fact: controller.getParameterFact(-1, paramPrefix + "OFFSET", false)
246 textFieldPreferredWidth: _textFieldWidth
247 textFieldShowUnits: true
248 Layout.fillWidth: true
249 visible: _isPitot(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "OFFSET")
250 }
251
252 LabelledFactComboBox {
253 label: qsTr("Skip calibration")
254 fact: controller.getParameterFact(-1, paramPrefix + "SKIP_CAL", false)
255 indexModel: false
256 comboBoxPreferredWidth: _comboWidth
257 Layout.fillWidth: true
258 visible: _isPitot(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "SKIP_CAL")
259 }
260
261 LabelledFactComboBox {
262 label: qsTr("Pitot tube order")
263 fact: controller.getParameterFact(-1, paramPrefix + "TUBE_ORDR", false)
264 indexModel: false
265 comboBoxPreferredWidth: _comboWidth
266 Layout.fillWidth: true
267 visible: _isPitot(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "TUBE_ORDR")
268 }
269
270 LabelledFactComboBox {
271 label: qsTr("Analog pin")
272 fact: controller.getParameterFact(-1, paramPrefix + "PIN", false)
273 indexModel: false
274 comboBoxPreferredWidth: _comboWidth
275 Layout.fillWidth: true
276 visible: _isAnalog(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "PIN")
277 }
278
279 LabelledFactComboBox {
280 label: qsTr("I2C bus")
281 fact: controller.getParameterFact(-1, paramPrefix + "BUS", false)
282 indexModel: false
283 comboBoxPreferredWidth: _comboWidth
284 Layout.fillWidth: true
285 visible: _isI2C(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "BUS")
286 }
287
288 LabelledFactTextField {
289 label: qsTr("PSI range")
290 fact: controller.getParameterFact(-1, paramPrefix + "PSI_RANGE", false)
291 textFieldPreferredWidth: _textFieldWidth
292 textFieldShowUnits: true
293 Layout.fillWidth: true
294 visible: _hasPsiRange(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "PSI_RANGE")
295 }
296 }
297 }
298
299 // ─── Sensor Advanced Settings ───
300
301 QGCGroupBox {
302 heading: qsTr("Sensor Settings")
303 visible: _sensorEnabled
304
305 ColumnLayout {
306 spacing: _margins
307
308 Loader {
309 sourceComponent: advancedSensorSettingsComponent
310 active: _sensorEnabled
311 property string paramPrefix: "ARSPD_"
312 property Fact sensorTypeFact: _arspdType
313 property string sensorLabel: qsTr("Primary Sensor")
314 }
315
316 Loader {
317 sourceComponent: advancedSensorSettingsComponent
318 active: _sensor2Enabled
319 property string paramPrefix: "ARSPD2_"
320 property Fact sensorTypeFact: _arspd2Type
321 property string sensorLabel: qsTr("Second Sensor")
322 }
323 }
324 }
325
326 // ─── Health Monitoring ───
327
328 QGCGroupBox {
329 heading: qsTr("Health Monitoring")
330 visible: _sensorEnabled
331
332 ColumnLayout {
333 spacing: _margins
334
335 LabelledFactTextField {
336 label: qsTr("Max airspeed/groundspeed difference")
337 fact: controller.getParameterFact(-1, "ARSPD_WIND_MAX", false)
338 textFieldPreferredWidth: _textFieldWidth
339 textFieldShowUnits: true
340 Layout.fillWidth: true
341 visible: controller.parameterExists(-1, "ARSPD_WIND_MAX")
342 }
343
344 LabelledFactTextField {
345 label: qsTr("Warning threshold")
346 fact: controller.getParameterFact(-1, "ARSPD_WIND_WARN", false)
347 textFieldPreferredWidth: _textFieldWidth
348 textFieldShowUnits: true
349 Layout.fillWidth: true
350 visible: controller.parameterExists(-1, "ARSPD_WIND_WARN")
351 }
352
353 LabelledFactTextField {
354 label: qsTr("Re-enable gate size")
355 fact: controller.getParameterFact(-1, "ARSPD_WIND_GATE", false)
356 textFieldPreferredWidth: _textFieldWidth
357 textFieldShowUnits: true
358 Layout.fillWidth: true
359 visible: controller.parameterExists(-1, "ARSPD_WIND_GATE")
360 }
361
362 LabelledFactTextField {
363 label: qsTr("Offset calibration error warning")
364 fact: controller.getParameterFact(-1, "ARSPD_OFF_PCNT", false)
365 textFieldPreferredWidth: _textFieldWidth
366 textFieldShowUnits: true
367 Layout.fillWidth: true
368 visible: controller.parameterExists(-1, "ARSPD_OFF_PCNT")
369 }
370 }
371 }
372
373 // ─── Airspeed Options ───
374
375 QGCGroupBox {
376 heading: qsTr("Airspeed Options")
377 visible: _sensorEnabled && controller.parameterExists(-1, "ARSPD_OPTIONS")
378
379 ColumnLayout {
380 spacing: _margins
381
382 FactBitmask {
383 fact: controller.getParameterFact(-1, "ARSPD_OPTIONS", false)
384 Layout.preferredWidth: airspeedPage.availableWidth * 0.5
385 }
386 }
387 }
388 }
389 }
390 }
391 }
392 }
393}