From 8bc1336d3dd917b7c18327d00181d111dd63a6fe Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Wed, 20 Jul 2016 12:04:25 -0700 Subject: [PATCH] Convert setup pages to use SetupPage --- .../Common/RadioComponent.qml | 372 ++++--- .../Common/RadioComponentController.h | 13 +- src/AutoPilotPlugins/Common/SetupPage.qml | 14 +- src/AutoPilotPlugins/PX4/AirframeComponent.cc | 2 +- .../PX4/AirframeComponent.qml | 221 ++--- src/AutoPilotPlugins/PX4/CameraComponent.cc | 2 +- src/AutoPilotPlugins/PX4/CameraComponent.qml | 160 ++- .../PX4/FlightModesComponent.cc | 4 +- .../PX4/PX4AdvancedFlightModes.qml | 2 - src/AutoPilotPlugins/PX4/PX4FlightModes.qml | 50 +- src/AutoPilotPlugins/PX4/PX4RadioComponent.cc | 5 +- .../PX4/PX4SimpleFlightModes.qml | 2 - .../PX4/PX4TuningComponent.cc | 2 +- .../PX4/PX4TuningComponentCopter.qml | 115 ++- .../PX4/PX4TuningComponentPlane.qml | 80 +- .../PX4/PX4TuningComponentVTOL.qml | 178 ++-- src/AutoPilotPlugins/PX4/PowerComponent.cc | 2 +- src/AutoPilotPlugins/PX4/PowerComponent.qml | 911 +++++++++--------- src/AutoPilotPlugins/PX4/SafetyComponent.cc | 2 +- src/AutoPilotPlugins/PX4/SafetyComponent.qml | 91 +- src/AutoPilotPlugins/PX4/SensorsComponent.cc | 3 +- src/AutoPilotPlugins/PX4/SensorsComponent.qml | 900 ++++++++--------- src/QmlControls/FactSliderPanel.qml | 144 ++- src/QmlControls/ModeSwitchDisplay.qml | 5 +- src/QmlControls/RCChannelMonitor.qml | 2 +- 25 files changed, 1616 insertions(+), 1666 deletions(-) diff --git a/src/AutoPilotPlugins/Common/RadioComponent.qml b/src/AutoPilotPlugins/Common/RadioComponent.qml index 7eec8a97c..a6bef66e7 100644 --- a/src/AutoPilotPlugins/Common/RadioComponent.qml +++ b/src/AutoPilotPlugins/Common/RadioComponent.qml @@ -15,241 +15,209 @@ import QtQuick.Dialogs 1.2 import QGroundControl 1.0 import QGroundControl.FactSystem 1.0 import QGroundControl.FactControls 1.0 -import QGroundControl.Palette 1.0 import QGroundControl.Controls 1.0 import QGroundControl.ScreenTools 1.0 import QGroundControl.Controllers 1.0 -QGCView { - id: qgcView - viewPanel: panel +SetupPage { + id: radioPage + pageComponent: pageComponent - QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled } + Component { + id: pageComponent - readonly property string dialogTitle: qsTr("Radio") - readonly property real labelToMonitorMargin: defaultTextWidth * 3 + Item { + width: availableWidth + height: Math.max(leftColumn.height, rightColumn.height) - property bool controllerCompleted: false - property bool controllerAndViewReady: false + readonly property string dialogTitle: qsTr("Radio") + readonly property real labelToMonitorMargin: defaultTextWidth * 3 - function updateChannelCount() - { -/* - FIXME: Turned off for now, since it prevents binding. Need to restructure to - allow binding and still check channel count - if (controller.channelCount < controller.minChannelCount) { - showDialog(channelCountDialogComponent, dialogTitle, qgcView.showDialogDefaultWidth, 0) - } else { - hideDialog() + property bool controllerCompleted: false + property bool controllerAndViewReady: false + + Component.onCompleted: { + if (controllerCompleted) { + controllerAndViewReady = true + controller.start() + updateChannelCount() + } } -*/ - } - - RadioComponentController { - id: controller - factPanel: panel - statusText: statusText - cancelButton: cancelButton - nextButton: nextButton - skipButton: skipButton - - Component.onCompleted: { - controllerCompleted = true - if (qgcView.completedSignalled) { - controllerAndViewReady = true - controller.start() - updateChannelCount() + + function updateChannelCount() + { } - } - - onChannelCountChanged: updateChannelCount() - onFunctionMappingChangedAPMReboot: showMessage(qsTr("Reboot required"), qsTr("Your stick mappings have changed, you must reboot the vehicle for correct operation."), StandardButton.Ok) - onThrottleReversedCalFailure: showMessage(qsTr("Throttle channel reversed"), qsTr("Calibration failed. The throttle channel on your transmitter is reversed. You must correct this on your transmitter in order to complete calibration."), StandardButton.Ok) - } - - onCompleted: { - if (controllerCompleted) { - controllerAndViewReady = true - controller.start() - updateChannelCount() - } - } - - QGCViewPanel { - id: panel - anchors.fill: parent - - Component { - id: copyTrimsDialogComponent - - QGCViewMessage { - message: qsTr("Center your sticks and move throttle all the way down, then press Ok to copy trims. After pressing Ok, reset the trims on your radio back to zero.") - - function accept() { - hideDialog() - controller.copyTrims() + + RadioComponentController { + id: controller + factPanel: radioPage.viewPanel + statusText: statusText + cancelButton: cancelButton + nextButton: nextButton + skipButton: skipButton + + Component.onCompleted: { + controllerCompleted = true + if (qgcView.completedSignalled) { + controllerAndViewReady = true + controller.start() + updateChannelCount() + } } + + onChannelCountChanged: updateChannelCount() + onFunctionMappingChangedAPMReboot: showMessage(qsTr("Reboot required"), qsTr("Your stick mappings have changed, you must reboot the vehicle for correct operation."), StandardButton.Ok) + onThrottleReversedCalFailure: showMessage(qsTr("Throttle channel reversed"), qsTr("Calibration failed. The throttle channel on your transmitter is reversed. You must correct this on your transmitter in order to complete calibration."), StandardButton.Ok) } - } - Component { - id: zeroTrimsDialogComponent + Component { + id: copyTrimsDialogComponent - QGCViewMessage { - message: qsTr("Before calibrating you should zero all your trims and subtrims. Click Ok to start Calibration.\n\n%1").arg( - (QGroundControl.multiVehicleManager.activeVehicle.px4Firmware ? "" : qsTr("Please ensure all motor power is disconnected AND all props are removed from the vehicle."))) + QGCViewMessage { + message: qsTr("Center your sticks and move throttle all the way down, then press Ok to copy trims. After pressing Ok, reset the trims on your radio back to zero.") - function accept() { - hideDialog() - controller.nextButtonClicked() + function accept() { + hideDialog() + controller.copyTrims() + } } } - } - Component { - id: channelCountDialogComponent + Component { + id: zeroTrimsDialogComponent - QGCViewMessage { - message: controller.channelCount == 0 ? qsTr("Please turn on transmitter.") : qsTr("%1 channels or more are needed to fly.").arg(controller.minChannelCount) - } - } + QGCViewMessage { + message: qsTr("Before calibrating you should zero all your trims and subtrims. Click Ok to start Calibration.\n\n%1").arg( + (QGroundControl.multiVehicleManager.activeVehicle.px4Firmware ? "" : qsTr("Please ensure all motor power is disconnected AND all props are removed from the vehicle."))) - Component { - id: spektrumBindDialogComponent + function accept() { + hideDialog() + controller.nextButtonClicked() + } + } + } - QGCViewDialog { + Component { + id: channelCountDialogComponent - function accept() { - controller.spektrumBindMode(radioGroup.current.bindMode) - hideDialog() + QGCViewMessage { + message: controller.channelCount == 0 ? qsTr("Please turn on transmitter.") : qsTr("%1 channels or more are needed to fly.").arg(controller.minChannelCount) } + } - function reject() { - hideDialog() - } + Component { + id: spektrumBindDialogComponent - Column { - anchors.fill: parent - spacing: 5 + QGCViewDialog { - QGCLabel { - width: parent.width - wrapMode: Text.WordWrap - text: qsTr("Click Ok to place your Spektrum receiver in the bind mode. Select the specific receiver type below:") + function accept() { + controller.spektrumBindMode(radioGroup.current.bindMode) + hideDialog() } - ExclusiveGroup { id: radioGroup } - - QGCRadioButton { - exclusiveGroup: radioGroup - text: qsTr("DSM2 Mode") - - property int bindMode: RadioComponentController.DSM2 + function reject() { + hideDialog() } - QGCRadioButton { - exclusiveGroup: radioGroup - text: qsTr("DSMX (7 channels or less)") - - property int bindMode: RadioComponentController.DSMX7 - } + Column { + anchors.fill: parent + spacing: 5 - QGCRadioButton { - exclusiveGroup: radioGroup - checked: true - text: qsTr("DSMX (8 channels or more)") + QGCLabel { + width: parent.width + wrapMode: Text.WordWrap + text: qsTr("Click Ok to place your Spektrum receiver in the bind mode. Select the specific receiver type below:") + } - property int bindMode: RadioComponentController.DSMX8 - } - } - } - } // Component - spektrumBindDialogComponent + ExclusiveGroup { id: radioGroup } - // Live channel monitor control component - Component { - id: channelMonitorDisplayComponent + QGCRadioButton { + exclusiveGroup: radioGroup + text: qsTr("DSM2 Mode") - Item { - property int rcValue: 1500 + property int bindMode: RadioComponentController.DSM2 + } + QGCRadioButton { + exclusiveGroup: radioGroup + text: qsTr("DSMX (7 channels or less)") - property int __lastRcValue: 1500 - readonly property int __rcValueMaxJitter: 2 - property color __barColor: qgcPal.windowShade + property int bindMode: RadioComponentController.DSMX7 + } - readonly property int _pwmMin: 800 - readonly property int _pwmMax: 2200 - readonly property int _pwmRange: _pwmMax - _pwmMin + QGCRadioButton { + exclusiveGroup: radioGroup + checked: true + text: qsTr("DSMX (8 channels or more)") - // Bar - Rectangle { - id: bar - anchors.verticalCenter: parent.verticalCenter - width: parent.width - height: parent.height / 2 - color: __barColor + property int bindMode: RadioComponentController.DSMX8 + } + } } + } // Component - spektrumBindDialogComponent - // Center point - Rectangle { - anchors.horizontalCenter: parent.horizontalCenter - width: defaultTextWidth / 2 - height: parent.height - color: qgcPal.window - } + // Live channel monitor control component + Component { + id: channelMonitorDisplayComponent - // Indicator - Rectangle { - anchors.verticalCenter: parent.verticalCenter - width: parent.height * 0.75 - height: width - radius: width / 2 - color: qgcPal.text - visible: mapped - x: (((reversed ? _pwmMax - rcValue : rcValue - _pwmMin) / _pwmRange) * parent.width) - (width / 2) - } + Item { + property int rcValue: 1500 - QGCLabel { - anchors.fill: parent - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - text: qsTr("Not Mapped") - visible: !mapped - } - ColorAnimation { - id: barAnimation - target: bar - property: "color" - from: "yellow" - to: __barColor - duration: 1500 - } + property int __lastRcValue: 1500 + readonly property int __rcValueMaxJitter: 2 + property color __barColor: qgcPal.windowShade + + readonly property int _pwmMin: 800 + readonly property int _pwmMax: 2200 + readonly property int _pwmRange: _pwmMax - _pwmMin - /* - // FIXME: Bar animation is turned off for now to figure out better usbaility - onRcValueChanged: { - if (Math.abs(rcValue - __lastRcValue) > __rcValueMaxJitter) { - __lastRcValue = rcValue - barAnimation.restart() + // Bar + Rectangle { + id: bar + anchors.verticalCenter: parent.verticalCenter + width: parent.width + height: parent.height / 2 + color: __barColor } - } - // rcValue debugger - QGCLabel { - anchors.fill: parent - text: rcValue - } - */ - } - } // Component - channelMonitorDisplayComponent + // Center point + Rectangle { + anchors.horizontalCenter: parent.horizontalCenter + width: defaultTextWidth / 2 + height: parent.height + color: qgcPal.window + } - // Main view Qml starts here + // Indicator + Rectangle { + anchors.verticalCenter: parent.verticalCenter + width: parent.height * 0.75 + height: width + radius: width / 2 + color: qgcPal.text + visible: mapped + x: (((reversed ? _pwmMax - rcValue : rcValue - _pwmMin) / _pwmRange) * parent.width) - (width / 2) + } + + QGCLabel { + anchors.fill: parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + text: qsTr("Not Mapped") + visible: !mapped + } - QGCFlickable { - anchors.fill: parent - contentHeight: Math.max(leftColumn.height, rightColumn.height) - clip: true + ColorAnimation { + id: barAnimation + target: bar + property: "color" + from: "yellow" + to: __barColor + duration: 1500 + } + } + } // Component - channelMonitorDisplayComponent // Left side column Column { @@ -277,11 +245,11 @@ QGCView { id: rollLoader anchors.left: rollLabel.right anchors.right: parent.right - height: qgcView.defaultTextHeight + height: radioPage.defaultTextHeight width: 100 sourceComponent: channelMonitorDisplayComponent - property real defaultTextWidth: qgcView.defaultTextWidth + property real defaultTextWidth: radioPage.defaultTextWidth property bool mapped: controller.rollChannelMapped property bool reversed: controller.rollChannelReversed } @@ -307,11 +275,11 @@ QGCView { id: pitchLoader anchors.left: pitchLabel.right anchors.right: parent.right - height: qgcView.defaultTextHeight + height: radioPage.defaultTextHeight width: 100 sourceComponent: channelMonitorDisplayComponent - property real defaultTextWidth: qgcView.defaultTextWidth + property real defaultTextWidth: radioPage.defaultTextWidth property bool mapped: controller.pitchChannelMapped property bool reversed: controller.pitchChannelReversed } @@ -337,11 +305,11 @@ QGCView { id: yawLoader anchors.left: yawLabel.right anchors.right: parent.right - height: qgcView.defaultTextHeight + height: radioPage.defaultTextHeight width: 100 sourceComponent: channelMonitorDisplayComponent - property real defaultTextWidth: qgcView.defaultTextWidth + property real defaultTextWidth: radioPage.defaultTextWidth property bool mapped: controller.yawChannelMapped property bool reversed: controller.yawChannelReversed } @@ -367,11 +335,11 @@ QGCView { id: throttleLoader anchors.left: throttleLabel.right anchors.right: parent.right - height: qgcView.defaultTextHeight + height: radioPage.defaultTextHeight width: 100 sourceComponent: channelMonitorDisplayComponent - property real defaultTextWidth: qgcView.defaultTextWidth + property real defaultTextWidth: radioPage.defaultTextWidth property bool mapped: controller.throttleChannelMapped property bool reversed: controller.throttleChannelReversed } @@ -409,7 +377,7 @@ QGCView { onClicked: { if (text == qsTr("Calibrate")) { - showDialog(zeroTrimsDialogComponent, dialogTitle, qgcView.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel) + showDialog(zeroTrimsDialogComponent, dialogTitle, radioPage.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel) } else { controller.nextButtonClicked() } @@ -442,13 +410,13 @@ QGCView { id: bindButton text: qsTr("Spektrum Bind") - onClicked: showDialog(spektrumBindDialogComponent, dialogTitle, qgcView.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel) + onClicked: showDialog(spektrumBindDialogComponent, dialogTitle, radioPage.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel) } QGCButton { text: qsTr("Copy Trims") visible: QGroundControl.multiVehicleManager.activeVehicle.px4Firmware - onClicked: showDialog(copyTrimsDialogComponent, dialogTitle, qgcView.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel) + onClicked: showDialog(copyTrimsDialogComponent, dialogTitle, radioPage.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel) } Repeater { @@ -484,7 +452,7 @@ QGCView { id: rightColumn anchors.top: parent.top anchors.right: parent.right - width: Math.min(defaultTextWidth * 35, qgcView.width * 0.4) + width: Math.min(radioPage.defaultTextWidth * 35, availableWidth * 0.4) spacing: ScreenTools.defaultFontPixelHeight / 2 Row { @@ -520,6 +488,6 @@ QGCView { width: parent.width } } // Column - Right Column - } // QGCFlickable - } // QGCViewPanel -} + } // Item + } // Component - pageComponent +} // SetupPage diff --git a/src/AutoPilotPlugins/Common/RadioComponentController.h b/src/AutoPilotPlugins/Common/RadioComponentController.h index 2aced17e8..bd3c056cf 100644 --- a/src/AutoPilotPlugins/Common/RadioComponentController.h +++ b/src/AutoPilotPlugins/Common/RadioComponentController.h @@ -45,10 +45,10 @@ public: Q_PROPERTY(int minChannelCount MEMBER _chanMinimum CONSTANT) Q_PROPERTY(int channelCount READ channelCount NOTIFY channelCountChanged) - Q_PROPERTY(QQuickItem* statusText MEMBER _statusText) - Q_PROPERTY(QQuickItem* cancelButton MEMBER _cancelButton) - Q_PROPERTY(QQuickItem* nextButton MEMBER _nextButton) - Q_PROPERTY(QQuickItem* skipButton MEMBER _skipButton) + Q_PROPERTY(QQuickItem* statusText MEMBER _statusText NOTIFY statusTextChanged) + Q_PROPERTY(QQuickItem* cancelButton MEMBER _cancelButton NOTIFY cancelButtonChanged) + Q_PROPERTY(QQuickItem* nextButton MEMBER _nextButton NOTIFY nextButtonChanged) + Q_PROPERTY(QQuickItem* skipButton MEMBER _skipButton NOTIFY skipButtonChanged) Q_PROPERTY(bool rollChannelMapped READ rollChannelMapped NOTIFY rollChannelMappedChanged) Q_PROPERTY(bool pitchChannelMapped READ pitchChannelMapped NOTIFY pitchChannelMappedChanged) @@ -103,6 +103,11 @@ public: void setTransmitterMode(int mode); signals: + void statusTextChanged(void); + void cancelButtonChanged(void); + void nextButtonChanged(void); + void skipButtonChanged(void); + void channelCountChanged(int channelCount); void channelRCValueChanged(int channel, int rcValue); diff --git a/src/AutoPilotPlugins/Common/SetupPage.qml b/src/AutoPilotPlugins/Common/SetupPage.qml index f4bcd67fd..96231c986 100644 --- a/src/AutoPilotPlugins/Common/SetupPage.qml +++ b/src/AutoPilotPlugins/Common/SetupPage.qml @@ -24,7 +24,9 @@ QGCView { id: setupView viewPanel: setupPanel - property alias pageComponent: pageLoader.sourceComponent + property alias pageComponent: pageLoader.sourceComponent + property real availableWidth: width - pageLoader.x + property real availableHeight: height - pageLoader.y property real _margins: ScreenTools.defaultFontPixelHeight / 2 @@ -36,14 +38,13 @@ QGCView { QGCFlickable { anchors.fill: parent - contentWidth: pageLoader.item.x + pageLoader.item.width - contentHeight: pageLoader.item.y + pageLoader.item.height + contentWidth: pageLoader.x + pageLoader.item.width + contentHeight: pageLoader.y + pageLoader.item.height clip: true Column { id: headingColumn - anchors.left: parent.left - anchors.right: parent.right + width: setupPanel.width spacing: _margins QGCLabel { @@ -62,9 +63,10 @@ QGCView { } Loader { + id: pageLoader anchors.topMargin: _margins anchors.top: headingColumn.bottom - id: pageLoader + } } } diff --git a/src/AutoPilotPlugins/PX4/AirframeComponent.cc b/src/AutoPilotPlugins/PX4/AirframeComponent.cc index e4b05ff1d..2f30fc2cb 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponent.cc +++ b/src/AutoPilotPlugins/PX4/AirframeComponent.cc @@ -113,7 +113,7 @@ QString AirframeComponent::name(void) const QString AirframeComponent::description(void) const { - return tr("The Airframe Component is used to select the airframe which matches your vehicle. " + return tr("Airframe Setup is used to select the airframe which matches your vehicle. " "This will in turn set up the various tuning values for flight parameters."); } diff --git a/src/AutoPilotPlugins/PX4/AirframeComponent.qml b/src/AutoPilotPlugins/PX4/AirframeComponent.qml index 4c540b40b..0c049b517 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponent.qml +++ b/src/AutoPilotPlugins/PX4/AirframeComponent.qml @@ -20,140 +20,131 @@ import QGroundControl.Controls 1.0 import QGroundControl.Controllers 1.0 import QGroundControl.ScreenTools 1.0 -QGCView { - id: qgcView - viewPanel: panel - - QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled } - - property real _minW: ScreenTools.defaultFontPixelWidth * 30 - property real _boxWidth: _minW - property real _boxSpace: ScreenTools.defaultFontPixelWidth - - function computeDimensions() { - var sw = 0 - var rw = 0 - var idx = Math.floor(scroll.width / (_minW + ScreenTools.defaultFontPixelWidth)) - if(idx < 1) { - _boxWidth = scroll.width - _boxSpace = 0 - } else { - _boxSpace = 0 - if(idx > 1) { - _boxSpace = ScreenTools.defaultFontPixelWidth - sw = _boxSpace * (idx - 1) - } - rw = scroll.width - sw - _boxWidth = rw / idx - } - } - - AirframeComponentController { - id: controller - factPanel: panel - - Component.onCompleted: { - if (controller.showCustomConfigPanel) { - showDialog(customConfigDialogComponent, qsTr("Custom Airframe Config"), qgcView.showDialogDefaultWidth, StandardButton.Reset) - } - } - } +SetupPage { + id: airframePage + pageComponent: pageComponent Component { - id: customConfigDialogComponent + id: pageComponent - QGCViewMessage { - id: customConfigDialog - message: qsTr("Your vehicle is using a custom airframe configuration. ") + - qsTr("This configuration can only be modified through the Parameter Editor.\n\n") + - qsTr("If you want to reset your airframe configuration and select a standard configuration, click 'Reset' above.") + Column { + id: mainColumn + width: availableWidth - property Fact sys_autostart: controller.getParameterFact(-1, "SYS_AUTOSTART") + property real _minW: ScreenTools.defaultFontPixelWidth * 30 + property real _boxWidth: _minW + property real _boxSpace: ScreenTools.defaultFontPixelWidth - function accept() { - sys_autostart.value = 0 - customConfigDialog.hideDialog() + readonly property real spacerHeight: ScreenTools.defaultFontPixelHeight + + onWidthChanged: { + computeDimensions() } - } - } - Component { - id: applyRestartDialogComponent + Component.onCompleted: computeDimensions() + + function computeDimensions() { + var sw = 0 + var rw = 0 + var idx = Math.floor(mainColumn.width / (_minW + ScreenTools.defaultFontPixelWidth)) + if(idx < 1) { + _boxWidth = mainColumn.width + _boxSpace = 0 + } else { + _boxSpace = 0 + if(idx > 1) { + _boxSpace = ScreenTools.defaultFontPixelWidth + sw = _boxSpace * (idx - 1) + } + rw = mainColumn.width - sw + _boxWidth = rw / idx + } + } - QGCViewDialog { - id: applyRestartDialog + AirframeComponentController { + id: controller + factPanel: airframePage.viewPanel - function accept() { - controller.changeAutostart() - applyRestartDialog.hideDialog() + Component.onCompleted: { + if (controller.showCustomConfigPanel) { + showDialog(customConfigDialogComponent, qsTr("Custom Airframe Config"), qgcView.showDialogDefaultWidth, StandardButton.Reset) + } + } } - QGCLabel { - anchors.fill: parent - wrapMode: Text.WordWrap - text: qsTr("Clicking “Apply” will save the changes you have made to your airframe configuration. ") + - qsTr("Your vehicle will also be restarted in order to complete the process.") + Component { + id: customConfigDialogComponent + + QGCViewMessage { + id: customConfigDialog + message: qsTr("Your vehicle is using a custom airframe configuration. ") + + qsTr("This configuration can only be modified through the Parameter Editor.\n\n") + + qsTr("If you want to reset your airframe configuration and select a standard configuration, click 'Reset' above.") + + property Fact sys_autostart: controller.getParameterFact(-1, "SYS_AUTOSTART") + + function accept() { + sys_autostart.value = 0 + customConfigDialog.hideDialog() + } + } } - } - } - - QGCViewPanel { - id: panel - anchors.fill: parent - - readonly property real spacerHeight: ScreenTools.defaultFontPixelHeight - - Item { - id: helpApplyRow - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - height: Math.max(helpText.contentHeight, applyButton.height) - - QGCLabel { - id: helpText - width: parent.width - applyButton.width - 5 - text: (controller.currentVehicleName != "" ? - qsTr("You've connected a %1.").arg(controller.currentVehicleName) : - qsTr("Airframe is not set.")) + - qsTr("To change this configuration, select the desired airframe below then click “Apply and Restart”.") - font.family: ScreenTools.demiboldFontFamily - wrapMode: Text.WordWrap + + Component { + id: applyRestartDialogComponent + + QGCViewDialog { + id: applyRestartDialog + + function accept() { + controller.changeAutostart() + applyRestartDialog.hideDialog() + } + + QGCLabel { + anchors.fill: parent + wrapMode: Text.WordWrap + text: qsTr("Clicking “Apply” will save the changes you have made to your airframe configuration. ") + + qsTr("Your vehicle will also be restarted in order to complete the process.") + } + } } - QGCButton { - id: applyButton + Item { + id: helpApplyRow + anchors.left: parent.left anchors.right: parent.right - text: qsTr("Apply and Restart") + height: Math.max(helpText.contentHeight, applyButton.height) + + QGCLabel { + id: helpText + width: parent.width - applyButton.width - 5 + text: (controller.currentVehicleName != "" ? + qsTr("You've connected a %1.").arg(controller.currentVehicleName) : + qsTr("Airframe is not set.")) + + qsTr("To change this configuration, select the desired airframe below then click “Apply and Restart”.") + font.family: ScreenTools.demiboldFontFamily + wrapMode: Text.WordWrap + } + + QGCButton { + id: applyButton + anchors.right: parent.right + text: qsTr("Apply and Restart") - onClicked: showDialog(applyRestartDialogComponent, qsTr("Apply and Restart"), qgcView.showDialogDefaultWidth, StandardButton.Apply | StandardButton.Cancel) + onClicked: showDialog(applyRestartDialogComponent, qsTr("Apply and Restart"), qgcView.showDialogDefaultWidth, StandardButton.Apply | StandardButton.Cancel) + } } - } - - Item { - id: lastSpacer - anchors.top: helpApplyRow.bottom - height: parent.spacerHeight - width: 10 - } - - QGCFlickable { - id: scroll - anchors.top: lastSpacer.bottom - anchors.bottom: parent.bottom - width: parent.width - clip: true - contentHeight: flowView.height - contentWidth: parent.width - flickableDirection: Flickable.VerticalFlick - onWidthChanged: { - computeDimensions() + Item { + id: lastSpacer + height: parent.spacerHeight + width: 10 } Flow { id: flowView - width: scroll.width + width: parent.width spacing: _boxSpace ExclusiveGroup { @@ -246,6 +237,6 @@ QGCView { } } // Repeater - summary boxes } // Flow - summary boxes - } // Scroll View - summary boxes - } // QGCViewPanel -} // QGCView + } // Column + } // Component +} // SetupPage diff --git a/src/AutoPilotPlugins/PX4/CameraComponent.cc b/src/AutoPilotPlugins/PX4/CameraComponent.cc index 912489463..47d445ac5 100644 --- a/src/AutoPilotPlugins/PX4/CameraComponent.cc +++ b/src/AutoPilotPlugins/PX4/CameraComponent.cc @@ -29,7 +29,7 @@ QString CameraComponent::name(void) const QString CameraComponent::description(void) const { - return tr("The Camera is used to setup the camera modes and hardware configuration to use it."); + return tr("Camera setup is used to adjust camera and gimbal settings."); } QString CameraComponent::iconResource(void) const diff --git a/src/AutoPilotPlugins/PX4/CameraComponent.qml b/src/AutoPilotPlugins/PX4/CameraComponent.qml index 09034962e..7b523f5a1 100644 --- a/src/AutoPilotPlugins/PX4/CameraComponent.qml +++ b/src/AutoPilotPlugins/PX4/CameraComponent.qml @@ -17,99 +17,90 @@ import QtGraphicalEffects 1.0 import QGroundControl 1.0 import QGroundControl.FactSystem 1.0 import QGroundControl.FactControls 1.0 -import QGroundControl.Palette 1.0 import QGroundControl.Controls 1.0 import QGroundControl.ScreenTools 1.0 -QGCView { - id: _cameraView - viewPanel: panel - anchors.fill: parent +SetupPage { + id: cameraPage + pageComponent: pageComponent - FactPanelController { id: controller; factPanel: panel } + Component { + id: pageComponent - QGCPalette { id: palette; colorGroupEnabled: enabled } + Column { + width: availableWidth - property real _margins: ScreenTools.defaultFontPixelHeight - property real _middleRowWidth: ScreenTools.defaultFontPixelWidth * 16 - property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 16 + FactPanelController { id: controller; factPanel: cameraPage.viewPanel } - property Fact _camTriggerMode: controller.getParameterFact(-1, "TRIG_MODE") - property Fact _camTriggerInterface: controller.getParameterFact(-1, "TRIG_INTERFACE", false) - property Fact _camTriggerPol: controller.getParameterFact(-1, "TRIG_POLARITY", false) // Don't bitch about missing as these only exist if trigger mode is enabled - property Fact _auxPins: controller.getParameterFact(-1, "TRIG_PINS", false) // Ditto + property real _margins: ScreenTools.defaultFontPixelHeight + property real _middleRowWidth: ScreenTools.defaultFontPixelWidth * 16 + property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 16 - property bool _rebooting: false - property var _auxChannels: [ 0, 0, 0, 0, 0, 0] + property Fact _camTriggerMode: controller.getParameterFact(-1, "TRIG_MODE") + property Fact _camTriggerInterface: controller.getParameterFact(-1, "TRIG_INTERFACE", false) + property Fact _camTriggerPol: controller.getParameterFact(-1, "TRIG_POLARITY", false) // Don't bitch about missing as these only exist if trigger mode is enabled + property Fact _auxPins: controller.getParameterFact(-1, "TRIG_PINS", false) // Ditto - function clearAuxArray() { - for(var i = 0; i < 6; i++) { - _auxChannels[i] = 0 - } - } + property bool _rebooting: false + property var _auxChannels: [ 0, 0, 0, 0, 0, 0] - function setAuxPins() { - if(_auxPins) { - var values = "" - for(var i = 0; i < 6; i++) { - if(_auxChannels[i]) { - values += ((i+1).toString()) + function clearAuxArray() { + for(var i = 0; i < 6; i++) { + _auxChannels[i] = 0 } } - _auxPins.value = parseInt(values) - } - } - Component.onCompleted: { - if(_auxPins) { - clearAuxArray() - var values = _auxPins.value.toString() - for(var i = 0; i < values.length; i++) { - var b = parseInt(values[i]) - 1 - if(b >= 0 && b < 6) { - _auxChannels[b] = 1 + function setAuxPins() { + if(_auxPins) { + var values = "" + for(var i = 0; i < 6; i++) { + if(_auxChannels[i]) { + values += ((i+1).toString()) + } + } + _auxPins.value = parseInt(values) } } - } - } - QGCViewPanel { - id: panel - anchors.fill: parent - Item { - id: applyAndRestart - visible: false - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 10 - anchors.rightMargin: ScreenTools.defaultFontPixelWidth * 10 - height: applyButton.height - QGCLabel { - anchors.left: parent.left - text: qsTr("Vehicle must be restarted for changes to take effect. ") + Component.onCompleted: { + if(_auxPins) { + clearAuxArray() + var values = _auxPins.value.toString() + for(var i = 0; i < values.length; i++) { + var b = parseInt(values[i]) - 1 + if(b >= 0 && b < 6) { + _auxChannels[b] = 1 + } + } + } } - QGCButton { - id: applyButton - anchors.right: parent.right - text: qsTr("Apply and Restart") - onClicked: { - //-- This will reboot the vehicle! We're set not to allow changes if armed. - QGroundControl.multiVehicleManager.activeVehicle.rebootVehicle() - applyAndRestart.visible = false - _rebooting = true + + Item { + id: applyAndRestart + visible: false + anchors.left: parent.left + anchors.right: parent.right + anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 10 + anchors.rightMargin: ScreenTools.defaultFontPixelWidth * 10 + height: applyButton.height + QGCLabel { + anchors.left: parent.left + text: qsTr("Vehicle must be restarted for changes to take effect. ") + } + QGCButton { + id: applyButton + anchors.right: parent.right + text: qsTr("Apply and Restart") + onClicked: { + //-- This will reboot the vehicle! We're set not to allow changes if armed. + QGroundControl.multiVehicleManager.activeVehicle.rebootVehicle() + applyAndRestart.visible = false + _rebooting = true + } } } - } - QGCFlickable { - clip: true - anchors.top: applyAndRestart.visible ? applyAndRestart.bottom : parent.top - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - contentHeight: mainCol.height - flickableDirection: Flickable.VerticalFlick + Column { id: mainCol spacing: _margins @@ -123,7 +114,7 @@ QGCView { } Rectangle { id: camTrigRect - color: palette.windowShade + color: qgcPal.windowShade width: camTrigRow.width + _margins * 2 height: camTrigRow.height + _margins * 2 Row { @@ -132,7 +123,7 @@ QGCView { anchors.verticalCenter: parent.verticalCenter Item { width: _margins * 0.5; height: 1; } QGCColoredImage { - color: palette.text + color: qgcPal.text height: ScreenTools.defaultFontPixelWidth * 10 width: ScreenTools.defaultFontPixelWidth * 20 sourceSize.width: width @@ -185,7 +176,7 @@ QGCView { text: qsTr("Time Interval") width: _middleRowWidth anchors.baseline: timeIntervalField.baseline - color: palette.text + color: qgcPal.text } FactTextField { id: timeIntervalField @@ -200,7 +191,7 @@ QGCView { text: qsTr("Distance Interval") width: _middleRowWidth anchors.baseline: trigDistField.baseline - color: palette.text + color: qgcPal.text } FactTextField { id: trigDistField @@ -223,7 +214,7 @@ QGCView { visible: _auxPins } Rectangle { - color: palette.windowShade + color: qgcPal.windowShade width: camTrigRect.width height: camHardwareRow.height + _margins * 2 visible: _auxPins @@ -251,31 +242,31 @@ QGCView { spacing: ScreenTools.defaultFontPixelWidth * 0.5 QGCLabel { text: model.index + 1 - color: palette.text + color: qgcPal.text anchors.horizontalCenter: parent.horizontalCenter } Rectangle { id: auxPin width: ScreenTools.defaultFontPixelWidth * 2 height: ScreenTools.defaultFontPixelWidth * 2 - border.color: palette.text + border.color: qgcPal.text color: { if(_auxPins) { var pins = _auxPins.value.toString() var pin = (model.index + 1).toString() if(pins.indexOf(pin) < 0) - return palette.windowShadeDark + return qgcPal.windowShadeDark else return "green" } else { - return palette.windowShade + return qgcPal.windowShade } } MouseArea { anchors.fill: parent onClicked: { _auxChannels[model.index] = 1 - _auxChannels[model.index] - auxPin.color = _auxChannels[model.index] ? "green" : palette.windowShadeDark + auxPin.color = _auxChannels[model.index] ? "green" : qgcPal.windowShadeDark setAuxPins() } } @@ -327,7 +318,7 @@ QGCView { text: qsTr("Trigger Period") width: _middleRowWidth anchors.baseline: trigPeriodField.baseline - color: palette.text + color: qgcPal.text } FactTextField { id: trigPeriodField @@ -343,4 +334,3 @@ QGCView { } } } - diff --git a/src/AutoPilotPlugins/PX4/FlightModesComponent.cc b/src/AutoPilotPlugins/PX4/FlightModesComponent.cc index b117745d3..38e39a7a5 100644 --- a/src/AutoPilotPlugins/PX4/FlightModesComponent.cc +++ b/src/AutoPilotPlugins/PX4/FlightModesComponent.cc @@ -33,9 +33,7 @@ QString FlightModesComponent::name(void) const QString FlightModesComponent::description(void) const { - // FIXME: Better text - return tr("The Flight Modes Component is used to set the switches associated with Flight Modes. " - "At a minimum the Main Mode Switch must be assigned prior to flight."); + return tr("Flight Modes Setup is used to configure the transmitter switches associated with Flight Modes."); } QString FlightModesComponent::iconResource(void) const diff --git a/src/AutoPilotPlugins/PX4/PX4AdvancedFlightModes.qml b/src/AutoPilotPlugins/PX4/PX4AdvancedFlightModes.qml index e63d57d0f..fc75d7fcd 100644 --- a/src/AutoPilotPlugins/PX4/PX4AdvancedFlightModes.qml +++ b/src/AutoPilotPlugins/PX4/PX4AdvancedFlightModes.qml @@ -91,8 +91,6 @@ Item { readonly property real modeSpacing: ScreenTools.defaultFontPixelHeight / 3 - QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled } - PX4AdvancedFlightModesController { id: controller factPanel: qgcViewPanel diff --git a/src/AutoPilotPlugins/PX4/PX4FlightModes.qml b/src/AutoPilotPlugins/PX4/PX4FlightModes.qml index 23fb72c3d..dad5c931c 100644 --- a/src/AutoPilotPlugins/PX4/PX4FlightModes.qml +++ b/src/AutoPilotPlugins/PX4/PX4FlightModes.qml @@ -23,33 +23,31 @@ import QGroundControl.ScreenTools 1.0 /// PX4 Flight Mode configuration. This control will load either the Simple or Advanced Flight Mode config /// based on current parameter settings. -QGCView { - id: rootQGCView - viewPanel: panel +SetupPage { + id: flightModesPage + pageComponent: pageComponent - property Fact _nullFact - property bool _rcMapFltmodeExists: controller.parameterExists(-1, "RC_MAP_FLTMODE") - property Fact _rcMapFltmode: _rcMapFltmodeExists ? controller.getParameterFact(-1, "RC_MAP_FLTMODE") : _nullFact - property Fact _rcMapModeSw: controller.getParameterFact(-1, "RC_MAP_MODE_SW") - property bool _simpleMode: _rcMapFltmodeExists ? _rcMapFltmode.value > 0 || _rcMapModeSw.value == 0 : false - - QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled } - - FactPanelController { - id: controller - factPanel: panel - } - - QGCViewPanel { - id: panel - anchors.fill: parent + Component { + id: pageComponent Loader { - anchors.fill: parent - source: _simpleMode ? "qrc:/qml/PX4SimpleFlightModes.qml" : "qrc:/qml/PX4AdvancedFlightModes.qml" - - property var qgcView: rootQGCView - property var qgcViewPanel: panel + width: availableWidth + height: availableHeight + source: _simpleMode ? "qrc:/qml/PX4SimpleFlightModes.qml" : "qrc:/qml/PX4AdvancedFlightModes.qml" + + property Fact _nullFact + property bool _rcMapFltmodeExists: controller.parameterExists(-1, "RC_MAP_FLTMODE") + property Fact _rcMapFltmode: _rcMapFltmodeExists ? controller.getParameterFact(-1, "RC_MAP_FLTMODE") : _nullFact + property Fact _rcMapModeSw: controller.getParameterFact(-1, "RC_MAP_MODE_SW") + property bool _simpleMode: _rcMapFltmodeExists ? _rcMapFltmode.value > 0 || _rcMapModeSw.value == 0 : false + + FactPanelController { + id: controller + factPanel: flightModesPage.viewPanel + } + + property var qgcView: flightModesPage + property var qgcViewPanel: flightModesPage.viewPanel } - } // QGCViewPanel -} // QGCView + } +} diff --git a/src/AutoPilotPlugins/PX4/PX4RadioComponent.cc b/src/AutoPilotPlugins/PX4/PX4RadioComponent.cc index ffbce79bd..1b2ca3596 100644 --- a/src/AutoPilotPlugins/PX4/PX4RadioComponent.cc +++ b/src/AutoPilotPlugins/PX4/PX4RadioComponent.cc @@ -24,9 +24,8 @@ QString PX4RadioComponent::name(void) const QString PX4RadioComponent::description(void) const { - return tr("The Radio Component is used to setup which channels on your RC Transmitter you will use for each vehicle control such as Roll, Pitch, Yaw and Throttle. " - "It also allows you to assign switches and dials to the various flight modes. " - "Prior to flight you must also calibrate the extents for all of your channels."); + return tr("Radio Setup is used to calibrate your transmitter. " + "It also assign channels for Roll, Pitch, Yaw and Throttle vehicle control as well as determining whether they are reversed."); } QString PX4RadioComponent::iconResource(void) const diff --git a/src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml b/src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml index 81247615a..8146a048a 100644 --- a/src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml +++ b/src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml @@ -30,8 +30,6 @@ Item { readonly property real _flightModeComboWidth: ScreenTools.defaultFontPixelWidth * 13 readonly property real _channelComboWidth: ScreenTools.defaultFontPixelWidth * 13 - QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled } - PX4SimpleFlightModesController { id: controller factPanel: qgcViewPanel diff --git a/src/AutoPilotPlugins/PX4/PX4TuningComponent.cc b/src/AutoPilotPlugins/PX4/PX4TuningComponent.cc index 9a1f140ee..465f2b6f6 100644 --- a/src/AutoPilotPlugins/PX4/PX4TuningComponent.cc +++ b/src/AutoPilotPlugins/PX4/PX4TuningComponent.cc @@ -25,7 +25,7 @@ QString PX4TuningComponent::name(void) const QString PX4TuningComponent::description(void) const { - return tr("The Tuning Component is used to tune the flight characteristics of the Vehicle."); + return tr("Tuning Setup is used to tune the flight characteristics of the Vehicle."); } QString PX4TuningComponent::iconResource(void) const diff --git a/src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml b/src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml index 5e6675827..e2d484e1b 100644 --- a/src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml +++ b/src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml @@ -13,63 +13,72 @@ import QtQuick.Controls 1.4 import QGroundControl.Controls 1.0 -FactSliderPanel { - anchors.fill: parent - panelTitle: "Tuning" +SetupPage { + id: tuningPage + pageComponent: pageComponent - sliderModel: ListModel { - ListElement { - title: qsTr("Hover Throttle") - description: qsTr("Adjust throttle so hover is at mid-throttle. Slide to the left if hover is lower than throttle center. Slide to the right if hover is higher than throttle center.") - param: "MPC_THR_HOVER" - min: 20 - max: 80 - step: 1 - } + Component { + id: pageComponent - ListElement { - title: qsTr("Manual minimum throttle") - description: qsTr("Slide to the left to start the motors with less idle power. Slide to the right if descending in manual flight becomes unstable.") - param: "MPC_MANTHR_MIN" - min: 0 - max: 15 - step: 1 - } + FactSliderPanel { + width: availableWidth + qgcViewPanel: tuningPage.viewPanel - ListElement { - title: qsTr("Roll sensitivity") - description: qsTr("Slide to the left to make roll control faster and more accurate. Slide to the right if roll oscillates or is too twitchy.") - param: "MC_ROLL_TC" - min: 0.15 - max: 0.25 - step: 0.01 - } + sliderModel: ListModel { + ListElement { + title: qsTr("Hover Throttle") + description: qsTr("Adjust throttle so hover is at mid-throttle. Slide to the left if hover is lower than throttle center. Slide to the right if hover is higher than throttle center.") + param: "MPC_THR_HOVER" + min: 20 + max: 80 + step: 1 + } - ListElement { - title: qsTr("Pitch sensitivity") - description: qsTr("Slide to the left to make pitch control faster and more accurate. Slide to the right if pitch oscillates or is too twitchy.") - param: "MC_PITCH_TC" - min: 0.15 - max: 0.25 - step: 0.01 - } + ListElement { + title: qsTr("Manual minimum throttle") + description: qsTr("Slide to the left to start the motors with less idle power. Slide to the right if descending in manual flight becomes unstable.") + param: "MPC_MANTHR_MIN" + min: 0 + max: 15 + step: 1 + } - ListElement { - title: qsTr("Altitude control sensitivity") - description: qsTr("Slide to the left to make altitude control smoother and less twitchy. Slide to the right to make altitude control more accurate and more aggressive.") - param: "MPC_Z_FF" - min: 0 - max: 1.0 - step: 0.1 - } + ListElement { + title: qsTr("Roll sensitivity") + description: qsTr("Slide to the left to make roll control faster and more accurate. Slide to the right if roll oscillates or is too twitchy.") + param: "MC_ROLL_TC" + min: 0.15 + max: 0.25 + step: 0.01 + } + + ListElement { + title: qsTr("Pitch sensitivity") + description: qsTr("Slide to the left to make pitch control faster and more accurate. Slide to the right if pitch oscillates or is too twitchy.") + param: "MC_PITCH_TC" + min: 0.15 + max: 0.25 + step: 0.01 + } + + ListElement { + title: qsTr("Altitude control sensitivity") + description: qsTr("Slide to the left to make altitude control smoother and less twitchy. Slide to the right to make altitude control more accurate and more aggressive.") + param: "MPC_Z_FF" + min: 0 + max: 1.0 + step: 0.1 + } - ListElement { - title: qsTr("Position control sensitivity") - description: qsTr("Slide to the left to make flight in position control mode smoother and less twitchy. Slide to the right to make position control more accurate and more aggressive.") - param: "MPC_XY_FF" - min: 0 - max: 1.0 - step: 0.1 + ListElement { + title: qsTr("Position control sensitivity") + description: qsTr("Slide to the left to make flight in position control mode smoother and less twitchy. Slide to the right to make position control more accurate and more aggressive.") + param: "MPC_XY_FF" + min: 0 + max: 1.0 + step: 0.1 + } + } } - } -} + } // Component +} // SetupPage diff --git a/src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml b/src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml index 73d5599a0..4c1eed32a 100644 --- a/src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml +++ b/src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml @@ -13,44 +13,54 @@ import QtQuick.Controls 1.4 import QGroundControl.Controls 1.0 -FactSliderPanel { - anchors.fill: parent - - sliderModel: ListModel { - ListElement { - title: "Roll sensitivity" - description: "Slide to the left to make roll control faster and more accurate. Slide to the right if roll oscillates or is too twitchy." - param: "FW_R_TC" - min: 0.2 - max: 0.8 - step: 0.01 - } +SetupPage { + id: tuningPage + pageComponent: pageComponent - ListElement { - title: "Pitch sensitivity" - description: "Slide to the left to make pitch control faster and more accurate. Slide to the right if pitch oscillates or is too twitchy." - param: "FW_P_TC" - min: 0.2 - max: 0.8 - step: 0.01 - } + Component { + id: pageComponent - ListElement { - title: "Cruise throttle" - description: "This is the throttle setting required to achieve the desired cruise speed. Most planes need 50-60%." - param: "FW_THR_CRUISE" - min: 20 - max: 80 - step: 1 - } + FactSliderPanel { + width: availableWidth + qgcViewPanel: tuningPage.viewPanel + + sliderModel: ListModel { + ListElement { + title: "Roll sensitivity" + description: "Slide to the left to make roll control faster and more accurate. Slide to the right if roll oscillates or is too twitchy." + param: "FW_R_TC" + min: 0.2 + max: 0.8 + step: 0.01 + } + + ListElement { + title: "Pitch sensitivity" + description: "Slide to the left to make pitch control faster and more accurate. Slide to the right if pitch oscillates or is too twitchy." + param: "FW_P_TC" + min: 0.2 + max: 0.8 + step: 0.01 + } + + ListElement { + title: "Cruise throttle" + description: "This is the throttle setting required to achieve the desired cruise speed. Most planes need 50-60%." + param: "FW_THR_CRUISE" + min: 20 + max: 80 + step: 1 + } - ListElement { - title: "Mission mode sensitivity" - description: "Slide to the left to make position control more accurate and more aggressive. Slide to the right to make flight in mission mode smoother and less twitchy." - param: "FW_L1_PERIOD" - min: 12 - max: 50 - step: 0.5 + ListElement { + title: "Mission mode sensitivity" + description: "Slide to the left to make position control more accurate and more aggressive. Slide to the right to make flight in mission mode smoother and less twitchy." + param: "FW_L1_PERIOD" + min: 12 + max: 50 + step: 0.5 + } + } } } } diff --git a/src/AutoPilotPlugins/PX4/PX4TuningComponentVTOL.qml b/src/AutoPilotPlugins/PX4/PX4TuningComponentVTOL.qml index 1ba6e8aa1..e715c2a6c 100644 --- a/src/AutoPilotPlugins/PX4/PX4TuningComponentVTOL.qml +++ b/src/AutoPilotPlugins/PX4/PX4TuningComponentVTOL.qml @@ -13,98 +13,108 @@ import QtQuick.Controls 1.4 import QGroundControl.Controls 1.0 -FactSliderPanel { - anchors.fill: parent - - sliderModel: ListModel { - - ListElement { - title: qsTr("Hover Roll sensitivity") - description: qsTr("Slide to the left to make roll control during hover faster and more accurate. Slide to the right if roll oscillates or is too twitchy.") - param: "MC_ROLL_TC" - min: 0.15 - max: 0.25 - step: 0.01 - } +SetupPage { + id: tuningPage + pageComponent: pageComponent - ListElement { - title: qsTr("Hover Pitch sensitivity") - description: qsTr("Slide to the left to make pitch control during hover faster and more accurate. Slide to the right if pitch oscillates or is too twitchy.") - param: "MC_PITCH_TC" - min: 0.15 - max: 0.25 - step: 0.01 - } + Component { + id: pageComponent - ListElement { - title: qsTr("Hover Altitude control sensitivity") - description: qsTr("Slide to the left to make altitude control during hover smoother and less twitchy. Slide to the right to make altitude control more accurate and more aggressive.") - param: "MPC_Z_FF" - min: 0 - max: 1.0 - step: 0.1 - } + FactSliderPanel { + width: availableWidth + qgcViewPanel: tuningPage.viewPanel - ListElement { - title: qsTr("Hover Position control sensitivity") - description: qsTr("Slide to the left to make flight during hover in position control mode smoother and less twitchy. Slide to the right to make position control more accurate and more aggressive.") - param: "MPC_XY_FF" - min: 0 - max: 1.0 - step: 0.1 - } - ListElement { - title: qsTr("Plane Roll sensitivity") - description: qsTr("Slide to the left to make roll control faster and more accurate. Slide to the right if roll oscillates or is too twitchy.") - param: "FW_R_TC" - min: 0.2 - max: 0.8 - step: 0.01 - } + sliderModel: ListModel { - ListElement { - title: qsTr("Plane Pitch sensitivity") - description: qsTr("Slide to the left to make pitch control faster and more accurate. Slide to the right if pitch oscillates or is too twitchy.") - param: "FW_P_TC" - min: 0.2 - max: 0.8 - step: 0.01 - } + ListElement { + title: qsTr("Hover Roll sensitivity") + description: qsTr("Slide to the left to make roll control during hover faster and more accurate. Slide to the right if roll oscillates or is too twitchy.") + param: "MC_ROLL_TC" + min: 0.15 + max: 0.25 + step: 0.01 + } - ListElement { - title: qsTr("Plane Cruise throttle") - description: qsTr("This is the throttle setting required to achieve the desired cruise speed. Most planes need 50-60%.") - param: "FW_THR_CRUISE" - min: 20 - max: 80 - step: 1 - } + ListElement { + title: qsTr("Hover Pitch sensitivity") + description: qsTr("Slide to the left to make pitch control during hover faster and more accurate. Slide to the right if pitch oscillates or is too twitchy.") + param: "MC_PITCH_TC" + min: 0.15 + max: 0.25 + step: 0.01 + } - ListElement { - title: qsTr("Hover Throttle") - description: qsTr("Adjust throttle so hover is at mid-throttle. Slide to the left if hover is lower than throttle center. Slide to the right if hover is higher than throttle center.") - param: "MPC_THR_HOVER" - min: 20 - max: 80 - step: 1 - } + ListElement { + title: qsTr("Hover Altitude control sensitivity") + description: qsTr("Slide to the left to make altitude control during hover smoother and less twitchy. Slide to the right to make altitude control more accurate and more aggressive.") + param: "MPC_Z_FF" + min: 0 + max: 1.0 + step: 0.1 + } - ListElement { - title: qsTr("Hoever manual minimum throttle") - description: qsTr("Slide to the left to start the motors with less idle power. Slide to the right if descending in manual flight becomes unstable.") - param: "MPC_MANTHR_MIN" - min: 0 - max: 15 - step: 1 - } + ListElement { + title: qsTr("Hover Position control sensitivity") + description: qsTr("Slide to the left to make flight during hover in position control mode smoother and less twitchy. Slide to the right to make position control more accurate and more aggressive.") + param: "MPC_XY_FF" + min: 0 + max: 1.0 + step: 0.1 + } + ListElement { + title: qsTr("Plane Roll sensitivity") + description: qsTr("Slide to the left to make roll control faster and more accurate. Slide to the right if roll oscillates or is too twitchy.") + param: "FW_R_TC" + min: 0.2 + max: 0.8 + step: 0.01 + } + + ListElement { + title: qsTr("Plane Pitch sensitivity") + description: qsTr("Slide to the left to make pitch control faster and more accurate. Slide to the right if pitch oscillates or is too twitchy.") + param: "FW_P_TC" + min: 0.2 + max: 0.8 + step: 0.01 + } + + ListElement { + title: qsTr("Plane Cruise throttle") + description: qsTr("This is the throttle setting required to achieve the desired cruise speed. Most planes need 50-60%.") + param: "FW_THR_CRUISE" + min: 20 + max: 80 + step: 1 + } + + ListElement { + title: qsTr("Hover Throttle") + description: qsTr("Adjust throttle so hover is at mid-throttle. Slide to the left if hover is lower than throttle center. Slide to the right if hover is higher than throttle center.") + param: "MPC_THR_HOVER" + min: 20 + max: 80 + step: 1 + } + + ListElement { + title: qsTr("Hoever manual minimum throttle") + description: qsTr("Slide to the left to start the motors with less idle power. Slide to the right if descending in manual flight becomes unstable.") + param: "MPC_MANTHR_MIN" + min: 0 + max: 15 + step: 1 + } - ListElement { - title: qsTr("Plane Mission mode sensitivity") - description: qsTr("Slide to the left to make position control more accurate and more aggressive. Slide to the right to make flight in mission mode smoother and less twitchy.") - param: "FW_L1_PERIOD" - min: 12 - max: 50 - step: 0.5 + ListElement { + title: qsTr("Plane Mission mode sensitivity") + description: qsTr("Slide to the left to make position control more accurate and more aggressive. Slide to the right to make flight in mission mode smoother and less twitchy.") + param: "FW_L1_PERIOD" + min: 12 + max: 50 + step: 0.5 + } + } } } } diff --git a/src/AutoPilotPlugins/PX4/PowerComponent.cc b/src/AutoPilotPlugins/PX4/PowerComponent.cc index 489a6e41a..8c91d5a77 100644 --- a/src/AutoPilotPlugins/PX4/PowerComponent.cc +++ b/src/AutoPilotPlugins/PX4/PowerComponent.cc @@ -28,7 +28,7 @@ QString PowerComponent::name(void) const QString PowerComponent::description(void) const { - return tr("The Power Component is used to setup battery parameters as well as advanced settings for propellers and magnetometer."); + return tr("Power Setup is used to setup battery parameters as well as advanced settings for propellers."); } QString PowerComponent::iconResource(void) const diff --git a/src/AutoPilotPlugins/PX4/PowerComponent.qml b/src/AutoPilotPlugins/PX4/PowerComponent.qml index 2dd15712c..1cc89d81c 100644 --- a/src/AutoPilotPlugins/PX4/PowerComponent.qml +++ b/src/AutoPilotPlugins/PX4/PowerComponent.qml @@ -19,546 +19,535 @@ import QtQuick.Layouts 1.2 import QGroundControl.FactSystem 1.0 import QGroundControl.FactControls 1.0 -import QGroundControl.Palette 1.0 import QGroundControl.Controls 1.0 import QGroundControl.ScreenTools 1.0 import QGroundControl.Controllers 1.0 -QGCView { - id: rootQGCView - viewPanel: panel - - property int textEditWidth: ScreenTools.defaultFontPixelWidth * 8 - - property Fact battNumCells: controller.getParameterFact(-1, "BAT_N_CELLS") - property Fact battHighVolt: controller.getParameterFact(-1, "BAT_V_CHARGED") - property Fact battLowVolt: controller.getParameterFact(-1, "BAT_V_EMPTY") - property Fact battVoltLoadDrop: controller.getParameterFact(-1, "BAT_V_LOAD_DROP") - property Fact battVoltageDivider: controller.getParameterFact(-1, "BAT_V_DIV") - property Fact battAmpsPerVolt: controller.getParameterFact(-1, "BAT_A_PER_V") - property Fact uavcanEnable: controller.getParameterFact(-1, "UAVCAN_ENABLE", false) - - readonly property string highlightPrefix: "" - readonly property string highlightSuffix: "" - - - function getBatteryImage() - { - switch(battNumCells.value) { - case 1: return "/qmlimages/PowerComponentBattery_01cell.svg"; - case 2: return "/qmlimages/PowerComponentBattery_02cell.svg" - case 3: return "/qmlimages/PowerComponentBattery_03cell.svg" - case 4: return "/qmlimages/PowerComponentBattery_04cell.svg" - case 5: return "/qmlimages/PowerComponentBattery_05cell.svg" - case 6: return "/qmlimages/PowerComponentBattery_06cell.svg" - default: return "/qmlimages/PowerComponentBattery_01cell.svg"; - } - } - - function drawArrowhead(ctx, x, y, radians) - { - ctx.save(); - ctx.beginPath(); - ctx.translate(x,y); - ctx.rotate(radians); - ctx.moveTo(0,0); - ctx.lineTo(5,10); - ctx.lineTo(-5,10); - ctx.closePath(); - ctx.restore(); - ctx.fill(); - } - - function drawLineWithArrow(ctx, x1, y1, x2, y2) - { - ctx.beginPath(); - ctx.moveTo(x1, y1); - ctx.lineTo(x2, y2); - ctx.stroke(); - var rd = Math.atan((y2 - y1) / (x2 - x1)); - rd += ((x2 > x1) ? 90 : -90) * Math.PI/180; - drawArrowhead(ctx, x2, y2, rd); - } - - PowerComponentController { - id: controller - factPanel: panel - - onOldFirmware: showMessage(qsTr("ESC Calibration"), qsTr("QGroundControl cannot perform ESC Calibration with this version of firmware. You will need to upgrade to a newer firmware."), StandardButton.Ok) - onNewerFirmware: showMessage(qsTr("ESC Calibration"), qsTr("QGroundControl cannot perform ESC Calibration with this version of firmware. You will need to upgrade QGroundControl."), StandardButton.Ok) - onBatteryConnected: showMessage(qsTr("ESC Calibration"), qsTr("Performing calibration. This will take a few seconds.."), 0) - onCalibrationFailed: showMessage(qsTr("ESC Calibration failed"), errorMessage, StandardButton.Ok) - onCalibrationSuccess: showMessage(qsTr("ESC Calibration"), qsTr("Calibration complete. You can disconnect your battery now if you like."), StandardButton.Ok) - onConnectBattery: showMessage(qsTr("ESC Calibration"), highlightPrefix + qsTr("WARNING: Props must be removed from vehicle prior to performing ESC calibration.") + highlightSuffix + qsTr(" Connect the battery now and calibration will begin."), 0) - onDisconnectBattery: showMessage(qsTr("ESC Calibration failed"), qsTr("You must disconnect the battery prior to performing ESC Calibration. Disconnect your battery and try again."), StandardButton.Ok) - } - - QGCPalette { id: palette; colorGroupEnabled: panel.enabled } +SetupPage { + id: powerPage + pageComponent: pageComponent Component { - id: calcVoltageDividerDlgComponent + id: pageComponent + + Column { + id: innerColumn + width: availableWidth + spacing: ScreenTools.defaultFontPixelHeight * 0.5 + + property int textEditWidth: ScreenTools.defaultFontPixelWidth * 8 + + property Fact battNumCells: controller.getParameterFact(-1, "BAT_N_CELLS") + property Fact battHighVolt: controller.getParameterFact(-1, "BAT_V_CHARGED") + property Fact battLowVolt: controller.getParameterFact(-1, "BAT_V_EMPTY") + property Fact battVoltLoadDrop: controller.getParameterFact(-1, "BAT_V_LOAD_DROP") + property Fact battVoltageDivider: controller.getParameterFact(-1, "BAT_V_DIV") + property Fact battAmpsPerVolt: controller.getParameterFact(-1, "BAT_A_PER_V") + property Fact uavcanEnable: controller.getParameterFact(-1, "UAVCAN_ENABLE", false) + + readonly property string highlightPrefix: "" + readonly property string highlightSuffix: "" + + + function getBatteryImage() + { + switch(battNumCells.value) { + case 1: return "/qmlimages/PowerComponentBattery_01cell.svg"; + case 2: return "/qmlimages/PowerComponentBattery_02cell.svg" + case 3: return "/qmlimages/PowerComponentBattery_03cell.svg" + case 4: return "/qmlimages/PowerComponentBattery_04cell.svg" + case 5: return "/qmlimages/PowerComponentBattery_05cell.svg" + case 6: return "/qmlimages/PowerComponentBattery_06cell.svg" + default: return "/qmlimages/PowerComponentBattery_01cell.svg"; + } + } + + function drawArrowhead(ctx, x, y, radians) + { + ctx.save(); + ctx.beginPath(); + ctx.translate(x,y); + ctx.rotate(radians); + ctx.moveTo(0,0); + ctx.lineTo(5,10); + ctx.lineTo(-5,10); + ctx.closePath(); + ctx.restore(); + ctx.fill(); + } + + function drawLineWithArrow(ctx, x1, y1, x2, y2) + { + ctx.beginPath(); + ctx.moveTo(x1, y1); + ctx.lineTo(x2, y2); + ctx.stroke(); + var rd = Math.atan((y2 - y1) / (x2 - x1)); + rd += ((x2 > x1) ? 90 : -90) * Math.PI/180; + drawArrowhead(ctx, x2, y2, rd); + } + + PowerComponentController { + id: controller + factPanel: powerPage.viewPanel + + onOldFirmware: showMessage(qsTr("ESC Calibration"), qsTr("QGroundControl cannot perform ESC Calibration with this version of firmware. You will need to upgrade to a newer firmware."), StandardButton.Ok) + onNewerFirmware: showMessage(qsTr("ESC Calibration"), qsTr("QGroundControl cannot perform ESC Calibration with this version of firmware. You will need to upgrade QGroundControl."), StandardButton.Ok) + onBatteryConnected: showMessage(qsTr("ESC Calibration"), qsTr("Performing calibration. This will take a few seconds.."), 0) + onCalibrationFailed: showMessage(qsTr("ESC Calibration failed"), errorMessage, StandardButton.Ok) + onCalibrationSuccess: showMessage(qsTr("ESC Calibration"), qsTr("Calibration complete. You can disconnect your battery now if you like."), StandardButton.Ok) + onConnectBattery: showMessage(qsTr("ESC Calibration"), highlightPrefix + qsTr("WARNING: Props must be removed from vehicle prior to performing ESC calibration.") + highlightSuffix + qsTr(" Connect the battery now and calibration will begin."), 0) + onDisconnectBattery: showMessage(qsTr("ESC Calibration failed"), qsTr("You must disconnect the battery prior to performing ESC Calibration. Disconnect your battery and try again."), StandardButton.Ok) + } + + Component { + id: calcVoltageDividerDlgComponent + + QGCViewDialog { + id: calcVoltageDividerDlg + + QGCFlickable { + anchors.fill: parent + contentHeight: column.height + contentWidth: column.width + + Column { + id: column + width: calcVoltageDividerDlg.width + spacing: ScreenTools.defaultFontPixelHeight - QGCViewDialog { - id: calcVoltageDividerDlg + QGCLabel { + width: parent.width + wrapMode: Text.WordWrap + text: "Measure battery voltage using an external voltmeter and enter the value below. Click Calculate to set the new voltage multiplier." + } - QGCFlickable { - anchors.fill: parent - contentHeight: column.height - contentWidth: column.width + Grid { + columns: 2 + spacing: ScreenTools.defaultFontPixelHeight / 2 + verticalItemAlignment: Grid.AlignVCenter - Column { - id: column - width: calcVoltageDividerDlg.width - spacing: ScreenTools.defaultFontPixelHeight + QGCLabel { + text: "Measured voltage:" + } + QGCTextField { id: measuredVoltage } - QGCLabel { - width: parent.width - wrapMode: Text.WordWrap - text: "Measure battery voltage using an external voltmeter and enter the value below. Click Calculate to set the new voltage multiplier." - } + QGCLabel { text: "Vehicle voltage:" } + QGCLabel { text: controller.vehicle.battery.voltage.valueString } - Grid { - columns: 2 - spacing: ScreenTools.defaultFontPixelHeight / 2 - verticalItemAlignment: Grid.AlignVCenter + QGCLabel { text: "Voltage divider:" } + FactLabel { fact: battVoltageDivider } + } - QGCLabel { - text: "Measured voltage:" - } - QGCTextField { id: measuredVoltage } + QGCButton { + text: "Calculate" + + onClicked: { + var measuredVoltageValue = parseFloat(measuredVoltage.text) + if (measuredVoltageValue == 0) { + return + } + var newVoltageDivider = (measuredVoltageValue * battVoltageDivider.value) / controller.vehicle.battery.voltage.value + if (newVoltageDivider != 0) { + battVoltageDivider.value = newVoltageDivider + } + } + } + } // Column + } // QGCFlickable + } // QGCViewDialog + } // Component - calcVoltageDividerDlgComponent - QGCLabel { text: "Vehicle voltage:" } - QGCLabel { text: controller.vehicle.battery.voltage.valueString } + Component { + id: calcAmpsPerVoltDlgComponent - QGCLabel { text: "Voltage divider:" } - FactLabel { fact: battVoltageDivider } - } + QGCViewDialog { + id: calcAmpsPerVoltDlg - QGCButton { - text: "Calculate" + QGCFlickable { + anchors.fill: parent + contentHeight: column.height + contentWidth: column.width - onClicked: { - var measuredVoltageValue = parseFloat(measuredVoltage.text) - if (measuredVoltageValue == 0) { - return - } - var newVoltageDivider = (measuredVoltageValue * battVoltageDivider.value) / controller.vehicle.battery.voltage.value - if (newVoltageDivider != 0) { - battVoltageDivider.value = newVoltageDivider + Column { + id: column + width: calcAmpsPerVoltDlg.width + spacing: ScreenTools.defaultFontPixelHeight + + QGCLabel { + width: parent.width + wrapMode: Text.WordWrap + text: "Measure current draw using an external current meter and enter the value below. Click Calculate to set the new amps per volt value." } - } - } - } // Column - } // QGCFlickable - } // QGCViewDialog - } // Component - calcVoltageDividerDlgComponent - Component { - id: calcAmpsPerVoltDlgComponent + Grid { + columns: 2 + spacing: ScreenTools.defaultFontPixelHeight / 2 + verticalItemAlignment: Grid.AlignVCenter - QGCViewDialog { - id: calcAmpsPerVoltDlg + QGCLabel { + text: "Measured current:" + } + QGCTextField { id: measuredCurrent } - QGCFlickable { - anchors.fill: parent - contentHeight: column.height - contentWidth: column.width + QGCLabel { text: "Vehicle current:" } + QGCLabel { text: controller.vehicle.battery.current.valueString } - Column { - id: column - width: calcAmpsPerVoltDlg.width - spacing: ScreenTools.defaultFontPixelHeight + QGCLabel { text: "Amps per volt:" } + FactLabel { fact: battAmpsPerVolt } + } + + QGCButton { + text: "Calculate" + + onClicked: { + var measuredCurrentValue = parseFloat(measuredCurrent.text) + if (measuredCurrentValue == 0) { + return + } + var newAmpsPerVolt = (measuredCurrentValue * battAmpsPerVolt.value) / controller.vehicle.battery.current.value + if (newAmpsPerVolt != 0) { + battAmpsPerVolt.value = newAmpsPerVolt + } + } + } + } // Column + } // QGCFlickable + } // QGCViewDialog + } // Component - calcAmpsPerVoltDlgComponent + + + QGCLabel { + text: qsTr("Battery") + font.family: ScreenTools.demiboldFontFamily + } + + Rectangle { + width: parent.width + height: batteryGrid.height + ScreenTools.defaultFontPixelHeight + color: qgcPal.windowShade + + GridLayout { + id: batteryGrid + anchors.margins: ScreenTools.defaultFontPixelHeight / 2 + anchors.left: parent.left + anchors.top: parent.top + columns: 5 + columnSpacing: ScreenTools.defaultFontPixelWidth QGCLabel { - width: parent.width - wrapMode: Text.WordWrap - text: "Measure current draw using an external current meter and enter the value below. Click Calculate to set the new amps per volt value." + text: qsTr("Number of Cells (in Series)") } - Grid { - columns: 2 - spacing: ScreenTools.defaultFontPixelHeight / 2 - verticalItemAlignment: Grid.AlignVCenter - - QGCLabel { - text: "Measured current:" - } - QGCTextField { id: measuredCurrent } - - QGCLabel { text: "Vehicle current:" } - QGCLabel { text: controller.vehicle.battery.current.valueString } - - QGCLabel { text: "Amps per volt:" } - FactLabel { fact: battAmpsPerVolt } + FactTextField { + id: cellsField + width: textEditWidth + fact: battNumCells + showUnits: true } - QGCButton { - text: "Calculate" - - onClicked: { - var measuredCurrentValue = parseFloat(measuredCurrent.text) - if (measuredCurrentValue == 0) { - return - } - var newAmpsPerVolt = (measuredCurrentValue * battAmpsPerVolt.value) / controller.vehicle.battery.current.value - if (newAmpsPerVolt != 0) { - battAmpsPerVolt.value = newAmpsPerVolt - } - } + QGCColoredImage { + id: batteryImage + Layout.rowSpan: 3 + width: height * 0.75 + height: 100 + sourceSize.height: height + fillMode: Image.PreserveAspectFit + smooth: true + color: qgcPal.text + cache: false + source: getBatteryImage(); } - } // Column - } // QGCFlickable - } // QGCViewDialog - } // Component - calcAmpsPerVoltDlgComponent - - QGCViewPanel { - id: panel - anchors.fill: parent - - QGCFlickable { - anchors.fill: parent - clip: true - contentHeight: innerColumn.height - contentWidth: panel.width - flickableDirection: Flickable.VerticalFlick - - Column { - id: innerColumn - width: parent.width - spacing: ScreenTools.defaultFontPixelHeight * 0.5 - - QGCLabel { - text: qsTr("Battery") - font.family: ScreenTools.demiboldFontFamily - } - Rectangle { - width: parent.width - height: batteryGrid.height + ScreenTools.defaultFontPixelHeight - color: palette.windowShade + Item { width: 1; height: 1; Layout.columnSpan: 2 } - GridLayout { - id: batteryGrid - anchors.margins: ScreenTools.defaultFontPixelHeight / 2 - anchors.left: parent.left - anchors.top: parent.top - columns: 5 - columnSpacing: ScreenTools.defaultFontPixelWidth + QGCLabel { + id: battHighLabel + text: qsTr("Full Voltage (per cell)") + } - QGCLabel { - text: qsTr("Number of Cells (in Series)") - } + FactTextField { + id: battHighField + width: textEditWidth + fact: battHighVolt + showUnits: true + } - FactTextField { - id: cellsField - width: textEditWidth - fact: battNumCells - showUnits: true - } + QGCLabel { + text: qsTr("Battery Max:") + } - QGCColoredImage { - id: batteryImage - Layout.rowSpan: 3 - width: height * 0.75 - height: 100 - sourceSize.height: height - fillMode: Image.PreserveAspectFit - smooth: true - color: palette.text - cache: false - source: getBatteryImage(); - } + QGCLabel { + text: (battNumCells.value * battHighVolt.value).toFixed(1) + ' V' + } - Item { width: 1; height: 1; Layout.columnSpan: 2 } + QGCLabel { + id: battLowLabel + text: qsTr("Empty Voltage (per cell)") + } - QGCLabel { - id: battHighLabel - text: qsTr("Full Voltage (per cell)") - } + FactTextField { + id: battLowField + width: textEditWidth + fact: battLowVolt + showUnits: true + } - FactTextField { - id: battHighField - width: textEditWidth - fact: battHighVolt - showUnits: true - } + QGCLabel { + text: qsTr("Battery Min:") + } - QGCLabel { - text: qsTr("Battery Max:") - } + QGCLabel { + text: (battNumCells.value * battLowVolt.value).toFixed(1) + ' V' + } - QGCLabel { - text: (battNumCells.value * battHighVolt.value).toFixed(1) + ' V' - } + QGCLabel { + text: qsTr("Voltage divider") + } - QGCLabel { - id: battLowLabel - text: qsTr("Empty Voltage (per cell)") - } + FactTextField { + id: voltMultField + fact: battVoltageDivider + } - FactTextField { - id: battLowField - width: textEditWidth - fact: battLowVolt - showUnits: true - } + QGCButton { + id: voltMultCalculateButton + text: "Calculate" + onClicked: showDialog(calcVoltageDividerDlgComponent, qsTr("Calculate Voltage Divider"), powerPage.showDialogDefaultWidth, StandardButton.Close) + } - QGCLabel { - text: qsTr("Battery Min:") - } + Item { width: 1; height: 1; Layout.columnSpan: 2 } - QGCLabel { - text: (battNumCells.value * battLowVolt.value).toFixed(1) + ' V' - } + QGCLabel { + id: voltMultHelp + Layout.columnSpan: batteryGrid.columns + Layout.fillWidth: true + font.pointSize: ScreenTools.smallFontPointSize + wrapMode: Text.WordWrap + text: "If the battery voltage reported by the vehicle is largely different than the voltage read externally using a voltmeter you can adjust the voltage multiplier value to correct this. " + + "Click the Calculate button for help with calculating a new value." + } - QGCLabel { - text: qsTr("Voltage divider") - } + QGCLabel { + id: ampPerVoltLabel + text: qsTr("Amps per volt") + } - FactTextField { - id: voltMultField - fact: battVoltageDivider - } + FactTextField { + id: ampPerVoltField + fact: battAmpsPerVolt + } - QGCButton { - id: voltMultCalculateButton - text: "Calculate" - onClicked: showDialog(calcVoltageDividerDlgComponent, qsTr("Calculate Voltage Divider"), qgcView.showDialogDefaultWidth, StandardButton.Close) - } + QGCButton { + id: ampPerVoltCalculateButton + text: "Calculate" + onClicked: showDialog(calcAmpsPerVoltDlgComponent, qsTr("Calculate Amps per Volt"), powerPage.showDialogDefaultWidth, StandardButton.Close) + } - Item { width: 1; height: 1; Layout.columnSpan: 2 } + Item { width: 1; height: 1; Layout.columnSpan: 2 } - QGCLabel { - id: voltMultHelp - Layout.columnSpan: batteryGrid.columns - Layout.fillWidth: true - font.pointSize: ScreenTools.smallFontPointSize - wrapMode: Text.WordWrap - text: "If the battery voltage reported by the vehicle is largely different than the voltage read externally using a voltmeter you can adjust the voltage multiplier value to correct this. " + - "Click the Calculate button for help with calculating a new value." - } + QGCLabel { + id: ampPerVoltHelp + Layout.columnSpan: batteryGrid.columns + Layout.fillWidth: true + font.pointSize: ScreenTools.smallFontPointSize + wrapMode: Text.WordWrap + text: "If the current draw reported by the vehicle is largely different than the current read externally using a current meter you can adjust the amps per volt value to correct this. " + + "Click the Calculate button for help with calculating a new value." + } + } // Grid + } // Rectangle - Battery settings - QGCLabel { - id: ampPerVoltLabel - text: qsTr("Amps per volt") - } + QGCLabel { + text: qsTr("ESC PWM Minimum and Maximum Calibration") + font.family: ScreenTools.demiboldFontFamily + } - FactTextField { - id: ampPerVoltField - fact: battAmpsPerVolt - } + Rectangle { + width: parent.width + height: escCalColumn.height + ScreenTools.defaultFontPixelHeight + color: qgcPal.windowShade - QGCButton { - id: ampPerVoltCalculateButton - text: "Calculate" - onClicked: showDialog(calcAmpsPerVoltDlgComponent, qsTr("Calculate Amps per Volt"), qgcView.showDialogDefaultWidth, StandardButton.Close) - } + Column { + id : escCalColumn + anchors.margins: ScreenTools.defaultFontPixelHeight / 2 + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + spacing: ScreenTools.defaultFontPixelWidth - Item { width: 1; height: 1; Layout.columnSpan: 2 } + QGCLabel { + width: parent.width + color: qgcPal.warningText + wrapMode: Text.WordWrap + text: qsTr("WARNING: Propellers must be removed from vehicle prior to performing ESC calibration.") + } - QGCLabel { - id: ampPerVoltHelp - Layout.columnSpan: batteryGrid.columns - Layout.fillWidth: true - font.pointSize: ScreenTools.smallFontPointSize - wrapMode: Text.WordWrap - text: "If the current draw reported by the vehicle is largely different than the current read externally using a current meter you can adjust the amps per volt value to correct this. " + - "Click the Calculate button for help with calculating a new value." - } - } // Grid - } // Rectangle - Battery settings + QGCLabel { + text: qsTr("You must use USB connection for this operation.") + } - QGCLabel { - text: qsTr("ESC PWM Minimum and Maximum Calibration") - font.family: ScreenTools.demiboldFontFamily + QGCButton { + text: qsTr("Calibrate") + width: ScreenTools.defaultFontPixelWidth * 20 + onClicked: controller.calibrateEsc() + } } + } + + QGCCheckBox { + id: showUAVCAN + text: qsTr("Show UAVCAN Settings") + visible: uavcanEnable !== -1 + } + + QGCLabel { + text: qsTr("UAVCAN Bus Configuration") + font.family: ScreenTools.demiboldFontFamily + visible: showUAVCAN.checked + } + + Rectangle { + width: parent.width + height: uavCanConfigColumn.height + ScreenTools.defaultFontPixelHeight + color: qgcPal.windowShade + visible: showUAVCAN.checked - Rectangle { - width: parent.width - height: escCalColumn.height + ScreenTools.defaultFontPixelHeight - color: palette.windowShade + Column { + id: uavCanConfigColumn + anchors.margins: ScreenTools.defaultFontPixelHeight / 2 + anchors.left: parent.left + anchors.top: parent.top + spacing: ScreenTools.defaultFontPixelWidth + + FactCheckBox { + id: uavcanEnabledCheckBox + width: ScreenTools.defaultFontPixelWidth * 20 + fact: uavcanEnable + checkedValue: 3 + uncheckedValue: 0 + text: qsTr("Enable UAVCAN as the default MAIN output bus (requires autopilot restart)") + } + } + } - Column { - id : escCalColumn - anchors.margins: ScreenTools.defaultFontPixelHeight / 2 - anchors.left: parent.left - anchors.right: parent.right - anchors.top: parent.top - spacing: ScreenTools.defaultFontPixelWidth + QGCLabel { + text: qsTr("UAVCAN Motor Index and Direction Assignment") + font.family: ScreenTools.demiboldFontFamily + visible: showUAVCAN.checked + } - QGCLabel { - width: parent.width - color: palette.warningText - wrapMode: Text.WordWrap - text: qsTr("WARNING: Propellers must be removed from vehicle prior to performing ESC calibration.") - } + Rectangle { + width: parent.width + height: uavCanEscCalColumn.height + ScreenTools.defaultFontPixelHeight + color: qgcPal.windowShade + visible: showUAVCAN.checked + enabled: uavcanEnabledCheckBox.checked - QGCLabel { - text: qsTr("You must use USB connection for this operation.") - } + Column { + id: uavCanEscCalColumn + anchors.margins: ScreenTools.defaultFontPixelHeight / 2 + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + spacing: ScreenTools.defaultFontPixelWidth - QGCButton { - text: qsTr("Calibrate") - width: ScreenTools.defaultFontPixelWidth * 20 - onClicked: controller.calibrateEsc() - } + QGCLabel { + width: parent.width + wrapMode: Text.WordWrap + color: qgcPal.warningText + text: qsTr("WARNING: Propellers must be removed from vehicle prior to performing UAVCAN ESC configuration.") } - } - QGCCheckBox { - id: showUAVCAN - text: qsTr("Show UAVCAN Settings") - visible: uavcanEnable !== -1 - } + QGCLabel { + width: parent.width + wrapMode: Text.WordWrap + text: qsTr("ESC parameters will only be accessible in the editor after assignment.") + } - QGCLabel { - text: qsTr("UAVCAN Bus Configuration") - font.family: ScreenTools.demiboldFontFamily - visible: showUAVCAN.checked - } + QGCLabel { + width: parent.width + wrapMode: Text.WordWrap + text: qsTr("Start the process, then turn each motor into its turn direction, in the order of their motor indices.") + } - Rectangle { - width: parent.width - height: uavCanConfigColumn.height + ScreenTools.defaultFontPixelHeight - color: palette.windowShade - visible: showUAVCAN.checked - - Column { - id: uavCanConfigColumn - anchors.margins: ScreenTools.defaultFontPixelHeight / 2 - anchors.left: parent.left - anchors.top: parent.top - spacing: ScreenTools.defaultFontPixelWidth - - FactCheckBox { - id: uavcanEnabledCheckBox - width: ScreenTools.defaultFontPixelWidth * 20 - fact: uavcanEnable - checkedValue: 3 - uncheckedValue: 0 - text: qsTr("Enable UAVCAN as the default MAIN output bus (requires autopilot restart)") - } + QGCButton { + text: qsTr("Start Assignment") + width: ScreenTools.defaultFontPixelWidth * 20 + onClicked: controller.busConfigureActuators() } - } - QGCLabel { - text: qsTr("UAVCAN Motor Index and Direction Assignment") - font.family: ScreenTools.demiboldFontFamily - visible: showUAVCAN.checked + QGCButton { + text: qsTr("Stop Assignment") + width: ScreenTools.defaultFontPixelWidth * 20 + onClicked: controller.stopBusConfigureActuators() + } } + } + + QGCCheckBox { + id: showAdvanced + text: qsTr("Show Advanced Settings") + } + + QGCLabel { + text: qsTr("Advanced Power Settings") + font.family: ScreenTools.demiboldFontFamily + visible: showAdvanced.checked + } + + Rectangle { + id: batteryRectangle + width: parent.width + height: advBatteryColumn.height + ScreenTools.defaultFontPixelHeight + color: qgcPal.windowShade + visible: showAdvanced.checked - Rectangle { - width: parent.width - height: uavCanEscCalColumn.height + ScreenTools.defaultFontPixelHeight - color: palette.windowShade - visible: showUAVCAN.checked - enabled: uavcanEnabledCheckBox.checked - - Column { - id: uavCanEscCalColumn - anchors.margins: ScreenTools.defaultFontPixelHeight / 2 - anchors.left: parent.left - anchors.right: parent.right - anchors.top: parent.top - spacing: ScreenTools.defaultFontPixelWidth - - QGCLabel { - width: parent.width - wrapMode: Text.WordWrap - color: palette.warningText - text: qsTr("WARNING: Propellers must be removed from vehicle prior to performing UAVCAN ESC configuration.") - } + Column { + id: advBatteryColumn + anchors.margins: ScreenTools.defaultFontPixelHeight / 2 + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + spacing: ScreenTools.defaultFontPixelWidth - QGCLabel { - width: parent.width - wrapMode: Text.WordWrap - text: qsTr("ESC parameters will only be accessible in the editor after assignment.") - } + Row { + spacing: ScreenTools.defaultFontPixelWidth QGCLabel { - width: parent.width - wrapMode: Text.WordWrap - text: qsTr("Start the process, then turn each motor into its turn direction, in the order of their motor indices.") - } - - QGCButton { - text: qsTr("Start Assignment") - width: ScreenTools.defaultFontPixelWidth * 20 - onClicked: controller.busConfigureActuators() + text: qsTr("Voltage Drop on Full Load (per cell)") + anchors.baseline: battDropField.baseline } - QGCButton { - text: qsTr("Stop Assignment") - width: ScreenTools.defaultFontPixelWidth * 20 - onClicked: controller.stopBusConfigureActuators() + FactTextField { + id: battDropField + width: textEditWidth + fact: battVoltLoadDrop + showUnits: true } } - } - - QGCCheckBox { - id: showAdvanced - text: qsTr("Show Advanced Settings") - } - - QGCLabel { - text: qsTr("Advanced Power Settings") - font.family: ScreenTools.demiboldFontFamily - visible: showAdvanced.checked - } - - Rectangle { - id: batteryRectangle - width: parent.width - height: advBatteryColumn.height + ScreenTools.defaultFontPixelHeight - color: palette.windowShade - visible: showAdvanced.checked - - Column { - id: advBatteryColumn - anchors.margins: ScreenTools.defaultFontPixelHeight / 2 - anchors.left: parent.left - anchors.right: parent.right - anchors.top: parent.top - spacing: ScreenTools.defaultFontPixelWidth - - Row { - spacing: ScreenTools.defaultFontPixelWidth - QGCLabel { - text: qsTr("Voltage Drop on Full Load (per cell)") - anchors.baseline: battDropField.baseline - } + QGCLabel { + width: parent.width + wrapMode: Text.WordWrap + text: qsTr("Batteries show less voltage at high throttle. Enter the difference in Volts between idle throttle and full ") + + qsTr("throttle, divided by the number of battery cells. Leave at the default if unsure. ") + + highlightPrefix + qsTr("If this value is set too high, the battery might be deep discharged and damaged.") + highlightSuffix + } - FactTextField { - id: battDropField - width: textEditWidth - fact: battVoltLoadDrop - showUnits: true - } - } + Row { + spacing: ScreenTools.defaultFontPixelWidth QGCLabel { - width: parent.width - wrapMode: Text.WordWrap - text: qsTr("Batteries show less voltage at high throttle. Enter the difference in Volts between idle throttle and full ") + - qsTr("throttle, divided by the number of battery cells. Leave at the default if unsure. ") + - highlightPrefix + qsTr("If this value is set too high, the battery might be deep discharged and damaged.") + highlightSuffix + text: qsTr("Compensated Minimum Voltage:") } - Row { - spacing: ScreenTools.defaultFontPixelWidth - - QGCLabel { - text: qsTr("Compensated Minimum Voltage:") - } - - QGCLabel { - text: ((battNumCells.value * battLowVolt.value) - (battNumCells.value * battVoltLoadDrop.value)).toFixed(1) + qsTr(" V") - } + QGCLabel { + text: ((battNumCells.value * battLowVolt.value) - (battNumCells.value * battVoltLoadDrop.value)).toFixed(1) + qsTr(" V") } } - } // Rectangle - Advanced power settings - } // Column - } // QGCFlickable - } // QGCViewPanel -} // QGCView + } + } // Rectangle - Advanced power settings + } // Column + } // Component +} // SetupPage diff --git a/src/AutoPilotPlugins/PX4/SafetyComponent.cc b/src/AutoPilotPlugins/PX4/SafetyComponent.cc index 0c9648710..bfef6d246 100644 --- a/src/AutoPilotPlugins/PX4/SafetyComponent.cc +++ b/src/AutoPilotPlugins/PX4/SafetyComponent.cc @@ -27,7 +27,7 @@ QString SafetyComponent::name(void) const QString SafetyComponent::description(void) const { - return tr("The Safety Component is used to setup triggers for Return to Land as well as the settings for Return to Land itself."); + return tr("Safety Setup is used to setup triggers for Return to Land as well as the settings for Return to Land itself."); } QString SafetyComponent::iconResource(void) const diff --git a/src/AutoPilotPlugins/PX4/SafetyComponent.qml b/src/AutoPilotPlugins/PX4/SafetyComponent.qml index 09f1c2576..a5c334833 100644 --- a/src/AutoPilotPlugins/PX4/SafetyComponent.qml +++ b/src/AutoPilotPlugins/PX4/SafetyComponent.qml @@ -16,48 +16,47 @@ import QtGraphicalEffects 1.0 import QGroundControl.FactSystem 1.0 import QGroundControl.FactControls 1.0 -import QGroundControl.Palette 1.0 import QGroundControl.Controls 1.0 import QGroundControl.ScreenTools 1.0 -QGCView { - id: _safetyView - viewPanel: panel - anchors.fill: parent +SetupPage { + id: safetyPage + pageComponent: pageComponent - FactPanelController { id: controller; factPanel: panel } + Component { + id: pageComponent - QGCPalette { id: palette; colorGroupEnabled: enabled } + Item { + width: Math.max(availableWidth, mainCol.width) + height: mainCol.height - property real _margins: ScreenTools.defaultFontPixelHeight - property real _middleRowWidth: ScreenTools.defaultFontPixelWidth * 20 - property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 14 + FactPanelController { + id: controller + factPanel: safetyPage.viewPanel + } + + property real _margins: ScreenTools.defaultFontPixelHeight + property real _middleRowWidth: ScreenTools.defaultFontPixelWidth * 20 + property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 14 - property Fact _fenceAction: controller.getParameterFact(-1, "GF_ACTION") - property Fact _fenceRadius: controller.getParameterFact(-1, "GF_MAX_HOR_DIST") - property Fact _fenceAlt: controller.getParameterFact(-1, "GF_MAX_VER_DIST") - property Fact _rtlLandDelay: controller.getParameterFact(-1, "RTL_LAND_DELAY") - property Fact _lowBattAction: controller.getParameterFact(-1, "COM_LOW_BAT_ACT") - property Fact _rcLossAction: controller.getParameterFact(-1, "NAV_RCL_ACT") - property Fact _dlLossAction: controller.getParameterFact(-1, "NAV_DLL_ACT") - property Fact _disarmLandDelay: controller.getParameterFact(-1, "COM_DISARM_LAND") - property Fact _landSpeedMC: controller.getParameterFact(-1, "MPC_LAND_SPEED", false) + property Fact _fenceAction: controller.getParameterFact(-1, "GF_ACTION") + property Fact _fenceRadius: controller.getParameterFact(-1, "GF_MAX_HOR_DIST") + property Fact _fenceAlt: controller.getParameterFact(-1, "GF_MAX_VER_DIST") + property Fact _rtlLandDelay: controller.getParameterFact(-1, "RTL_LAND_DELAY") + property Fact _lowBattAction: controller.getParameterFact(-1, "COM_LOW_BAT_ACT") + property Fact _rcLossAction: controller.getParameterFact(-1, "NAV_RCL_ACT") + property Fact _dlLossAction: controller.getParameterFact(-1, "NAV_DLL_ACT") + property Fact _disarmLandDelay: controller.getParameterFact(-1, "COM_DISARM_LAND") + property Fact _landSpeedMC: controller.getParameterFact(-1, "MPC_LAND_SPEED", false) - property bool _showIcons: !ScreenTools.isTinyScreen + property bool _showIcons: !ScreenTools.isTinyScreen - QGCViewPanel { - id: panel - anchors.fill: parent - QGCFlickable { - clip: true - anchors.fill: parent - contentHeight: mainCol.height - flickableDirection: Flickable.VerticalFlick Column { id: mainCol spacing: _margins anchors.horizontalCenter: parent.horizontalCenter + /* **** Low Battery **** */ @@ -67,7 +66,7 @@ QGCView { font.family: ScreenTools.demiboldFontFamily } Rectangle { - color: palette.windowShade + color: qgcPal.windowShade width: rtlSettings.width height: lowBattRow.height + _margins * 2 Row { @@ -81,7 +80,7 @@ QGCView { sourceSize.width: width mipmap: true fillMode: Image.PreserveAspectFit - source: qgcPal.globalTheme === QGCPalette.Light ? "/qmlimages/LowBatteryLight.svg" : "/qmlimages/LowBattery.svg" + source: qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/LowBatteryLight.svg" : "/qmlimages/LowBattery.svg" anchors.verticalCenter: parent.verticalCenter visible: _showIcons } @@ -143,7 +142,7 @@ QGCView { font.family: ScreenTools.demiboldFontFamily } Rectangle { - color: palette.windowShade + color: qgcPal.windowShade width: rtlSettings.width height: rcLossRow.height + _margins * 2 Row { @@ -157,7 +156,7 @@ QGCView { sourceSize.width: width mipmap: true fillMode: Image.PreserveAspectFit - source: qgcPal.globalTheme === QGCPalette.Light ? "/qmlimages/RCLossLight.svg" : "/qmlimages/RCLoss.svg" + source: qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/RCLossLight.svg" : "/qmlimages/RCLoss.svg" anchors.verticalCenter: parent.verticalCenter visible: _showIcons } @@ -206,7 +205,7 @@ QGCView { font.family: ScreenTools.demiboldFontFamily } Rectangle { - color: palette.windowShade + color: qgcPal.windowShade width: rtlSettings.width height: dlLossRow.height + _margins * 2 Row { @@ -220,7 +219,7 @@ QGCView { sourceSize.width: width mipmap: true fillMode: Image.PreserveAspectFit - source: qgcPal.globalTheme === QGCPalette.Light ? "/qmlimages/DatalinkLossLight.svg" : "/qmlimages/DatalinkLoss.svg" + source: qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/DatalinkLossLight.svg" : "/qmlimages/DatalinkLoss.svg" anchors.verticalCenter: parent.verticalCenter visible: _showIcons } @@ -269,7 +268,7 @@ QGCView { font.family: ScreenTools.demiboldFontFamily } Rectangle { - color: palette.windowShade + color: qgcPal.windowShade width: rtlSettings.width height: geofenceRow.height + _margins * 2 Row { @@ -283,7 +282,7 @@ QGCView { sourceSize.width: width mipmap: true fillMode: Image.PreserveAspectFit - source: qgcPal.globalTheme === QGCPalette.Light ? "/qmlimages/GeoFenceLight.svg" : "/qmlimages/GeoFence.svg" + source: qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/GeoFenceLight.svg" : "/qmlimages/GeoFence.svg" anchors.verticalCenter: parent.verticalCenter visible: _showIcons } @@ -356,7 +355,7 @@ QGCView { } Rectangle { id: rtlSettings - color: palette.windowShade + color: qgcPal.windowShade width: rtlRow.width + _margins * 2 height: rtlRow.height + _margins * 2 Row { @@ -366,7 +365,7 @@ QGCView { Item { width: _margins * 0.5; height: 1; } QGCColoredImage { id: icon - color: palette.text + color: qgcPal.text height: ScreenTools.defaultFontPixelWidth * 10 width: ScreenTools.defaultFontPixelWidth * 20 sourceSize.width: width @@ -436,7 +435,7 @@ QGCView { text: qsTr("Loiter Time") width: _middleRowWidth anchors.baseline: landDelayField.baseline - color: palette.text + color: qgcPal.text enabled: homeLoiterLandRadio.checked === true } FactTextField { @@ -452,7 +451,7 @@ QGCView { text: qsTr("Loiter Altitude") width: _middleRowWidth anchors.baseline: descendField.baseline - color: palette.text + color: qgcPal.text enabled: homeLoiterLandRadio.checked === true || homeLoiterNoLandRadio.checked === true } FactTextField { @@ -474,7 +473,7 @@ QGCView { font.family: ScreenTools.demiboldFontFamily } Rectangle { - color: palette.windowShade + color: qgcPal.windowShade width: rtlSettings.width height: landModeRow.height + _margins * 2 Row { @@ -486,7 +485,7 @@ QGCView { height: 1 } QGCColoredImage { - color: palette.text + color: qgcPal.text height: ScreenTools.defaultFontPixelWidth * 13 width: ScreenTools.defaultFontPixelWidth * 20 sourceSize.width: width @@ -539,8 +538,8 @@ QGCView { } } Item { width: 1; height: _margins * 0.5; } - } - } - } -} + } // Column + } // Item + } // Component +} // SetupPage diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.cc b/src/AutoPilotPlugins/PX4/SensorsComponent.cc index 7645f81b4..7396bbffd 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.cc +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.cc @@ -33,8 +33,7 @@ QString SensorsComponent::name(void) const QString SensorsComponent::description(void) const { - return tr("The Sensors Component allows you to calibrate the sensors within your vehicle. " - "Prior to flight you must calibrate the Magnetometer, Gyroscope and Accelerometer."); + return tr("Sensors Setup is used to calibrate the sensors within your vehicle."); } QString SensorsComponent::iconResource(void) const diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.qml b/src/AutoPilotPlugins/PX4/SensorsComponent.qml index b27d85c92..e798565c4 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.qml +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.qml @@ -20,520 +20,522 @@ import QGroundControl.Controls 1.0 import QGroundControl.ScreenTools 1.0 import QGroundControl.Controllers 1.0 -QGCView { - id: qgcView - viewPanel: panel - - // Help text which is shown both in the status text area prior to pressing a cal button and in the - // pre-calibration dialog. - - readonly property string boardRotationText: qsTr("If the orientation is in the direction of flight, select ROTATION_NONE.") - readonly property string compassRotationText: qsTr("If the orientation is in the direction of flight, select ROTATION_NONE.") - - readonly property string compassHelp: qsTr("For Compass calibration you will need to rotate your vehicle through a number of positions.") - readonly property string gyroHelp: qsTr("For Gyroscope calibration you will need to place your vehicle on a surface and leave it still.") - readonly property string accelHelp: qsTr("For Accelerometer calibration you will need to place your vehicle on all six sides on a perfectly level surface and hold it still in each orientation for a few seconds.") - readonly property string levelHelp: qsTr("To level the horizon you need to place the vehicle in its level flight position and press OK.") - readonly property string airspeedHelp: qsTr("For Airspeed calibration you will need to keep your airspeed sensor out of any wind and then blow across the sensor.") - - readonly property string statusTextAreaDefaultText: qsTr("Start the individual calibration steps by clicking one of the buttons to the left.") - - // Used to pass what type of calibration is being performed to the preCalibrationDialog - property string preCalibrationDialogType - - // Used to pass help text to the preCalibrationDialog dialog - property string preCalibrationDialogHelp - - readonly property int rotationColumnWidth: ScreenTools.defaultFontPixelWidth * 30 - readonly property var rotations: [ - "ROTATION_NONE", - "ROTATION_YAW_45", - "ROTATION_YAW_90", - "ROTATION_YAW_135", - "ROTATION_YAW_180", - "ROTATION_YAW_225", - "ROTATION_YAW_270", - "ROTATION_YAW_315", - "ROTATION_ROLL_180", - "ROTATION_ROLL_180_YAW_45", - "ROTATION_ROLL_180_YAW_90", - "ROTATION_ROLL_180_YAW_135", - "ROTATION_PITCH_180", - "ROTATION_ROLL_180_YAW_225", - "ROTATION_ROLL_180_YAW_270", - "ROTATION_ROLL_180_YAW_315", - "ROTATION_ROLL_90", - "ROTATION_ROLL_90_YAW_45", - "ROTATION_ROLL_90_YAW_90", - "ROTATION_ROLL_90_YAW_135", - "ROTATION_ROLL_270", - "ROTATION_ROLL_270_YAW_45", - "ROTATION_ROLL_270_YAW_90", - "ROTATION_ROLL_270_YAW_135", - "ROTATION_PITCH_90", - "ROTATION_PITCH_270", - "ROTATION_ROLL_270_YAW_270", - "ROTATION_ROLL_180_PITCH_270", - "ROTATION_PITCH_90_YAW_180", - "ROTATION_ROLL_90_PITCH_90" - ] - - property Fact cal_mag0_id: controller.getParameterFact(-1, "CAL_MAG0_ID") - property Fact cal_mag1_id: controller.getParameterFact(-1, "CAL_MAG1_ID") - property Fact cal_mag2_id: controller.getParameterFact(-1, "CAL_MAG2_ID") - property Fact cal_mag0_rot: controller.getParameterFact(-1, "CAL_MAG0_ROT") - property Fact cal_mag1_rot: controller.getParameterFact(-1, "CAL_MAG1_ROT") - property Fact cal_mag2_rot: controller.getParameterFact(-1, "CAL_MAG2_ROT") - - property Fact cal_gyro0_id: controller.getParameterFact(-1, "CAL_GYRO0_ID") - property Fact cal_acc0_id: controller.getParameterFact(-1, "CAL_ACC0_ID") - - property Fact sens_board_rot: controller.getParameterFact(-1, "SENS_BOARD_ROT") - property Fact sens_board_x_off: controller.getParameterFact(-1, "SENS_BOARD_X_OFF") - property Fact sens_dpres_off: controller.getParameterFact(-1, "SENS_DPRES_OFF") - - // Id > = signals compass available, rot < 0 signals internal compass - property bool showCompass0Rot: cal_mag0_id.value > 0 && cal_mag0_rot.value >= 0 - property bool showCompass1Rot: cal_mag1_id.value > 0 && cal_mag1_rot.value >= 0 - property bool showCompass2Rot: cal_mag2_id.value > 0 && cal_mag2_rot.value >= 0 - - SensorsComponentController { - id: controller - factPanel: panel - statusLog: statusTextArea - progressBar: progressBar - compassButton: compassButton - gyroButton: gyroButton - accelButton: accelButton - airspeedButton: airspeedButton - levelButton: levelButton - cancelButton: cancelButton - setOrientationsButton: setOrientationsButton - orientationCalAreaHelpText: orientationCalAreaHelpText - - onResetStatusTextArea: statusLog.text = statusTextAreaDefaultText - - onSetCompassRotations: { - if (showCompass0Rot || showCompass1Rot || showCompass2Rot) { - setOrientationsDialogShowBoardOrientation = false - showDialog(setOrientationsDialogComponent, qsTr("Set Compass Rotation(s)"), qgcView.showDialogDefaultWidth, StandardButton.Ok) - } - } - - onWaitingForCancelChanged: { - if (controller.waitingForCancel) { - showMessage(qsTr("Calibration Cancel"), qsTr("Waiting for Vehicle to response to Cancel. This may take a few seconds."), 0) - } else { - hideDialog() - } - } - - } - - Component.onCompleted: { - var usingUDP = controller.usingUDPLink() - if (usingUDP) { - console.log("onUsingUDPLink") - showMessage("Sensor Calibration", "Performing sensor calibration over a WiFi connection is known to be unreliable. You should disconnect and perform calibration using a direct USB connection instead.", StandardButton.Ok) - } - } - - QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled } +SetupPage { + id: sensorsPage + pageComponent: pageComponent Component { - id: preCalibrationDialogComponent - - QGCViewDialog { - id: preCalibrationDialog - - function accept() { - if (preCalibrationDialogType == "gyro") { - controller.calibrateGyro() - } else if (preCalibrationDialogType == "accel") { - controller.calibrateAccel() - } else if (preCalibrationDialogType == "level") { - controller.calibrateLevel() - } else if (preCalibrationDialogType == "compass") { - controller.calibrateCompass() - } else if (preCalibrationDialogType == "airspeed") { - controller.calibrateAirspeed() - } - preCalibrationDialog.hideDialog() - } - - Column { - anchors.fill: parent - spacing: 5 - - QGCLabel { - width: parent.width - wrapMode: Text.WordWrap - text: preCalibrationDialogHelp + id: pageComponent + + Item { + width: availableWidth + height: availableHeight + + // Help text which is shown both in the status text area prior to pressing a cal button and in the + // pre-calibration dialog. + + readonly property string boardRotationText: qsTr("If the orientation is in the direction of flight, select ROTATION_NONE.") + readonly property string compassRotationText: qsTr("If the orientation is in the direction of flight, select ROTATION_NONE.") + + readonly property string compassHelp: qsTr("For Compass calibration you will need to rotate your vehicle through a number of positions.") + readonly property string gyroHelp: qsTr("For Gyroscope calibration you will need to place your vehicle on a surface and leave it still.") + readonly property string accelHelp: qsTr("For Accelerometer calibration you will need to place your vehicle on all six sides on a perfectly level surface and hold it still in each orientation for a few seconds.") + readonly property string levelHelp: qsTr("To level the horizon you need to place the vehicle in its level flight position and press OK.") + readonly property string airspeedHelp: qsTr("For Airspeed calibration you will need to keep your airspeed sensor out of any wind and then blow across the sensor.") + + readonly property string statusTextAreaDefaultText: qsTr("Start the individual calibration steps by clicking one of the buttons to the left.") + + // Used to pass what type of calibration is being performed to the preCalibrationDialog + property string preCalibrationDialogType + + // Used to pass help text to the preCalibrationDialog dialog + property string preCalibrationDialogHelp + + readonly property int rotationColumnWidth: ScreenTools.defaultFontPixelWidth * 30 + readonly property var rotations: [ + "ROTATION_NONE", + "ROTATION_YAW_45", + "ROTATION_YAW_90", + "ROTATION_YAW_135", + "ROTATION_YAW_180", + "ROTATION_YAW_225", + "ROTATION_YAW_270", + "ROTATION_YAW_315", + "ROTATION_ROLL_180", + "ROTATION_ROLL_180_YAW_45", + "ROTATION_ROLL_180_YAW_90", + "ROTATION_ROLL_180_YAW_135", + "ROTATION_PITCH_180", + "ROTATION_ROLL_180_YAW_225", + "ROTATION_ROLL_180_YAW_270", + "ROTATION_ROLL_180_YAW_315", + "ROTATION_ROLL_90", + "ROTATION_ROLL_90_YAW_45", + "ROTATION_ROLL_90_YAW_90", + "ROTATION_ROLL_90_YAW_135", + "ROTATION_ROLL_270", + "ROTATION_ROLL_270_YAW_45", + "ROTATION_ROLL_270_YAW_90", + "ROTATION_ROLL_270_YAW_135", + "ROTATION_PITCH_90", + "ROTATION_PITCH_270", + "ROTATION_ROLL_270_YAW_270", + "ROTATION_ROLL_180_PITCH_270", + "ROTATION_PITCH_90_YAW_180", + "ROTATION_ROLL_90_PITCH_90" + ] + + property Fact cal_mag0_id: controller.getParameterFact(-1, "CAL_MAG0_ID") + property Fact cal_mag1_id: controller.getParameterFact(-1, "CAL_MAG1_ID") + property Fact cal_mag2_id: controller.getParameterFact(-1, "CAL_MAG2_ID") + property Fact cal_mag0_rot: controller.getParameterFact(-1, "CAL_MAG0_ROT") + property Fact cal_mag1_rot: controller.getParameterFact(-1, "CAL_MAG1_ROT") + property Fact cal_mag2_rot: controller.getParameterFact(-1, "CAL_MAG2_ROT") + + property Fact cal_gyro0_id: controller.getParameterFact(-1, "CAL_GYRO0_ID") + property Fact cal_acc0_id: controller.getParameterFact(-1, "CAL_ACC0_ID") + + property Fact sens_board_rot: controller.getParameterFact(-1, "SENS_BOARD_ROT") + property Fact sens_board_x_off: controller.getParameterFact(-1, "SENS_BOARD_X_OFF") + property Fact sens_dpres_off: controller.getParameterFact(-1, "SENS_DPRES_OFF") + + // Id > = signals compass available, rot < 0 signals internal compass + property bool showCompass0Rot: cal_mag0_id.value > 0 && cal_mag0_rot.value >= 0 + property bool showCompass1Rot: cal_mag1_id.value > 0 && cal_mag1_rot.value >= 0 + property bool showCompass2Rot: cal_mag2_id.value > 0 && cal_mag2_rot.value >= 0 + + SensorsComponentController { + id: controller + factPanel: sensorsPage.viewPanel + statusLog: statusTextArea + progressBar: progressBar + compassButton: compassButton + gyroButton: gyroButton + accelButton: accelButton + airspeedButton: airspeedButton + levelButton: levelButton + cancelButton: cancelButton + setOrientationsButton: setOrientationsButton + orientationCalAreaHelpText: orientationCalAreaHelpText + + onResetStatusTextArea: statusLog.text = statusTextAreaDefaultText + + onSetCompassRotations: { + if (showCompass0Rot || showCompass1Rot || showCompass2Rot) { + setOrientationsDialogShowBoardOrientation = false + showDialog(setOrientationsDialogComponent, qsTr("Set Compass Rotation(s)"), sensorsPage.showDialogDefaultWidth, StandardButton.Ok) + } } - QGCLabel { - id: boardRotationHelp - width: parent.width - wrapMode: Text.WordWrap - visible: (preCalibrationDialogType != "airspeed") && (preCalibrationDialogType != "gyro") - text: boardRotationText + onWaitingForCancelChanged: { + if (controller.waitingForCancel) { + showMessage(qsTr("Calibration Cancel"), qsTr("Waiting for Vehicle to response to Cancel. This may take a few seconds."), 0) + } else { + hideDialog() + } } - Column { - visible: boardRotationHelp.visible - QGCLabel { - text: qsTr("Autopilot Orientation:") - } + } - FactComboBox { - id: boardRotationCombo - width: rotationColumnWidth; - model: rotations - fact: sens_board_rot - } + Component.onCompleted: { + var usingUDP = controller.usingUDPLink() + if (usingUDP) { + console.log("onUsingUDPLink") + showMessage("Sensor Calibration", "Performing sensor calibration over a WiFi connection is known to be unreliable. You should disconnect and perform calibration using a direct USB connection instead.", StandardButton.Ok) } } - } - } - property bool setOrientationsDialogShowBoardOrientation: true - - Component { - id: setOrientationsDialogComponent - - QGCViewDialog { - id: setOrientationsDialog - - QGCFlickable { - anchors.fill: parent - contentHeight: columnLayout.height - clip: true - - Column { - id: columnLayout - anchors.margins: ScreenTools.defaultFontPixelWidth - anchors.left: parent.left - anchors.right: parent.right - anchors.top: parent.top - spacing: ScreenTools.defaultFontPixelHeight - - QGCLabel { - width: parent.width - wrapMode: Text.WordWrap - text: boardRotationText + Component { + id: preCalibrationDialogComponent + + QGCViewDialog { + id: preCalibrationDialog + + function accept() { + if (preCalibrationDialogType == "gyro") { + controller.calibrateGyro() + } else if (preCalibrationDialogType == "accel") { + controller.calibrateAccel() + } else if (preCalibrationDialogType == "level") { + controller.calibrateLevel() + } else if (preCalibrationDialogType == "compass") { + controller.calibrateCompass() + } else if (preCalibrationDialogType == "airspeed") { + controller.calibrateAirspeed() + } + preCalibrationDialog.hideDialog() } Column { - visible: setOrientationsDialogShowBoardOrientation + anchors.fill: parent + spacing: 5 QGCLabel { - text: qsTr("Autopilot Orientation:") + width: parent.width + wrapMode: Text.WordWrap + text: preCalibrationDialogHelp } - FactComboBox { - id: boardRotationCombo - width: rotationColumnWidth; - model: rotations - fact: sens_board_rot + QGCLabel { + id: boardRotationHelp + width: parent.width + wrapMode: Text.WordWrap + visible: (preCalibrationDialogType != "airspeed") && (preCalibrationDialogType != "gyro") + text: boardRotationText } - } - - Column { - // Compass 0 rotation - Component { - id: compass0ComponentLabel2 + Column { + visible: boardRotationHelp.visible QGCLabel { - text: qsTr("External Compass Orientation:") + text: qsTr("Autopilot Orientation:") } - } - - Component { - id: compass0ComponentCombo2 FactComboBox { - id: compass0RotationCombo - width: rotationColumnWidth + id: boardRotationCombo + width: rotationColumnWidth; model: rotations - fact: cal_mag0_rot + fact: sens_board_rot } } - - Loader { sourceComponent: showCompass0Rot ? compass0ComponentLabel2 : null } - Loader { sourceComponent: showCompass0Rot ? compass0ComponentCombo2 : null } } + } + } - Column { - // Compass 1 rotation - Component { - id: compass1ComponentLabel2 + property bool setOrientationsDialogShowBoardOrientation: true - QGCLabel { - text: qsTr("External Compass 1 Orientation:") - } - } + Component { + id: setOrientationsDialogComponent - Component { - id: compass1ComponentCombo2 + QGCViewDialog { + id: setOrientationsDialog - FactComboBox { - id: compass1RotationCombo - width: rotationColumnWidth - model: rotations - fact: cal_mag1_rot + QGCFlickable { + anchors.fill: parent + contentHeight: columnLayout.height + clip: true + + Column { + id: columnLayout + anchors.margins: ScreenTools.defaultFontPixelWidth + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + spacing: ScreenTools.defaultFontPixelHeight + + QGCLabel { + width: parent.width + wrapMode: Text.WordWrap + text: boardRotationText } - } - Loader { sourceComponent: showCompass1Rot ? compass1ComponentLabel2 : null } - Loader { sourceComponent: showCompass1Rot ? compass1ComponentCombo2 : null } - } + Column { + visible: setOrientationsDialogShowBoardOrientation - Column { - spacing: ScreenTools.defaultFontPixelWidth + QGCLabel { + text: qsTr("Autopilot Orientation:") + } - // Compass 2 rotation - Component { - id: compass2ComponentLabel2 + FactComboBox { + id: boardRotationCombo + width: rotationColumnWidth; + model: rotations + fact: sens_board_rot + } + } - QGCLabel { - text: qsTr("Compass 2 Orientation") + Column { + // Compass 0 rotation + Component { + id: compass0ComponentLabel2 + + QGCLabel { + text: qsTr("External Compass Orientation:") + } + } + + Component { + id: compass0ComponentCombo2 + + FactComboBox { + id: compass0RotationCombo + width: rotationColumnWidth + model: rotations + fact: cal_mag0_rot + } + } + + Loader { sourceComponent: showCompass0Rot ? compass0ComponentLabel2 : null } + Loader { sourceComponent: showCompass0Rot ? compass0ComponentCombo2 : null } } - } - Component { - id: compass2ComponentCombo2 + Column { + // Compass 1 rotation + Component { + id: compass1ComponentLabel2 + + QGCLabel { + text: qsTr("External Compass 1 Orientation:") + } + } + + Component { + id: compass1ComponentCombo2 + + FactComboBox { + id: compass1RotationCombo + width: rotationColumnWidth + model: rotations + fact: cal_mag1_rot + } + } + + Loader { sourceComponent: showCompass1Rot ? compass1ComponentLabel2 : null } + Loader { sourceComponent: showCompass1Rot ? compass1ComponentCombo2 : null } + } - FactComboBox { - id: compass1RotationCombo - width: rotationColumnWidth - model: rotations - fact: cal_mag2_rot + Column { + spacing: ScreenTools.defaultFontPixelWidth + + // Compass 2 rotation + Component { + id: compass2ComponentLabel2 + + QGCLabel { + text: qsTr("Compass 2 Orientation") + } + } + + Component { + id: compass2ComponentCombo2 + + FactComboBox { + id: compass1RotationCombo + width: rotationColumnWidth + model: rotations + fact: cal_mag2_rot + } + } + Loader { sourceComponent: showCompass2Rot ? compass2ComponentLabel2 : null } + Loader { sourceComponent: showCompass2Rot ? compass2ComponentCombo2 : null } } - } - Loader { sourceComponent: showCompass2Rot ? compass2ComponentLabel2 : null } - Loader { sourceComponent: showCompass2Rot ? compass2ComponentCombo2 : null } + } // Column + } // QGCFlickable + } // QGCViewDialog + } // Component - setOrientationsDialogComponent + + Column { + id: buttonColumn + spacing: ScreenTools.defaultFontPixelHeight / 2 + + readonly property int buttonWidth: ScreenTools.defaultFontPixelWidth * 15 + + IndicatorButton { + id: compassButton + width: parent.buttonWidth + text: qsTr("Compass") + indicatorGreen: cal_mag0_id.value != 0 + + onClicked: { + preCalibrationDialogType = "compass" + preCalibrationDialogHelp = compassHelp + showDialog(preCalibrationDialogComponent, qsTr("Calibrate Compass"), sensorsPage.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) } - } // Column - } // QGCFlickable - } // QGCViewDialog - } // Component - setOrientationsDialogComponent - - QGCViewPanel { - id: panel - anchors.fill: parent - - Column { - id: buttonColumn - spacing: ScreenTools.defaultFontPixelHeight / 2 - - readonly property int buttonWidth: ScreenTools.defaultFontPixelWidth * 15 - - IndicatorButton { - id: compassButton - width: parent.buttonWidth - text: qsTr("Compass") - indicatorGreen: cal_mag0_id.value != 0 - - onClicked: { - preCalibrationDialogType = "compass" - preCalibrationDialogHelp = compassHelp - showDialog(preCalibrationDialogComponent, qsTr("Calibrate Compass"), qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) } - } - IndicatorButton { - id: gyroButton - width: parent.buttonWidth - text: qsTr("Gyroscope") - indicatorGreen: cal_gyro0_id.value != 0 + IndicatorButton { + id: gyroButton + width: parent.buttonWidth + text: qsTr("Gyroscope") + indicatorGreen: cal_gyro0_id.value != 0 - onClicked: { - preCalibrationDialogType = "gyro" - preCalibrationDialogHelp = gyroHelp - showDialog(preCalibrationDialogComponent, qsTr("Calibrate Gyro"), qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) + onClicked: { + preCalibrationDialogType = "gyro" + preCalibrationDialogHelp = gyroHelp + showDialog(preCalibrationDialogComponent, qsTr("Calibrate Gyro"), sensorsPage.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) + } } - } - IndicatorButton { - id: accelButton - width: parent.buttonWidth - text: qsTr("Accelerometer") - indicatorGreen: cal_acc0_id.value != 0 + IndicatorButton { + id: accelButton + width: parent.buttonWidth + text: qsTr("Accelerometer") + indicatorGreen: cal_acc0_id.value != 0 - onClicked: { - preCalibrationDialogType = "accel" - preCalibrationDialogHelp = accelHelp - showDialog(preCalibrationDialogComponent, qsTr("Calibrate Accelerometer"), qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) + onClicked: { + preCalibrationDialogType = "accel" + preCalibrationDialogHelp = accelHelp + showDialog(preCalibrationDialogComponent, qsTr("Calibrate Accelerometer"), sensorsPage.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) + } } - } - IndicatorButton { - id: levelButton - width: parent.buttonWidth - text: qsTr("Level Horizon") - indicatorGreen: sens_board_x_off.value != 0 - enabled: cal_acc0_id.value != 0 && cal_gyro0_id.value != 0 - - onClicked: { - preCalibrationDialogType = "level" - preCalibrationDialogHelp = levelHelp - showDialog(preCalibrationDialogComponent, qsTr("Level Horizon"), qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) + IndicatorButton { + id: levelButton + width: parent.buttonWidth + text: qsTr("Level Horizon") + indicatorGreen: sens_board_x_off.value != 0 + enabled: cal_acc0_id.value != 0 && cal_gyro0_id.value != 0 + + onClicked: { + preCalibrationDialogType = "level" + preCalibrationDialogHelp = levelHelp + showDialog(preCalibrationDialogComponent, qsTr("Level Horizon"), sensorsPage.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) + } } - } - IndicatorButton { - id: airspeedButton - width: parent.buttonWidth - text: qsTr("Airspeed") - visible: (controller.vehicle.fixedWing || controller.vehicle.vtol) && controller.getParameterFact(-1, "CBRK_AIRSPD_CHK").value != 162128 - indicatorGreen: sens_dpres_off.value != 0 - - onClicked: { - preCalibrationDialogType = "airspeed" - preCalibrationDialogHelp = airspeedHelp - showDialog(preCalibrationDialogComponent, qsTr("Calibrate Airspeed"), qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) + IndicatorButton { + id: airspeedButton + width: parent.buttonWidth + text: qsTr("Airspeed") + visible: (controller.vehicle.fixedWing || controller.vehicle.vtol) && controller.getParameterFact(-1, "CBRK_AIRSPD_CHK").value != 162128 + indicatorGreen: sens_dpres_off.value != 0 + + onClicked: { + preCalibrationDialogType = "airspeed" + preCalibrationDialogHelp = airspeedHelp + showDialog(preCalibrationDialogComponent, qsTr("Calibrate Airspeed"), sensorsPage.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) + } } - } - QGCButton { - id: cancelButton - width: parent.buttonWidth - text: qsTr("Cancel") - enabled: false - onClicked: controller.cancelCalibration() - } + QGCButton { + id: cancelButton + width: parent.buttonWidth + text: qsTr("Cancel") + enabled: false + onClicked: controller.cancelCalibration() + } - QGCButton { - id: setOrientationsButton - width: parent.buttonWidth - text: qsTr("Set Orientations") - onClicked: { - setOrientationsDialogShowBoardOrientation = true - showDialog(setOrientationsDialogComponent, qsTr("Set Orientations"), qgcView.showDialogDefaultWidth, StandardButton.Ok) + QGCButton { + id: setOrientationsButton + width: parent.buttonWidth + text: qsTr("Set Orientations") + onClicked: { + setOrientationsDialogShowBoardOrientation = true + showDialog(setOrientationsDialogComponent, qsTr("Set Orientations"), sensorsPage.showDialogDefaultWidth, StandardButton.Ok) + } } - } - } // Column - Buttons - - Column { - anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2 - anchors.left: buttonColumn.right - anchors.right: parent.right - anchors.top: parent.top - anchors.bottom: parent.bottom - - ProgressBar { - id: progressBar - anchors.left: parent.left - anchors.right: parent.right - } + } // Column - Buttons - Item { height: ScreenTools.defaultFontPixelHeight; width: 10 } // spacer + Column { + anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2 + anchors.left: buttonColumn.right + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + + ProgressBar { + id: progressBar + anchors.left: parent.left + anchors.right: parent.right + } - Item { - property int calDisplayAreaWidth: parent.width + Item { height: ScreenTools.defaultFontPixelHeight; width: 10 } // spacer - width: parent.width - height: parent.height - y + Item { + property int calDisplayAreaWidth: parent.width - TextArea { - id: statusTextArea - width: parent.calDisplayAreaWidth - height: parent.height - readOnly: true - frameVisible: false - text: statusTextAreaDefaultText + width: parent.width + height: parent.height - y - style: TextAreaStyle { - textColor: qgcPal.text - backgroundColor: qgcPal.windowShade - } - } + TextArea { + id: statusTextArea + width: parent.calDisplayAreaWidth + height: parent.height + readOnly: true + frameVisible: false + text: statusTextAreaDefaultText - Rectangle { - id: orientationCalArea - width: parent.calDisplayAreaWidth - height: parent.height - visible: controller.showOrientationCalArea - color: qgcPal.windowShade - - QGCLabel { - id: orientationCalAreaHelpText - anchors.margins: ScreenTools.defaultFontPixelWidth - anchors.top: orientationCalArea.top - anchors.left: orientationCalArea.left - width: parent.width - wrapMode: Text.WordWrap - font.pointSize: ScreenTools.mediumFontPointSize + style: TextAreaStyle { + textColor: qgcPal.text + backgroundColor: qgcPal.windowShade + } } - Flow { - anchors.topMargin: ScreenTools.defaultFontPixelWidth - anchors.top: orientationCalAreaHelpText.bottom - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - spacing: ScreenTools.defaultFontPixelWidth / 2 - - property real indicatorWidth: (width / 3) - (spacing * 2) - property real indicatorHeight: (height / 2) - spacing - - VehicleRotationCal { - width: parent.indicatorWidth - height: parent.indicatorHeight - visible: controller.orientationCalDownSideVisible - calValid: controller.orientationCalDownSideDone - calInProgress: controller.orientationCalDownSideInProgress - calInProgressText: controller.orientationCalDownSideRotate ? qsTr("Rotate") : qsTr("Hold Still") - imageSource: controller.orientationCalDownSideRotate ? "qrc:///qmlimages/VehicleDownRotate.png" : "qrc:///qmlimages/VehicleDown.png" - } - VehicleRotationCal { - width: parent.indicatorWidth - height: parent.indicatorHeight - visible: controller.orientationCalUpsideDownSideVisible - calValid: controller.orientationCalUpsideDownSideDone - calInProgress: controller.orientationCalUpsideDownSideInProgress - calInProgressText: controller.orientationCalUpsideDownSideRotate ? qsTr("Rotate") : qsTr("Hold Still") - imageSource: controller.orientationCalUpsideDownSideRotate ? "qrc:///qmlimages/VehicleUpsideDownRotate.png" : "qrc:///qmlimages/VehicleUpsideDown.png" - } - VehicleRotationCal { - width: parent.indicatorWidth - height: parent.indicatorHeight - visible: controller.orientationCalNoseDownSideVisible - calValid: controller.orientationCalNoseDownSideDone - calInProgress: controller.orientationCalNoseDownSideInProgress - calInProgressText: controller.orientationCalNoseDownSideRotate ? qsTr("Rotate") : qsTr("Hold Still") - imageSource: controller.orientationCalNoseDownSideRotate ? "qrc:///qmlimages/VehicleNoseDownRotate.png" : "qrc:///qmlimages/VehicleNoseDown.png" - } - VehicleRotationCal { - width: parent.indicatorWidth - height: parent.indicatorHeight - visible: controller.orientationCalTailDownSideVisible - calValid: controller.orientationCalTailDownSideDone - calInProgress: controller.orientationCalTailDownSideInProgress - calInProgressText: controller.orientationCalTailDownSideRotate ? qsTr("Rotate") : qsTr("Hold Still") - imageSource: controller.orientationCalTailDownSideRotate ? "qrc:///qmlimages/VehicleTailDownRotate.png" : "qrc:///qmlimages/VehicleTailDown.png" - } - VehicleRotationCal { - width: parent.indicatorWidth - height: parent.indicatorHeight - visible: controller.orientationCalLeftSideVisible - calValid: controller.orientationCalLeftSideDone - calInProgress: controller.orientationCalLeftSideInProgress - calInProgressText: controller.orientationCalLeftSideRotate ? qsTr("Rotate") : qsTr("Hold Still") - imageSource: controller.orientationCalLeftSideRotate ? "qrc:///qmlimages/VehicleLeftRotate.png" : "qrc:///qmlimages/VehicleLeft.png" + Rectangle { + id: orientationCalArea + width: parent.calDisplayAreaWidth + height: parent.height + visible: controller.showOrientationCalArea + color: qgcPal.windowShade + + QGCLabel { + id: orientationCalAreaHelpText + anchors.margins: ScreenTools.defaultFontPixelWidth + anchors.top: orientationCalArea.top + anchors.left: orientationCalArea.left + width: parent.width + wrapMode: Text.WordWrap + font.pointSize: ScreenTools.mediumFontPointSize } - VehicleRotationCal { - width: parent.indicatorWidth - height: parent.indicatorHeight - visible: controller.orientationCalRightSideVisible - calValid: controller.orientationCalRightSideDone - calInProgress: controller.orientationCalRightSideInProgress - calInProgressText: controller.orientationCalRightSideRotate ? qsTr("Rotate") : qsTr("Hold Still") - imageSource: controller.orientationCalRightSideRotate ? "qrc:///qmlimages/VehicleRightRotate.png" : "qrc:///qmlimages/VehicleRight.png" + + Flow { + anchors.topMargin: ScreenTools.defaultFontPixelWidth + anchors.top: orientationCalAreaHelpText.bottom + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + spacing: ScreenTools.defaultFontPixelWidth / 2 + + property real indicatorWidth: (width / 3) - (spacing * 2) + property real indicatorHeight: (height / 2) - spacing + + VehicleRotationCal { + width: parent.indicatorWidth + height: parent.indicatorHeight + visible: controller.orientationCalDownSideVisible + calValid: controller.orientationCalDownSideDone + calInProgress: controller.orientationCalDownSideInProgress + calInProgressText: controller.orientationCalDownSideRotate ? qsTr("Rotate") : qsTr("Hold Still") + imageSource: controller.orientationCalDownSideRotate ? "qrc:///qmlimages/VehicleDownRotate.png" : "qrc:///qmlimages/VehicleDown.png" + } + VehicleRotationCal { + width: parent.indicatorWidth + height: parent.indicatorHeight + visible: controller.orientationCalUpsideDownSideVisible + calValid: controller.orientationCalUpsideDownSideDone + calInProgress: controller.orientationCalUpsideDownSideInProgress + calInProgressText: controller.orientationCalUpsideDownSideRotate ? qsTr("Rotate") : qsTr("Hold Still") + imageSource: controller.orientationCalUpsideDownSideRotate ? "qrc:///qmlimages/VehicleUpsideDownRotate.png" : "qrc:///qmlimages/VehicleUpsideDown.png" + } + VehicleRotationCal { + width: parent.indicatorWidth + height: parent.indicatorHeight + visible: controller.orientationCalNoseDownSideVisible + calValid: controller.orientationCalNoseDownSideDone + calInProgress: controller.orientationCalNoseDownSideInProgress + calInProgressText: controller.orientationCalNoseDownSideRotate ? qsTr("Rotate") : qsTr("Hold Still") + imageSource: controller.orientationCalNoseDownSideRotate ? "qrc:///qmlimages/VehicleNoseDownRotate.png" : "qrc:///qmlimages/VehicleNoseDown.png" + } + VehicleRotationCal { + width: parent.indicatorWidth + height: parent.indicatorHeight + visible: controller.orientationCalTailDownSideVisible + calValid: controller.orientationCalTailDownSideDone + calInProgress: controller.orientationCalTailDownSideInProgress + calInProgressText: controller.orientationCalTailDownSideRotate ? qsTr("Rotate") : qsTr("Hold Still") + imageSource: controller.orientationCalTailDownSideRotate ? "qrc:///qmlimages/VehicleTailDownRotate.png" : "qrc:///qmlimages/VehicleTailDown.png" + } + VehicleRotationCal { + width: parent.indicatorWidth + height: parent.indicatorHeight + visible: controller.orientationCalLeftSideVisible + calValid: controller.orientationCalLeftSideDone + calInProgress: controller.orientationCalLeftSideInProgress + calInProgressText: controller.orientationCalLeftSideRotate ? qsTr("Rotate") : qsTr("Hold Still") + imageSource: controller.orientationCalLeftSideRotate ? "qrc:///qmlimages/VehicleLeftRotate.png" : "qrc:///qmlimages/VehicleLeft.png" + } + VehicleRotationCal { + width: parent.indicatorWidth + height: parent.indicatorHeight + visible: controller.orientationCalRightSideVisible + calValid: controller.orientationCalRightSideDone + calInProgress: controller.orientationCalRightSideInProgress + calInProgressText: controller.orientationCalRightSideRotate ? qsTr("Rotate") : qsTr("Hold Still") + imageSource: controller.orientationCalRightSideRotate ? "qrc:///qmlimages/VehicleRightRotate.png" : "qrc:///qmlimages/VehicleRight.png" + } } } } } - } - } // QGCViewPanel -} // QGCView + } // Row + } // Component +} // SetupPage diff --git a/src/QmlControls/FactSliderPanel.qml b/src/QmlControls/FactSliderPanel.qml index 5e113b349..e900e8382 100644 --- a/src/QmlControls/FactSliderPanel.qml +++ b/src/QmlControls/FactSliderPanel.qml @@ -16,11 +16,7 @@ import QGroundControl.Palette 1.0 import QGroundControl.Controls 1.0 import QGroundControl.ScreenTools 1.0 -QGCView { - viewPanel: panel - - property string panelTitle: "Title" ///< Title for panel - +Column { /// ListModel must contains elements which look like this: /// ListElement { /// title: "Roll sensitivity" @@ -32,12 +28,17 @@ QGCView { /// } property ListModel sliderModel - FactPanelController { id: controller; factPanel: panel } + property var qgcViewPanel - QGCPalette { id: palette; colorGroupEnabled: enabled } - property real _margins: ScreenTools.defaultFontPixelHeight + property real _margins: ScreenTools.defaultFontPixelHeight + property bool _loadComplete: false - property bool _loadComplete: false + FactPanelController { + id: controller + factPanel: qgcViewPanel + } + + QGCPalette { id: palette; colorGroupEnabled: enabled } Component.onCompleted: { // Qml Sliders have a strange behavior in which they first set Slider::value to some internal @@ -51,84 +52,69 @@ QGCView { _loadComplete = true } - QGCViewPanel { - id: panel - anchors.fill: parent - - QGCFlickable { - clip: true - anchors.fill: parent - contentHeight: sliderOuterColumn.y + sliderOuterColumn.height - flickableDirection: Flickable.VerticalFlick + QGCLabel { + id: panelLabel + text: panelTitle + font.family: ScreenTools.demiboldFontFamily + } - QGCLabel { - id: panelLabel - text: panelTitle - font.family: ScreenTools.demiboldFontFamily - } + Column { + id: sliderOuterColumn + anchors.left: parent.left + anchors.right: parent.right + spacing: _margins + Repeater { + id: sliderRepeater + model: sliderModel - Column { - id: sliderOuterColumn - anchors.margins: _margins + Rectangle { + id: sliderRect anchors.left: parent.left anchors.right: parent.right - anchors.top: panelLabel.bottom - spacing: _margins - - Repeater { - id: sliderRepeater - model: sliderModel - - Rectangle { - id: sliderRect + height: sliderColumn.y + sliderColumn.height + _margins + color: palette.windowShade + + property alias sliderValue: slider.value + + Column { + id: sliderColumn + anchors.margins: _margins + anchors.left: parent.left + anchors.right: parent.right + anchors.top: sliderRect.top + + QGCLabel { + text: title + font.family: ScreenTools.demiboldFontFamily + } + + QGCLabel { + text: description + anchors.left: parent.left + anchors.right: parent.right + wrapMode: Text.WordWrap + } + + Slider { + id: slider anchors.left: parent.left anchors.right: parent.right - height: sliderColumn.y + sliderColumn.height + _margins - color: palette.windowShade - - property alias sliderValue: slider.value + minimumValue: min + maximumValue: max + stepSize: isNaN(fact.increment) ? step : fact.increment + tickmarksEnabled: true - Column { - id: sliderColumn - anchors.margins: _margins - anchors.left: parent.left - anchors.right: parent.right - anchors.top: sliderRect.top + property Fact fact: controller.getParameterFact(-1, param) - QGCLabel { - text: title - font.family: ScreenTools.demiboldFontFamily + onValueChanged: { + if (_loadComplete) { + fact.value = value } - - QGCLabel { - text: description - anchors.left: parent.left - anchors.right: parent.right - wrapMode: Text.WordWrap - } - - Slider { - id: slider - anchors.left: parent.left - anchors.right: parent.right - minimumValue: min - maximumValue: max - stepSize: isNaN(fact.increment) ? step : fact.increment - tickmarksEnabled: true - - property Fact fact: controller.getParameterFact(-1, param) - - onValueChanged: { - if (_loadComplete) { - fact.value = value - } - } - } // Slider - } // Column - } // Rectangle - } // Repeater - } // Column - } // QGCFlickable - } // QGCViewPanel + } + } // Slider + } // Column + } // Rectangle + } // Repeater + } // Column } // QGCView diff --git a/src/QmlControls/ModeSwitchDisplay.qml b/src/QmlControls/ModeSwitchDisplay.qml index 8e651bfcc..de4c4a093 100644 --- a/src/QmlControls/ModeSwitchDisplay.qml +++ b/src/QmlControls/ModeSwitchDisplay.qml @@ -89,7 +89,7 @@ Rectangle { spacing: ScreenTools.defaultFontPixelWidth * 2 QGCLabel { - width: ScreenTools.defaultFontPixelWidth * monitorThresholdCharWidth + id: monitorLabel height: ScreenTools.defaultFontPixelHeight verticalAlignment: Text.AlignVCenter text: qsTr("Monitor:") @@ -129,13 +129,12 @@ Rectangle { spacing: ScreenTools.defaultFontPixelWidth * 2 QGCLabel { - width: ScreenTools.defaultFontPixelWidth * monitorThresholdCharWidth + id: thresholdLabel height: ScreenTools.defaultFontPixelHeight verticalAlignment: Text.AlignVCenter text: qsTr("Threshold:") } - Item { id: thresholdContainer height: ScreenTools.defaultFontPixelHeight diff --git a/src/QmlControls/RCChannelMonitor.qml b/src/QmlControls/RCChannelMonitor.qml index c3563eb45..1f0acf02a 100644 --- a/src/QmlControls/RCChannelMonitor.qml +++ b/src/QmlControls/RCChannelMonitor.qml @@ -27,7 +27,7 @@ FactPanel { readonly property int _pwmMax: 2200 readonly property int _pwmRange: _pwmMax - _pwmMin - QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled } + QGCPalette { id: qgcPal; colorGroupEnabled: _root.enabled } RCChannelMonitorController { id: controller -- 2.22.0