6import QGroundControl.FactControls
7import QGroundControl.Controls
12 property real _margins: ScreenTools.defaultFontPixelHeight / 2
13 property var _switchNameList: [ "RC_MAP_ARM_SW", "RC_MAP_GEAR_SW", "RC_MAP_KILL_SW", "RC_MAP_LOITER_SW", "RC_MAP_OFFB_SW", "RC_MAP_RETURN_SW" ]
14 property var _switchTHList: [ "RC_ARMSWITCH_TH", "RC_GEAR_TH", "RC_KILLSWITCH_TH", "RC_LOITER_TH", "RC_OFFB_TH", "RC_RETURN_TH" ]
16 readonly property real _channelComboWidth: ScreenTools.defaultFontPixelWidth * 13
18 Component.onCompleted: {
19 if (controller.vehicle.vtol) {
20 _switchNameList.push("RC_MAP_TRANS_SW")
21 _switchTHList.push("RC_TRANS_TH")
23 if (controller.vehicle.fixedWing) {
24 _switchNameList.push("RC_MAP_FLAPS")
25 _switchTHList.push("")
27 switchRepeater.model = _switchNameList
30 PX4SimpleFlightModesController {
37 contentWidth: column2.x + column2.width
38 contentHeight: Math.max(column1.height, column2.height)
49 id: flightModeSettingsColumn
54 text: qsTr("Flight Mode Settings")
59 id: flightModeSettings
60 width: flightModeColumn.width + (_margins * 2)
61 height: flightModeColumn.height + ScreenTools.defaultFontPixelHeight
62 color: qgcPal.windowShade
66 anchors.margins: ScreenTools.defaultFontPixelWidth
67 anchors.left: parent.left
68 anchors.top: parent.top
70 rowSpacing: ScreenTools.defaultFontPixelWidth / 2
71 columnSpacing: rowSpacing
72 flow: GridLayout.TopToBottom
75 Layout.fillWidth: true
76 text: qsTr("Mode Channel")
83 Layout.fillWidth: true
84 text: qsTr("Flight Mode %1").arg(modelData + 1)
85 color: (controller.activeFlightMode - 1) == index ? "yellow" : qgcPal.text
90 Layout.fillWidth: true
91 fact: controller.getParameterFact(-1, "RC_MAP_FLTMODE")
100 Layout.fillWidth: true
101 fact: controller.getParameterFact(-1, "COM_FLTMODE" + (modelData + 1))
107 } // Rectangle - Flight Modes
108 } // Column - Flight mode settings
115 text: qsTr("Switch Settings")
120 id: switchSettingsRect
121 width: switchSettingsGrid.width + (_margins * 2)
122 height: switchSettingsGrid.height + ScreenTools.defaultFontPixelHeight
123 color: qgcPal.windowShade
126 id: switchSettingsGrid
127 anchors.margins: ScreenTools.defaultFontPixelWidth
128 anchors.left: parent.left
129 anchors.top: parent.top
131 columnSpacing: ScreenTools.defaultFontPixelWidth
137 spacing: ScreenTools.defaultFontPixelWidth
138 Layout.fillWidth: true
140 property string thFactName: _switchTHList[index]
141 property bool thFactExists: thFactName !== ""
142 property Fact swFact: controller.getParameterFact(-1, modelData)
143 property Fact thFact: thFactExists ? controller.getParameterFact(-1, thFactName) : null
144 property real thValue: thFactExists ? thFact.rawValue : 0.5
145 property real thPWM: 1000 + (1000 * thValue)
146 property int swChannel: swFact.rawValue - 1
147 property bool swActive: swChannel < 0 ?
150 (controller.rcChannelValues[swChannel] > thPWM) :
151 (controller.rcChannelValues[swChannel] <= thPWM))
153 text: swFact.shortDescription
154 Layout.fillWidth: true
155 color: swActive ? "yellow" : qgcPal.text
159 Layout.preferredWidth: _channelComboWidth
169 width: switchSettingsRect.width
172 } // Column - Switch settings