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

Merge pull request #8852 from DonLakeFlyer/CompassPriority

ArduPilot: Compass priority support
parents 5ea49f8f b1860d28
...@@ -91,6 +91,7 @@ SetupPage { ...@@ -91,6 +91,7 @@ SetupPage {
case _calTypeCompass: case _calTypeCompass:
_orientationsDialogShowCompass = true _orientationsDialogShowCompass = true
_orientationDialogHelp = orientationHelpCal _orientationDialogHelp = orientationHelpCal
_singleCompassSettingsComponentShowPriority = false
dialogTitle = qsTr("Calibrate Compass") dialogTitle = qsTr("Calibrate Compass")
buttons |= StandardButton.Cancel buttons |= StandardButton.Cancel
break break
...@@ -110,6 +111,28 @@ SetupPage { ...@@ -110,6 +111,28 @@ SetupPage {
mainWindow.showComponentDialog(orientationsDialogComponent, dialogTitle, mainWindow.showDialogDefaultWidth, buttons) mainWindow.showComponentDialog(orientationsDialogComponent, dialogTitle, mainWindow.showDialogDefaultWidth, buttons)
} }
function compassLabel(index) {
var label = qsTr("Compass %1 ").arg(index+1)
var addOpenParan = true
var addComma = false
if (sensorParams.compassPrimaryFactAvailable) {
label += sensorParams.rgCompassPrimary[index] ? qsTr("(primary") : qsTr("(secondary")
addComma = true
addOpenParan = false
}
if (sensorParams.rgCompassExternalParamAvailable[index]) {
if (addOpenParan) {
label += "("
}
if (addComma) {
label += qsTr(", ")
}
label += sensorParams.rgCompassExternal[index] ? qsTr("external") : qsTr("internal")
}
label += ")"
return label
}
APMSensorParams { APMSensorParams {
id: sensorParams id: sensorParams
factPanelController: controller factPanelController: controller
...@@ -142,6 +165,7 @@ SetupPage { ...@@ -142,6 +165,7 @@ SetupPage {
mainWindow.showComponentDialog(postCalibrationComponent, qsTr("Compass calibration complete"), mainWindow.showDialogDefaultWidth, StandardButton.Ok) mainWindow.showComponentDialog(postCalibrationComponent, qsTr("Compass calibration complete"), mainWindow.showDialogDefaultWidth, StandardButton.Ok)
break break
case APMSensorsComponentController.CalTypeOnboardCompass: case APMSensorsComponentController.CalTypeOnboardCompass:
_singleCompassSettingsComponentShowPriority = true
mainWindow.showComponentDialog(postOnboardCompassCalibrationComponent, qsTr("Calibration complete"), mainWindow.showDialogDefaultWidth, StandardButton.Ok) mainWindow.showComponentDialog(postOnboardCompassCalibrationComponent, qsTr("Calibration complete"), mainWindow.showDialogDefaultWidth, StandardButton.Ok)
break break
} }
...@@ -189,6 +213,8 @@ SetupPage { ...@@ -189,6 +213,8 @@ SetupPage {
spacing: Math.round(ScreenTools.defaultFontPixelHeight / 2) spacing: Math.round(ScreenTools.defaultFontPixelHeight / 2)
visible: sensorParams.rgCompassAvailable[index] && sensorParams.rgCompassUseFact[index].value visible: sensorParams.rgCompassAvailable[index] && sensorParams.rgCompassUseFact[index].value
property int _index: index
property real greenMaxThreshold: 8 * (sensorParams.rgCompassExternal[index] ? 1 : 2) property real greenMaxThreshold: 8 * (sensorParams.rgCompassExternal[index] ? 1 : 2)
property real yellowMaxThreshold: 15 * (sensorParams.rgCompassExternal[index] ? 1 : 2) property real yellowMaxThreshold: 15 * (sensorParams.rgCompassExternal[index] ? 1 : 2)
property real fitnessRange: 25 * (sensorParams.rgCompassExternal[index] ? 1 : 2) property real fitnessRange: 25 * (sensorParams.rgCompassExternal[index] ? 1 : 2)
...@@ -230,26 +256,13 @@ SetupPage { ...@@ -230,26 +256,13 @@ SetupPage {
} }
} }
Column { Loader {
anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2 anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
spacing: Math.round(ScreenTools.defaultFontPixelHeight / 4) sourceComponent: singleCompassSettingsComponent
QGCLabel {
text: qsTr("Compass ") + (index+1) + " " +
(sensorParams.rgCompassPrimary[index] ? qsTr("(primary") : qsTr("(secondary")) +
(sensorParams.rgCompassExternalParamAvailable[index] ?
(sensorParams.rgCompassExternal[index] ? qsTr(", external") : qsTr(", internal" )) :
"") +
")"
}
FactCheckBox { property int index: _index
text: qsTr("Use Compass")
fact: sensorParams.rgCompassUseFact[index]
visible: sensorParams.rgCompassUseParamAvailable[index] && !sensorParams.rgCompassPrimary[index]
}
} }
} }
} }
...@@ -314,11 +327,12 @@ SetupPage { ...@@ -314,11 +327,12 @@ SetupPage {
controller.vehicle.rebootVehicle() controller.vehicle.rebootVehicle()
hideDialog() hideDialog()
} }
} }
} }
} }
} }
property bool _singleCompassSettingsComponentShowPriority: true
Component { Component {
id: singleCompassSettingsComponent id: singleCompassSettingsComponent
...@@ -327,12 +341,7 @@ SetupPage { ...@@ -327,12 +341,7 @@ SetupPage {
visible: sensorParams.rgCompassAvailable[index] visible: sensorParams.rgCompassAvailable[index]
QGCLabel { QGCLabel {
text: qsTr("Compass ") + (index+1) + " " + text: compassLabel(index)
(sensorParams.rgCompassPrimary[index] ? qsTr("(primary") :qsTr( "(secondary")) +
(sensorParams.rgCompassExternalParamAvailable[index] ?
(sensorParams.rgCompassExternal[index] ? qsTr(", external") : qsTr(", internal") ) :
"") +
")"
} }
Column { Column {
...@@ -340,10 +349,46 @@ SetupPage { ...@@ -340,10 +349,46 @@ SetupPage {
anchors.left: parent.left anchors.left: parent.left
spacing: Math.round(ScreenTools.defaultFontPixelHeight / 4) spacing: Math.round(ScreenTools.defaultFontPixelHeight / 4)
FactCheckBox { RowLayout {
text: qsTr("Use Compass") spacing: ScreenTools.defaultFontPixelWidth
fact: sensorParams.rgCompassUseFact[index]
visible: sensorParams.rgCompassUseParamAvailable[index] && !sensorParams.rgCompassPrimary[index] FactCheckBox {
id: useCompassCheckBox
text: qsTr("Use Compass")
fact: sensorParams.rgCompassUseFact[index]
visible: sensorParams.rgCompassUseParamAvailable[index] && !sensorParams.rgCompassPrimary[index]
}
QGCComboBox {
model: [ qsTr("Priority 1"), qsTr("Priority 2"), qsTr("Priority 3"), qsTr("Not Set") ]
visible: _singleCompassSettingsComponentShowPriority && sensorParams.compassPrioFactsAvailable && useCompassCheckBox.visible && useCompassCheckBox.checked
property int _compassIndex: index
function selectPriorityfromParams() {
if (visible) {
currentIndex = 3
var compassId = sensorParams.rgCompassId[_compassIndex].rawValue
for (var prioIndex=0; prioIndex<3; prioIndex++) {
if (compassId == sensorParams.rgCompassPrio[prioIndex].rawValue) {
currentIndex = prioIndex
break
}
}
}
}
Component.onCompleted: selectPriorityfromParams()
onActivated: {
if (index == 3) {
// User cannot select Not Set
selectPriorityfromParams()
} else {
sensorParams.rgCompassPrio[index].rawValue = sensorParams.rgCompassId[_compassIndex].rawValue
}
}
}
} }
Column { Column {
......
...@@ -17,15 +17,23 @@ Item { ...@@ -17,15 +17,23 @@ Item {
property Fact _noFact: Fact { } property Fact _noFact: Fact { }
property Fact compassPrimaryFact: factPanelController.getParameterFact(-1, "COMPASS_PRIMARY") property bool compassPrimaryFactAvailable: factPanelController.parameterExists(-1, "COMPASS_PRIMARY")
property bool compass1Primary: compassPrimaryFact.rawValue == 0 property Fact compassPrimaryFact: compassPrimaryFactAvailable ? factPanelController.getParameterFact(-1, "COMPASS_PRIMARY") : _noFact
property bool compass2Primary: compassPrimaryFact.rawValue == 1 property bool compass1Primary: compassPrimaryFactAvailable ? compassPrimaryFact.rawValue == 0 : false
property bool compass3Primary: compassPrimaryFact.rawValue == 2 property bool compass2Primary: compassPrimaryFactAvailable ? compassPrimaryFact.rawValue == 1 : false
property bool compass3Primary: compassPrimaryFactAvailable ? compassPrimaryFact.rawValue == 2 : false
property var rgCompassPrimary: [ compass1Primary, compass2Primary, compass3Primary ] property var rgCompassPrimary: [ compass1Primary, compass2Primary, compass3Primary ]
property Fact compass1Id: factPanelController.getParameterFact(-1, "COMPASS_DEV_ID") property Fact compass1Id: factPanelController.getParameterFact(-1, "COMPASS_DEV_ID")
property Fact compass2Id: factPanelController.getParameterFact(-1, "COMPASS_DEV_ID2") property Fact compass2Id: factPanelController.getParameterFact(-1, "COMPASS_DEV_ID2")
property Fact compass3Id: factPanelController.getParameterFact(-1, "COMPASS_DEV_ID3") property Fact compass3Id: factPanelController.getParameterFact(-1, "COMPASS_DEV_ID3")
property var rgCompassId: [ compass1Id, compass2Id, compass3Id ]
property bool compassPrioFactsAvailable: factPanelController.parameterExists(-1, "COMPASS_PRIO1_ID")
property Fact compassPrio1Fact: compassPrioFactsAvailable ? factPanelController.getParameterFact(-1, "COMPASS_PRIO1_ID") : _noFact
property Fact compassPrio2Fact: compassPrioFactsAvailable ? factPanelController.getParameterFact(-1, "COMPASS_PRIO2_ID") : _noFact
property Fact compassPrio3Fact: compassPrioFactsAvailable ? factPanelController.getParameterFact(-1, "COMPASS_PRIO3_ID") : _noFact
property var rgCompassPrio: [ compassPrio1Fact, compassPrio2Fact, compassPrio3Fact ]
property bool compass1Available: compass1Id.value > 0 property bool compass1Available: compass1Id.value > 0
property bool compass2Available: compass2Id.value > 0 property bool compass2Available: compass2Id.value > 0
......
...@@ -28,8 +28,6 @@ SetupPage { ...@@ -28,8 +28,6 @@ SetupPage {
pageName: qsTr("Firmware") pageName: qsTr("Firmware")
showAdvanced: activeVehicle && activeVehicle.apmFirmware showAdvanced: activeVehicle && activeVehicle.apmFirmware
signal cancelDialog
Component { Component {
id: firmwarePageComponent id: firmwarePageComponent
...@@ -135,15 +133,20 @@ SetupPage { ...@@ -135,15 +133,20 @@ SetupPage {
} else { } else {
// We end up here when we detect a board plugged in after we've started upgrade // We end up here when we detect a board plugged in after we've started upgrade
statusTextArea.append(highlightPrefix + qsTr("Found device") + highlightSuffix + ": " + controller.boardType) statusTextArea.append(highlightPrefix + qsTr("Found device") + highlightSuffix + ": " + controller.boardType)
if (controller.pixhawkBoard || controller.px4FlowBoard) { if (controller.px4FlowBoard) {
mainWindow.showComponentDialog(pixhawkFirmwareSelectDialogComponent, title, mainWindow.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel) mainWindow.showComponentDialog(pixhawkFirmwareSelectDialogComponent, title, mainWindow.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel)
} }
} }
} }
onBootloaderFound: {
if (controller.pixhawkBoard) {
mainWindow.showComponentDialog(pixhawkFirmwareSelectDialogComponent, title, mainWindow.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel)
}
}
onError: { onError: {
statusTextArea.append(flashFailText) statusTextArea.append(flashFailText)
firmwarePage.cancelDialog()
} }
} }
...@@ -191,6 +194,11 @@ SetupPage { ...@@ -191,6 +194,11 @@ SetupPage {
updatePX4VersionDisplay() updatePX4VersionDisplay()
} }
Connections {
target: controller
onError: reject()
}
function accept() { function accept() {
if (_singleFirmwareMode) { if (_singleFirmwareMode) {
controller.flashSingleFirmwareMode(controller.selectedFirmwareBuildType) controller.flashSingleFirmwareMode(controller.selectedFirmwareBuildType)
......
...@@ -245,6 +245,8 @@ void FirmwareUpgradeController::_foundBootloader(int bootloaderVersion, int boar ...@@ -245,6 +245,8 @@ void FirmwareUpgradeController::_foundBootloader(int bootloaderVersion, int boar
if (_rgManifestFirmwareInfo.count()) { if (_rgManifestFirmwareInfo.count()) {
_buildAPMFirmwareNames(); _buildAPMFirmwareNames();
} }
emit bootloaderFound();
} }
......
...@@ -156,6 +156,7 @@ public: ...@@ -156,6 +156,7 @@ public:
signals: signals:
void boardFound (void); void boardFound (void);
void bootloaderFound (void);
void noBoardFound (void); void noBoardFound (void);
void boardGone (void); void boardGone (void);
void flashComplete (void); void flashComplete (void);
......
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