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
......@@ -25,11 +25,32 @@ Item {
//property var qgcView - QGCView 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 _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 {
id: controller
factPanel: qgcViewPanel
......@@ -138,98 +159,43 @@ Item {
columnSpacing: ScreenTools.defaultFontPixelWidth
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)
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 {
text: fact.shortDescription
text: swFact.shortDescription
Layout.fillWidth: true
color: swActive ? "yellow" : qgcPal.text
}
FactComboBox {
Layout.preferredWidth: _channelComboWidth
fact: parent.fact
fact: swFact
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 {
spacing: ScreenTools.defaultFontPixelWidth
Layout.fillWidth: true
visible: controller.vehicle.vtol
property Fact fact: controller.getParameterFact(-1, modelData)
QGCLabel {
text: fact.shortDescription
Layout.fillWidth: true
}
FactComboBox {
Layout.preferredWidth: _channelComboWidth
fact: parent.fact
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
} // Rectangle
RCChannelMonitor {
width: switchSettingsRect.width
width: switchSettingsRect.width
twoColumn: true
}
} // Column - Switch settings
} // Row - Settings
......
......@@ -11,6 +11,7 @@
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.11
import QGroundControl 1.0
import QGroundControl.Palette 1.0
......@@ -23,6 +24,8 @@ FactPanel {
id: _root
height: monitorColumn.height
property bool twoColumn: false
readonly property int _pwmMin: 800
readonly property int _pwmMax: 2200
readonly property int _pwmRange: _pwmMax - _pwmMin
......@@ -39,6 +42,8 @@ FactPanel {
id: channelMonitorDisplayComponent
Item {
height: ScreenTools.defaultFontPixelHeight
property int rcValue: 1500
property int __lastRcValue: 1500
......@@ -92,12 +97,15 @@ FactPanel {
}
} // Component - channelMonitorDisplayComponent
Column {
GridLayout {
id: monitorColumn
width: parent.width
spacing: ScreenTools.defaultFontPixelHeight / 2
columns: twoColumn ? 2 : 1
QGCLabel { text: "Channel Monitor" }
QGCLabel {
Layout.columnSpan: parent.columns
text: "Channel Monitor"
}
Connections {
target: controller
......@@ -110,13 +118,10 @@ FactPanel {
}
Repeater {
id: channelMonitorRepeater
model: controller.channelCount
Item {
width: monitorColumn.width
height: ScreenTools.defaultFontPixelHeight
id: channelMonitorRepeater
model: controller.channelCount
RowLayout {
// Need this to get to loader from Connections above
property Item loader: theLoader
......@@ -126,12 +131,10 @@ FactPanel {
}
Loader {
id: theLoader
anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
anchors.left: channelLabel.right
anchors.verticalCenter: channelLabel.verticalCenter
height: ScreenTools.defaultFontPixelHeight
width: parent.width - anchors.leftMargin - ScreenTools.defaultFontPixelWidth
id: theLoader
Layout.fillWidth: true
//height: ScreenTools.defaultFontPixelHeight
//width: parent.width - anchors.leftMargin - ScreenTools.defaultFontPixelWidth
sourceComponent: channelMonitorDisplayComponent
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