Unverified Commit dff4c0ef authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #6998 from DonLakeFlyer/PX4FlightModeSetup

PX4 - Simple Flight Mode setup: Support switch highlighting
parents e91bbca1 16469725
...@@ -26,10 +26,31 @@ Item { ...@@ -26,10 +26,31 @@ Item {
//property var qgcViewPanel - QGCViewPanel control //property var qgcViewPanel - QGCViewPanel control
property real _margins: ScreenTools.defaultFontPixelHeight / 2 property real _margins: ScreenTools.defaultFontPixelHeight / 2
property var _switchNameList: [ "ACRO", "ARM", "GEAR", "KILL", "LOITER", "OFFB", "POSCTL", "RATT", "RETURN", "STAB" ]
property var _switchFactList: [ ]
property var _switchTHFactList: [ ]
readonly property real _flightModeComboWidth: ScreenTools.defaultFontPixelWidth * 13 readonly property real _flightModeComboWidth: ScreenTools.defaultFontPixelWidth * 13
readonly property real _channelComboWidth: ScreenTools.defaultFontPixelWidth * 13 readonly property real _channelComboWidth: ScreenTools.defaultFontPixelWidth * 13
Component.onCompleted: {
if (controller.vehicle.fixedWing) {
_switchNameList.push("MAN")
}
if (controller.vehicle.vtol) {
_switchNameList.push("TRANS")
}
for (var i=0; i<_switchNameList.length; i++) {
_switchFactList.push("RC_MAP_" + _switchNameList[i] + "_SW")
_switchTHFactList.push("RC_" + _switchNameList[i] + "_TH")
}
if (controller.vehicle.fixedWing) {
_switchFactList.push("RC_MAP_FLAPS")
_switchTHFactList.push("")
}
switchRepeater.model = _switchFactList
}
PX4SimpleFlightModesController { PX4SimpleFlightModesController {
id: controller id: controller
factPanel: qgcViewPanel factPanel: qgcViewPanel
...@@ -138,98 +159,43 @@ Item { ...@@ -138,98 +159,43 @@ Item {
columnSpacing: ScreenTools.defaultFontPixelWidth columnSpacing: ScreenTools.defaultFontPixelWidth
Repeater { 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" ] id: switchRepeater
RowLayout {
spacing: ScreenTools.defaultFontPixelWidth
Layout.fillWidth: true
property Fact fact: controller.getParameterFact(-1, modelData)
QGCLabel {
text: fact.shortDescription
Layout.fillWidth: true
}
FactComboBox {
Layout.preferredWidth: _channelComboWidth
fact: parent.fact
indexModel: false
}
}
}
Repeater {
model: [ "RC_MAP_FLAPS", "RC_MAP_MAN_SW" ]
RowLayout {
spacing: ScreenTools.defaultFontPixelWidth
visible: controller.vehicle.fixedWing
Layout.fillWidth: true
property Fact fact: controller.getParameterFact(-1, modelData)
QGCLabel {
text: fact.shortDescription
Layout.fillWidth: true
}
FactComboBox {
Layout.preferredWidth: _channelComboWidth
fact: parent.fact
indexModel: false
}
}
}
Repeater {
model: [ "RC_MAP_TRANS_SW" ]
RowLayout { RowLayout {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
Layout.fillWidth: true Layout.fillWidth: true
visible: controller.vehicle.vtol
property Fact fact: controller.getParameterFact(-1, modelData)
property string thFactName: _switchTHFactList[index]
property bool thFactExists: thFactName == ""
property Fact swFact: controller.getParameterFact(-1, modelData)
property Fact thFact: thFactExists ? controller.getParameterFact(-1, thFactName) : null
property real thValue: thFactExists ? thFact.rawValue : 0.5
property real thPWM: 1000 + (1000 * thValue)
property int swChannel: swFact.rawValue - 1
property bool swActive: swChannel < 0 ?
false :
(thValue >= 0 ?
(controller.rcChannelValues[swChannel] > thPWM) :
(controller.rcChannelValues[swChannel] <= thPWM))
QGCLabel { QGCLabel {
text: fact.shortDescription text: swFact.shortDescription
Layout.fillWidth: true Layout.fillWidth: true
color: swActive ? "yellow" : qgcPal.text
} }
FactComboBox { FactComboBox {
Layout.preferredWidth: _channelComboWidth Layout.preferredWidth: _channelComboWidth
fact: parent.fact fact: swFact
indexModel: false indexModel: false
} }
} }
} }
Row {
spacing: ScreenTools.defaultFontPixelWidth
property Fact fact: controller.getParameterFact(-1, "RC_MAP_TRANS_SW", false)
visible: (controller.vehicle.vtol && controller.parameterExists(-1, "RC_MAP_TRANS_SW"))
QGCLabel {
anchors.baseline: vtolCombo.baseline
text: qsTr("VTOL mode switch:")
color: parent.fact.value === 0 ? qgcPal.text : (controller.rcChannelValues[parent.fact.value - 1] >= 1500 ? "yellow" : qgcPal.text)
}
FactComboBox {
id: vtolCombo
width: _channelComboWidth
fact: parent.fact
indexModel: false
}
}
} // Column } // Column
} // Rectangle } // Rectangle
RCChannelMonitor { RCChannelMonitor {
width: switchSettingsRect.width width: switchSettingsRect.width
twoColumn: true
} }
} // Column - Switch settings } // Column - Switch settings
} // Row - Settings } // Row - Settings
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
import QtQuick 2.3 import QtQuick 2.3
import QtQuick.Controls 1.2 import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2 import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.11
import QGroundControl 1.0 import QGroundControl 1.0
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
...@@ -23,6 +24,8 @@ FactPanel { ...@@ -23,6 +24,8 @@ FactPanel {
id: _root id: _root
height: monitorColumn.height height: monitorColumn.height
property bool twoColumn: false
readonly property int _pwmMin: 800 readonly property int _pwmMin: 800
readonly property int _pwmMax: 2200 readonly property int _pwmMax: 2200
readonly property int _pwmRange: _pwmMax - _pwmMin readonly property int _pwmRange: _pwmMax - _pwmMin
...@@ -39,6 +42,8 @@ FactPanel { ...@@ -39,6 +42,8 @@ FactPanel {
id: channelMonitorDisplayComponent id: channelMonitorDisplayComponent
Item { Item {
height: ScreenTools.defaultFontPixelHeight
property int rcValue: 1500 property int rcValue: 1500
property int __lastRcValue: 1500 property int __lastRcValue: 1500
...@@ -92,12 +97,15 @@ FactPanel { ...@@ -92,12 +97,15 @@ FactPanel {
} }
} // Component - channelMonitorDisplayComponent } // Component - channelMonitorDisplayComponent
Column { GridLayout {
id: monitorColumn id: monitorColumn
width: parent.width width: parent.width
spacing: ScreenTools.defaultFontPixelHeight / 2 columns: twoColumn ? 2 : 1
QGCLabel { text: "Channel Monitor" } QGCLabel {
Layout.columnSpan: parent.columns
text: "Channel Monitor"
}
Connections { Connections {
target: controller target: controller
...@@ -113,10 +121,7 @@ FactPanel { ...@@ -113,10 +121,7 @@ FactPanel {
id: channelMonitorRepeater id: channelMonitorRepeater
model: controller.channelCount model: controller.channelCount
Item { RowLayout {
width: monitorColumn.width
height: ScreenTools.defaultFontPixelHeight
// Need this to get to loader from Connections above // Need this to get to loader from Connections above
property Item loader: theLoader property Item loader: theLoader
...@@ -127,11 +132,9 @@ FactPanel { ...@@ -127,11 +132,9 @@ FactPanel {
Loader { Loader {
id: theLoader id: theLoader
anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2 Layout.fillWidth: true
anchors.left: channelLabel.right //height: ScreenTools.defaultFontPixelHeight
anchors.verticalCenter: channelLabel.verticalCenter //width: parent.width - anchors.leftMargin - ScreenTools.defaultFontPixelWidth
height: ScreenTools.defaultFontPixelHeight
width: parent.width - anchors.leftMargin - ScreenTools.defaultFontPixelWidth
sourceComponent: channelMonitorDisplayComponent sourceComponent: channelMonitorDisplayComponent
property bool mapped: true property bool mapped: true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment