Browse Source

Merge pull request #6655 from DonLakeFlyer/APMPowerCalc

ArduPilot voltage/amp calculators broken
QGC4.4
Don Gagne 7 years ago committed by GitHub
parent
commit
348091b34a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 39
      src/AutoPilotPlugins/APM/APMPowerComponent.qml
  2. 1
      src/QmlControls/ParameterEditorDialog.qml
  3. 15
      src/QmlControls/QGCTextField.qml

39
src/AutoPilotPlugins/APM/APMPowerComponent.qml

@ -369,8 +369,14 @@ SetupPage {
QGCButton { QGCButton {
text: qsTr("Calculate") text: qsTr("Calculate")
onClicked: showDialog(calcVoltageMultiplierDlgComponent, qsTr("Calculate Voltage Multiplier"), qgcView.showDialogDefaultWidth, StandardButton.Close)
visible: _showAdvanced visible: _showAdvanced
onClicked: {
_calcVoltageDlgVehicleVoltage = vehicleVoltage
_calcVoltageDlgBattVoltMultParam = battVoltMult
showDialog(calcVoltageMultiplierDlgComponent, qsTr("Calculate Voltage Multiplier"), qgcView.showDialogDefaultWidth, StandardButton.Close)
}
} }
QGCLabel { QGCLabel {
@ -395,8 +401,13 @@ SetupPage {
QGCButton { QGCButton {
text: qsTr("Calculate") text: qsTr("Calculate")
onClicked: showDialog(calcAmpsPerVoltDlgComponent, qsTr("Calculate Amps per Volt"), qgcView.showDialogDefaultWidth, StandardButton.Close)
visible: _showAdvanced visible: _showAdvanced
onClicked: {
_calcAmpsPerVoltDlgVehicleCurrent = vehicleCurrent
_calcAmpsPerVoltDlgBattAmpPerVoltParam = battAmpPerVolt
showDialog(calcAmpsPerVoltDlgComponent, qsTr("Calculate Amps per Volt"), qgcView.showDialogDefaultWidth, StandardButton.Close)
}
} }
QGCLabel { QGCLabel {
@ -411,6 +422,10 @@ SetupPage {
} // Column } // Column
} // Component - powerSetupComponent } // Component - powerSetupComponent
// Must be set prior to use of calcVoltageMultiplierDlgComponent
property Fact _calcVoltageDlgVehicleVoltage
property Fact _calcVoltageDlgBattVoltMultParam
Component { Component {
id: calcVoltageMultiplierDlgComponent id: calcVoltageMultiplierDlgComponent
@ -444,10 +459,10 @@ SetupPage {
QGCTextField { id: measuredVoltage } QGCTextField { id: measuredVoltage }
QGCLabel { text: qsTr("Vehicle voltage:") } QGCLabel { text: qsTr("Vehicle voltage:") }
QGCLabel { text: vehicleVoltage.valueString } FactLabel { fact: _calcVoltageDlgVehicleVoltage }
QGCLabel { text: qsTr("Voltage multiplier:") } QGCLabel { text: qsTr("Voltage multiplier:") }
FactLabel { fact: battVoltMult } FactLabel { fact: _calcVoltageDlgBattVoltMultParam }
} }
QGCButton { QGCButton {
@ -458,9 +473,9 @@ SetupPage {
if (measuredVoltageValue == 0 || isNaN(measuredVoltageValue)) { if (measuredVoltageValue == 0 || isNaN(measuredVoltageValue)) {
return return
} }
var newVoltageMultiplier = (measuredVoltageValue * battVoltMult.value) / vehicleVoltage.value var newVoltageMultiplier = (measuredVoltageValue * _calcVoltageDlgBattVoltMultParam.value) / _calcVoltageDlgVehicleVoltage.value
if (newVoltageMultiplier > 0) { if (newVoltageMultiplier > 0) {
battVoltMult.value = newVoltageMultiplier _calcVoltageDlgBattVoltMultParam.value = newVoltageMultiplier
} }
} }
} }
@ -469,6 +484,10 @@ SetupPage {
} // QGCViewDialog } // QGCViewDialog
} // Component - calcVoltageMultiplierDlgComponent } // Component - calcVoltageMultiplierDlgComponent
// Must be set prior to use of calcAmpsPerVoltDlgComponent
property Fact _calcAmpsPerVoltDlgVehicleCurrent
property Fact _calcAmpsPerVoltDlgBattAmpPerVoltParam
Component { Component {
id: calcAmpsPerVoltDlgComponent id: calcAmpsPerVoltDlgComponent
@ -502,10 +521,10 @@ SetupPage {
QGCTextField { id: measuredCurrent } QGCTextField { id: measuredCurrent }
QGCLabel { text: qsTr("Vehicle current:") } QGCLabel { text: qsTr("Vehicle current:") }
QGCLabel { text: vehicleCurrent.valueString } FactLabel { fact: _calcAmpsPerVoltDlgVehicleCurrent }
QGCLabel { text: qsTr("Amps per volt:") } QGCLabel { text: qsTr("Amps per volt:") }
FactLabel { fact: battAmpPerVolt } FactLabel { fact: _calcAmpsPerVoltDlgBattAmpPerVoltParam }
} }
QGCButton { QGCButton {
@ -516,9 +535,9 @@ SetupPage {
if (measuredCurrentValue == 0) { if (measuredCurrentValue == 0) {
return return
} }
var newAmpsPerVolt = (measuredCurrentValue * battAmpPerVolt.value) / vehicleCurrent.value var newAmpsPerVolt = (measuredCurrentValue * _calcAmpsPerVoltDlgBattAmpPerVoltParam.value) / _calcAmpsPerVoltDlgVehicleCurrent.value
if (newAmpsPerVolt != 0) { if (newAmpsPerVolt != 0) {
battAmpPerVolt.value = newAmpsPerVolt _calcAmpsPerVoltDlgBattAmpPerVoltParam.value = newAmpsPerVolt
} }
} }
} }

1
src/QmlControls/ParameterEditorDialog.qml

@ -129,7 +129,6 @@ QGCViewDialog {
} }
QGCButton { QGCButton {
anchors.baseline: valueField.baseline
visible: _allowDefaultReset visible: _allowDefaultReset
text: qsTr("Reset to default") text: qsTr("Reset to default")

15
src/QmlControls/QGCTextField.qml

@ -71,7 +71,7 @@ TextField {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.rightMargin: backgroundItem.showHelp ? 0 : control.__contentHeight * 0.333 anchors.rightMargin: backgroundItem.showHelp ? 0 : control.__contentHeight * 0.333
anchors.right: parent.right anchors.right: parent.right
spacing: 4 spacing: ScreenTools.defaultFontPixelWidth / 4
Component.onCompleted: control._helpLayoutWidth = unitsHelpLayout.width Component.onCompleted: control._helpLayoutWidth = unitsHelpLayout.width
onWidthChanged: control._helpLayoutWidth = unitsHelpLayout.width onWidthChanged: control._helpLayoutWidth = unitsHelpLayout.width
@ -88,19 +88,18 @@ TextField {
Rectangle { Rectangle {
Layout.margins: 2 Layout.margins: 2
Layout.leftMargin: 0
Layout.rightMargin: 1
Layout.fillHeight: true Layout.fillHeight: true
Layout.alignment: Qt.AlignRight width: helpLabel.contentWidth * 3
width: height * 0.75
color: control.textColor color: control.textColor
radius: 2
visible: backgroundItem.showHelp visible: backgroundItem.showHelp
QGCLabel { QGCLabel {
anchors.fill: parent id: helpLabel
verticalAlignment: Text.AlignVCenter anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
color: qgcPal.textField color: qgcPal.textField
text: "?" text: qsTr("?")
} }
} }
} }

Loading…
Cancel
Save