PX4SimpleFlightModes.qml 10.7 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
Don Gagne's avatar
Don Gagne committed
9

10 11 12
import QtQuick          2.3
import QtQuick.Controls 1.2
import QtQuick.Layouts  1.2
Don Gagne's avatar
Don Gagne committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

import QGroundControl.FactSystem    1.0
import QGroundControl.FactControls  1.0
import QGroundControl.Palette       1.0
import QGroundControl.Controls      1.0
import QGroundControl.Controllers   1.0
import QGroundControl.ScreenTools   1.0

Item {
    id: root

    // The following properties must be pushed in from the Loader
    //property var qgcView      - QGCView control
    //property var qgcViewPanel - QGCViewPanel control

    property real _margins: ScreenTools.defaultFontPixelHeight / 2

Don Gagne's avatar
Don Gagne committed
30 31
    readonly property real _flightModeComboWidth:   ScreenTools.defaultFontPixelWidth * 13
    readonly property real _channelComboWidth:      ScreenTools.defaultFontPixelWidth * 13
32

Don Gagne's avatar
Don Gagne committed
33 34 35 36 37 38 39 40
    PX4SimpleFlightModesController {
        id:         controller
        factPanel:  qgcViewPanel
    }

    QGCFlickable {
        anchors.fill:   parent
        clip:           true
Don Gagne's avatar
Don Gagne committed
41 42
        contentWidth:   column2.x + column2.width
        contentHeight:  Math.max(column1.height, column2.height)
Don Gagne's avatar
Don Gagne committed
43 44

        Column {
Don Gagne's avatar
Don Gagne committed
45
            id:         column1
Don Gagne's avatar
Don Gagne committed
46 47
            spacing:    _margins

Don Gagne's avatar
Don Gagne committed
48 49 50
            Row {
                id:         settingsRow
                spacing:    _margins
Don Gagne's avatar
Don Gagne committed
51 52

                Column {
Don Gagne's avatar
Don Gagne committed
53 54 55 56 57
                    id:     flightModeSettingsColumn
                    spacing: _margins

                    QGCLabel {
                        id:             flightModeLabel
58
                        text:           qsTr("Flight Mode Settings")
59
                        font.family:    ScreenTools.demiboldFontFamily
Don Gagne's avatar
Don Gagne committed
60 61 62 63 64 65 66 67
                    }

                    Rectangle {
                        id:                 flightModeSettings
                        width:              flightModeColumn.width + (_margins * 2)
                        height:             flightModeColumn.height + ScreenTools.defaultFontPixelHeight
                        color:              qgcPal.windowShade

68
                        ColumnLayout {
Don Gagne's avatar
Don Gagne committed
69 70 71 72 73 74
                            id:                 flightModeColumn
                            anchors.margins:    ScreenTools.defaultFontPixelWidth
                            anchors.left:       parent.left
                            anchors.top:        parent.top
                            spacing:            ScreenTools.defaultFontPixelHeight

75 76 77
                            RowLayout {
                                Layout.fillWidth:   true
                                spacing:            _margins
Don Gagne's avatar
Don Gagne committed
78 79

                                QGCLabel {
80
                                    Layout.fillWidth:   true
Don Gagne's avatar
Don Gagne committed
81
                                    text:               qsTr("Mode channel:")
Don Gagne's avatar
Don Gagne committed
82 83 84
                                }

                                FactComboBox {
85 86 87
                                    Layout.preferredWidth:  _channelComboWidth
                                    fact:                   controller.getParameterFact(-1, "RC_MAP_FLTMODE")
                                    indexModel:             false
Don Gagne's avatar
Don Gagne committed
88 89
                                }
                            }
Don Gagne's avatar
Don Gagne committed
90

Don Gagne's avatar
Don Gagne committed
91 92
                            Repeater {
                                model:  6
Don Gagne's avatar
Don Gagne committed
93

94 95 96
                                RowLayout {
                                    Layout.fillWidth:   true
                                    spacing:            ScreenTools.defaultFontPixelWidth
Don Gagne's avatar
Don Gagne committed
97

Don Gagne's avatar
Don Gagne committed
98
                                    property int index:         modelData + 1
Don Gagne's avatar
Don Gagne committed
99

Don Gagne's avatar
Don Gagne committed
100
                                    QGCLabel {
101
                                        Layout.fillWidth:   true
102
                                        text:               qsTr("Flight Mode %1").arg(index)
Don Gagne's avatar
Don Gagne committed
103 104
                                        color:              controller.activeFlightMode == index ? "yellow" : qgcPal.text
                                    }
Don Gagne's avatar
Don Gagne committed
105

Don Gagne's avatar
Don Gagne committed
106
                                    FactComboBox {
107 108 109
                                        Layout.preferredWidth:  _channelComboWidth
                                        fact:                   controller.getParameterFact(-1, "COM_FLTMODE" + index)
                                        indexModel:             false
Don Gagne's avatar
Don Gagne committed
110 111 112 113 114 115 116 117
                                    }
                                }
                            } // Repeater - Flight Modes
                        } // Column - Flight Modes
                    } // Rectangle - Flight Modes
                } // Column - Flight mode settings

                Column {
Don Gagne's avatar
Don Gagne committed
118 119
                    id:         column2
                    spacing:    _margins
Don Gagne's avatar
Don Gagne committed
120 121

                    QGCLabel {
122
                        text:           qsTr("Switch Settings")
123
                        font.family:    ScreenTools.demiboldFontFamily
Don Gagne's avatar
Don Gagne committed
124 125 126
                    }

                    Rectangle {
Don Gagne's avatar
Don Gagne committed
127
                        id:     switchSettingsRect
128 129
                        width:  switchSettingsGrid.width + (_margins * 2)
                        height: switchSettingsGrid.height + ScreenTools.defaultFontPixelHeight
Don Gagne's avatar
Don Gagne committed
130 131
                        color:  qgcPal.windowShade

132 133
                        GridLayout {
                            id:                 switchSettingsGrid
Don Gagne's avatar
Don Gagne committed
134 135 136
                            anchors.margins:    ScreenTools.defaultFontPixelWidth
                            anchors.left:       parent.left
                            anchors.top:        parent.top
137 138
                            columns:            2
                            columnSpacing:      ScreenTools.defaultFontPixelWidth
Don Gagne's avatar
Don Gagne committed
139

140 141
                            Repeater {
                                model: [ "RC_MAP_ACRO_SW", "RC_MAP_ARM_SW", "RC_MAP_GEAR_SW", "RC_MAP_KILL_SW", "RC_MAP_LOITER_SW", "RC_MAP_OFFB_SW", "RC_MAP_POSCTL_SW", "RC_MAP_RATT_SW", "RC_MAP_RETURN_SW", "RC_MAP_STAB_SW" ]
Don Gagne's avatar
Don Gagne committed
142

143 144 145
                                RowLayout {
                                    spacing:            ScreenTools.defaultFontPixelWidth
                                    Layout.fillWidth:   true
Don Gagne's avatar
Don Gagne committed
146

147
                                    property Fact fact: controller.getParameterFact(-1, modelData)
Don Gagne's avatar
Don Gagne committed
148

149 150 151 152 153 154 155 156 157 158
                                    QGCLabel {
                                        text:               fact.shortDescription
                                        Layout.fillWidth:   true
                                    }

                                    FactComboBox {
                                        Layout.preferredWidth:  _channelComboWidth
                                        fact:                   parent.fact
                                        indexModel:             false
                                    }
Don Gagne's avatar
Don Gagne committed
159 160
                                }
                            }
Don Gagne's avatar
Don Gagne committed
161

162 163
                            Repeater {
                                model: [ "RC_MAP_FLAPS", "RC_MAP_MAN_SW" ]
Don Gagne's avatar
Don Gagne committed
164

165 166 167 168
                                RowLayout {
                                    spacing:            ScreenTools.defaultFontPixelWidth
                                    visible:            controller.vehicle.fixedWing
                                    Layout.fillWidth:   true
Don Gagne's avatar
Don Gagne committed
169

170
                                    property Fact fact: controller.getParameterFact(-1, modelData)
Don Gagne's avatar
Don Gagne committed
171

172 173 174 175 176 177 178 179 180 181
                                    QGCLabel {
                                        text:               fact.shortDescription
                                        Layout.fillWidth:   true
                                    }

                                    FactComboBox {
                                        Layout.preferredWidth:  _channelComboWidth
                                        fact:                   parent.fact
                                        indexModel:             false
                                    }
Don Gagne's avatar
Don Gagne committed
182
                                }
Don Gagne's avatar
Don Gagne committed
183 184
                            }

185 186
                            Repeater {
                                model: [ "RC_MAP_TRANS_SW" ]
Don Gagne's avatar
Don Gagne committed
187

188 189 190 191
                                RowLayout {
                                    spacing:            ScreenTools.defaultFontPixelWidth
                                    Layout.fillWidth:   true
                                    visible:            controller.vehicle.vtol
Don Gagne's avatar
Don Gagne committed
192

193
                                    property Fact fact: controller.getParameterFact(-1, modelData)
Don Gagne's avatar
Don Gagne committed
194

195 196 197 198 199 200 201 202 203 204
                                    QGCLabel {
                                        text:               fact.shortDescription
                                        Layout.fillWidth:   true
                                    }

                                    FactComboBox {
                                        Layout.preferredWidth:  _channelComboWidth
                                        fact:                   parent.fact
                                        indexModel:             false
                                    }
Don Gagne's avatar
Don Gagne committed
205 206
                                }
                            }
207

208

209 210 211
                            Row {
                                spacing: ScreenTools.defaultFontPixelWidth

212
                                property Fact fact: controller.getParameterFact(-1, "RC_MAP_TRANS_SW", false)
213
                                visible: (controller.vehicle.vtol && controller.parameterExists(-1, "RC_MAP_TRANS_SW"))
214 215 216

                                QGCLabel {
                                    anchors.baseline:   vtolCombo.baseline
217
                                    text:               qsTr("VTOL mode switch:")
218
                                    color:              parent.fact.value === 0 ? qgcPal.text : (controller.rcChannelValues[parent.fact.value - 1] >= 1500 ? "yellow" : qgcPal.text)
219 220 221 222 223 224 225 226 227
                                }

                                FactComboBox {
                                    id:         vtolCombo
                                    width:      _channelComboWidth
                                    fact:       parent.fact
                                    indexModel: false
                                }
                            }
Don Gagne's avatar
Don Gagne committed
228 229
                        } // Column
                    } // Rectangle
Don Gagne's avatar
Don Gagne committed
230 231 232 233

                    RCChannelMonitor {
                        width: switchSettingsRect.width
                    }
Don Gagne's avatar
Don Gagne committed
234 235
                } // Column - Switch settings
            } // Row - Settings
Don Gagne's avatar
Don Gagne committed
236 237

            QGCButton {
Don Gagne's avatar
Don Gagne committed
238
                text: "Use Multi Channel Mode Selection"
Don Gagne's avatar
Don Gagne committed
239 240 241 242 243 244 245 246
                onClicked: {
                    controller.getParameterFact(-1, "RC_MAP_MODE_SW").value = 5
                    controller.getParameterFact(-1, "RC_MAP_FLTMODE").value = 0
                }
            }
        } // Column
    } // QGCFlickable
} // QGCView