6import QGroundControl.FactControls
7import QGroundControl.Controls
12 pageComponent: airspeedPageComponent
15 id: airspeedPageComponent
19 spacing: ScreenTools.defaultFontPixelHeight
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
37 readonly property real _margins: ScreenTools.defaultFontPixelWidth / 2
38 readonly property real _comboWidth: ScreenTools.defaultFontPixelWidth * 30
39 readonly property real _textFieldWidth: ScreenTools.defaultFontPixelWidth * 15
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
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
53 readonly property var _nonI2CTypes: [_typeNone, _typeAnalog, _typeDroneCAN, _typeNMEA, _typeMSP, _typeExtAHRS]
54 readonly property var _nonPitotTypes: [_typeNone, _typeNMEA, _typeMSP, _typeExtAHRS]
56 readonly property var _psiRangeTypes: [_typeSDP3X, _typeDLVR, _typeASP5033, _typeMS5525_Addr1, _typeMS5525_Addr2, _typeSDPx1, _typeSDPx2, _typeSDPx3]
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 }
63 FactPanelController { id: controller }
64 QGCPalette { id: qgcPal; colorGroupEnabled: true }
68 Layout.fillWidth: true
75 text: qsTr("Advanced")
82 Layout.maximumWidth: availableWidth
83 spacing: ScreenTools.defaultFontPixelHeight
84 visible: tabBar.currentIndex === 0
86 // ─── Shared Basic Sensor Configuration Component ───
89 id: basicSensorSettingsComponent
94 LabelledFactComboBox {
95 label: qsTr("Sensor type")
98 comboBoxPreferredWidth: _comboWidth
99 Layout.fillWidth: true
104 visible: sensorTypeFact.rawValue !== _typeNone
106 LabelledFactComboBox {
107 label: qsTr("Use airspeed")
108 fact: controller.getParameterFact(-1, paramPrefix + "USE", false)
110 comboBoxPreferredWidth: _comboWidth
111 Layout.fillWidth: true
112 visible: controller.parameterExists(-1, paramPrefix + "USE")
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")
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")
133 // ─── Primary Sensor Configuration ───
136 title: qsTr("Primary Airspeed Sensor")
137 visible: _arspdTypeAvailable
140 sourceComponent: basicSensorSettingsComponent
141 property string paramPrefix: "ARSPD_"
142 property Fact sensorTypeFact: _arspdType
146 // ─── Second Sensor Configuration ───
149 title: qsTr("Second Airspeed Sensor")
150 visible: _arspd2TypeAvailable
153 sourceComponent: basicSensorSettingsComponent
154 property string paramPrefix: "ARSPD2_"
155 property Fact sensorTypeFact: _arspd2Type
159 // ─── Multi-Sensor Options ───
162 title: qsTr("Multi-Sensor Options")
163 visible: _sensorEnabled && _sensor2Enabled
168 LabelledFactComboBox {
169 label: qsTr("Primary sensor")
170 fact: controller.getParameterFact(-1, "ARSPD_PRIMARY", false)
172 comboBoxPreferredWidth: _comboWidth
173 Layout.fillWidth: true
174 visible: controller.parameterExists(-1, "ARSPD_PRIMARY")
179 // ─── Airspeed Limits ───
182 title: qsTr("Airspeed Limits")
183 visible: _sensorEnabled && controller.parameterExists(-1, "AIRSPEED_CRUISE")
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")
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")
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")
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")
227 // ─── Advanced Tab ───
230 Layout.maximumWidth: availableWidth
231 spacing: ScreenTools.defaultFontPixelHeight
232 visible: tabBar.currentIndex === 1
234 // ─── Shared Advanced Sensor Configuration Component ───
237 id: advancedSensorSettingsComponent
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")
256 LabelledFactComboBox {
257 label: qsTr("Skip calibration")
258 fact: controller.getParameterFact(-1, paramPrefix + "SKIP_CAL", false)
260 comboBoxPreferredWidth: _comboWidth
261 Layout.fillWidth: true
262 visible: _isPitot(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "SKIP_CAL")
265 LabelledFactComboBox {
266 label: qsTr("Pitot tube order")
267 fact: controller.getParameterFact(-1, paramPrefix + "TUBE_ORDR", false)
269 comboBoxPreferredWidth: _comboWidth
270 Layout.fillWidth: true
271 visible: _isPitot(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "TUBE_ORDR")
274 LabelledFactComboBox {
275 label: qsTr("Analog pin")
276 fact: controller.getParameterFact(-1, paramPrefix + "PIN", false)
278 comboBoxPreferredWidth: _comboWidth
279 Layout.fillWidth: true
280 visible: _isAnalog(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "PIN")
283 LabelledFactComboBox {
284 label: qsTr("I2C bus")
285 fact: controller.getParameterFact(-1, paramPrefix + "BUS", false)
287 comboBoxPreferredWidth: _comboWidth
288 Layout.fillWidth: true
289 visible: _isI2C(sensorTypeFact.rawValue) && controller.parameterExists(-1, paramPrefix + "BUS")
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")
303 // ─── Sensor Advanced Settings ───
306 title: qsTr("Sensor Settings")
307 visible: _sensorEnabled
313 sourceComponent: advancedSensorSettingsComponent
314 active: _sensorEnabled
315 property string paramPrefix: "ARSPD_"
316 property Fact sensorTypeFact: _arspdType
317 property string sensorLabel: qsTr("Primary Sensor")
321 sourceComponent: advancedSensorSettingsComponent
322 active: _sensor2Enabled
323 property string paramPrefix: "ARSPD2_"
324 property Fact sensorTypeFact: _arspd2Type
325 property string sensorLabel: qsTr("Second Sensor")
330 // ─── Health Monitoring ───
333 title: qsTr("Health Monitoring")
334 visible: _sensorEnabled
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")
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")
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")
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")
377 // ─── Airspeed Options ───
380 title: qsTr("Airspeed Options")
381 visible: _sensorEnabled && controller.parameterExists(-1, "ARSPD_OPTIONS")
387 fact: controller.getParameterFact(-1, "ARSPD_OPTIONS", false)
388 Layout.preferredWidth: airspeedPage.availableWidth * 0.5