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 QGCTabBar {
67 id: tabBar
68 Layout.fillWidth: true
69
70 QGCTabButton {
71 text: qsTr("Basic")
72 checked: true
73 }
74 QGCTabButton {
75 text: qsTr("Advanced")
76 }
77 }
78
79 // ─── Basic Tab ───
80
81 Flow {
82 Layout.maximumWidth: availableWidth
83 spacing: ScreenTools.defaultFontPixelHeight
84 visible: tabBar.currentIndex === 0
85
86 // ─── Shared Basic Sensor Configuration Component ───
87
88 Component {
89 id: basicSensorSettingsComponent
90
91 ColumnLayout {
92 spacing: _margins
93
94 LabelledFactComboBox {
95 label: qsTr("Sensor type")
96 fact: sensorTypeFact
97 indexModel: false
98 comboBoxPreferredWidth: _comboWidth
99 Layout.fillWidth: true
100 }
101
102 ColumnLayout {
103 spacing: _margins
104 visible: sensorTypeFact.rawValue !== _typeNone
105
106 LabelledFactComboBox {
107 label: qsTr("Use airspeed")
108 fact: controller.getParameterFact(-1, paramPrefix + "USE", false)
109 indexModel: false
110 comboBoxPreferredWidth: _comboWidth
111 Layout.fillWidth: true
112 visible: controller.parameterExists(-1, paramPrefix + "USE")
113 }
114
115 LabelledFactTextField {
116 label: qsTr("Airspeed ratio")
117 fact: controller.getParameterFact(-1, paramPrefix + "RATIO", false)
118 textFieldPreferredWidth: _textFieldWidth
119 textFieldShowUnits: true
120 Layout.fillWidth: true
121 visible: _isPitot(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "RATIO")
122 }
123
124 FactCheckBox {
125 text: qsTr("Auto calibrate ratio in flight")
126 fact: controller.getParameterFact(-1, paramPrefix + "AUTOCAL", false)
127 visible: _isPitot(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "AUTOCAL")
128 }
129 }
130 }
131 }
132
133 // ─── Primary Sensor Configuration ───
134
135 QGCGroupBox {
136 title: qsTr("Primary Airspeed Sensor")
137 visible: _arspdTypeAvailable
138
139 Loader {
140 sourceComponent: basicSensorSettingsComponent
141 property string paramPrefix: "ARSPD_"
142 property Fact sensorTypeFact: _arspdType
143 }
144 }
145
146 // ─── Second Sensor Configuration ───
147
148 QGCGroupBox {
149 title: qsTr("Second Airspeed Sensor")
150 visible: _arspd2TypeAvailable
151
152 Loader {
153 sourceComponent: basicSensorSettingsComponent
154 property string paramPrefix: "ARSPD2_"
155 property Fact sensorTypeFact: _arspd2Type
156 }
157 }
158
159 // ─── Multi-Sensor Options ───
160
161 QGCGroupBox {
162 title: qsTr("Multi-Sensor Options")
163 visible: _sensorEnabled && _sensor2Enabled
164
165 ColumnLayout {
166 spacing: _margins
167
168 LabelledFactComboBox {
169 label: qsTr("Primary sensor")
170 fact: controller.getParameterFact(-1, "ARSPD_PRIMARY", false)
171 indexModel: false
172 comboBoxPreferredWidth: _comboWidth
173 Layout.fillWidth: true
174 visible: controller.parameterExists(-1, "ARSPD_PRIMARY")
175 }
176 }
177 }
178
179 // ─── Airspeed Limits ───
180
181 QGCGroupBox {
182 title: qsTr("Airspeed Limits")
183 visible: _sensorEnabled && controller.parameterExists(-1, "AIRSPEED_CRUISE")
184
185 ColumnLayout {
186 spacing: _margins
187
188 LabelledFactTextField {
189 label: qsTr("Cruise airspeed")
190 fact: controller.getParameterFact(-1, "AIRSPEED_CRUISE", false)
191 textFieldPreferredWidth: _textFieldWidth
192 textFieldShowUnits: true
193 Layout.fillWidth: true
194 visible: controller.parameterExists(-1, "AIRSPEED_CRUISE")
195 }
196
197 LabelledFactTextField {
198 label: qsTr("Minimum airspeed")
199 fact: controller.getParameterFact(-1, "AIRSPEED_MIN", false)
200 textFieldPreferredWidth: _textFieldWidth
201 textFieldShowUnits: true
202 Layout.fillWidth: true
203 visible: controller.parameterExists(-1, "AIRSPEED_MIN")
204 }
205
206 LabelledFactTextField {
207 label: qsTr("Maximum airspeed")
208 fact: controller.getParameterFact(-1, "AIRSPEED_MAX", false)
209 textFieldPreferredWidth: _textFieldWidth
210 textFieldShowUnits: true
211 Layout.fillWidth: true
212 visible: controller.parameterExists(-1, "AIRSPEED_MAX")
213 }
214
215 LabelledFactTextField {
216 label: qsTr("Stall airspeed")
217 fact: controller.getParameterFact(-1, "AIRSPEED_STALL", false)
218 textFieldPreferredWidth: _textFieldWidth
219 textFieldShowUnits: true
220 Layout.fillWidth: true
221 visible: controller.parameterExists(-1, "AIRSPEED_STALL")
222 }
223 }
224 }
225 }
226
227 // ─── Advanced Tab ───
228
229 Flow {
230 Layout.maximumWidth: availableWidth
231 spacing: ScreenTools.defaultFontPixelHeight
232 visible: tabBar.currentIndex === 1
233
234 // ─── Shared Advanced Sensor Configuration Component ───
235
236 Component {
237 id: advancedSensorSettingsComponent
238
239 ColumnLayout {
240 spacing: _margins
241
242 QGCLabel {
243 text: sensorLabel
244 font.bold: true
245 }
246
247 LabelledFactTextField {
248 label: qsTr("Airspeed offset")
249 fact: controller.getParameterFact(-1, paramPrefix + "OFFSET", false)
250 textFieldPreferredWidth: _textFieldWidth
251 textFieldShowUnits: true
252 Layout.fillWidth: true
253 visible: _isPitot(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "OFFSET")
254 }
255
256 LabelledFactComboBox {
257 label: qsTr("Skip calibration")
258 fact: controller.getParameterFact(-1, paramPrefix + "SKIP_CAL", false)
259 indexModel: false
260 comboBoxPreferredWidth: _comboWidth
261 Layout.fillWidth: true
262 visible: _isPitot(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "SKIP_CAL")
263 }
264
265 LabelledFactComboBox {
266 label: qsTr("Pitot tube order")
267 fact: controller.getParameterFact(-1, paramPrefix + "TUBE_ORDR", false)
268 indexModel: false
269 comboBoxPreferredWidth: _comboWidth
270 Layout.fillWidth: true
271 visible: _isPitot(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "TUBE_ORDR")
272 }
273
274 LabelledFactComboBox {
275 label: qsTr("Analog pin")
276 fact: controller.getParameterFact(-1, paramPrefix + "PIN", false)
277 indexModel: false
278 comboBoxPreferredWidth: _comboWidth
279 Layout.fillWidth: true
280 visible: _isAnalog(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "PIN")
281 }
282
283 LabelledFactComboBox {
284 label: qsTr("I2C bus")
285 fact: controller.getParameterFact(-1, paramPrefix + "BUS", false)
286 indexModel: false
287 comboBoxPreferredWidth: _comboWidth
288 Layout.fillWidth: true
289 visible: _isI2C(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "BUS")
290 }
291
292 LabelledFactTextField {
293 label: qsTr("PSI range")
294 fact: controller.getParameterFact(-1, paramPrefix + "PSI_RANGE", false)
295 textFieldPreferredWidth: _textFieldWidth
296 textFieldShowUnits: true
297 Layout.fillWidth: true
298 visible: _hasPsiRange(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "PSI_RANGE")
299 }
300 }
301 }
302
303 // ─── Sensor Advanced Settings ───
304
305 QGCGroupBox {
306 title: qsTr("Sensor Settings")
307 visible: _sensorEnabled
308
309 ColumnLayout {
310 spacing: _margins
311
312 Loader {
313 sourceComponent: advancedSensorSettingsComponent
314 active: _sensorEnabled
315 property string paramPrefix: "ARSPD_"
316 property Fact sensorTypeFact: _arspdType
317 property string sensorLabel: qsTr("Primary Sensor")
318 }
319
320 Loader {
321 sourceComponent: advancedSensorSettingsComponent
322 active: _sensor2Enabled
323 property string paramPrefix: "ARSPD2_"
324 property Fact sensorTypeFact: _arspd2Type
325 property string sensorLabel: qsTr("Second Sensor")
326 }
327 }
328 }
329
330 // ─── Health Monitoring ───
331
332 QGCGroupBox {
333 title: qsTr("Health Monitoring")
334 visible: _sensorEnabled
335
336 ColumnLayout {
337 spacing: _margins
338
339 LabelledFactTextField {
340 label: qsTr("Max airspeed/groundspeed difference")
341 fact: controller.getParameterFact(-1, "ARSPD_WIND_MAX", false)
342 textFieldPreferredWidth: _textFieldWidth
343 textFieldShowUnits: true
344 Layout.fillWidth: true
345 visible: controller.parameterExists(-1, "ARSPD_WIND_MAX")
346 }
347
348 LabelledFactTextField {
349 label: qsTr("Warning threshold")
350 fact: controller.getParameterFact(-1, "ARSPD_WIND_WARN", false)
351 textFieldPreferredWidth: _textFieldWidth
352 textFieldShowUnits: true
353 Layout.fillWidth: true
354 visible: controller.parameterExists(-1, "ARSPD_WIND_WARN")
355 }
356
357 LabelledFactTextField {
358 label: qsTr("Re-enable gate size")
359 fact: controller.getParameterFact(-1, "ARSPD_WIND_GATE", false)
360 textFieldPreferredWidth: _textFieldWidth
361 textFieldShowUnits: true
362 Layout.fillWidth: true
363 visible: controller.parameterExists(-1, "ARSPD_WIND_GATE")
364 }
365
366 LabelledFactTextField {
367 label: qsTr("Offset calibration error warning")
368 fact: controller.getParameterFact(-1, "ARSPD_OFF_PCNT", false)
369 textFieldPreferredWidth: _textFieldWidth
370 textFieldShowUnits: true
371 Layout.fillWidth: true
372 visible: controller.parameterExists(-1, "ARSPD_OFF_PCNT")
373 }
374 }
375 }
376
377 // ─── Airspeed Options ───
378
379 QGCGroupBox {
380 title: qsTr("Airspeed Options")
381 visible: _sensorEnabled && controller.parameterExists(-1, "ARSPD_OPTIONS")
382
383 ColumnLayout {
384 spacing: _margins
385
386 FactBitmask {
387 fact: controller.getParameterFact(-1, "ARSPD_OPTIONS", false)
388 Layout.preferredWidth: airspeedPage.availableWidth * 0.5
389 }
390 }
391 }
392 }
393 }
394 }
395}