/**************************************************************************** * * (c) 2009-2016 QGROUNDCONTROL PROJECT * * QGroundControl is licensed according to the terms in the file * COPYING.md in the root of the source code directory. * ****************************************************************************/ import QtQuick 2.3 import QtQuick.Controls 1.2 import QtQuick.Dialogs 1.2 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 SetupPage { id: powerPage pageComponent: powerPageComponent FactPanelController { id: controller factPanel: powerPage.viewPanel } Component { id: powerPageComponent Column { spacing: _margins QGCLabel { text: qsTr("Battery 1"); font.pointSize: ScreenTools.mediumFontPointSize } Loader { sourceComponent: powerSetupComponent property Fact armVoltMin: controller.getParameterFact(-1, "r.ARMING_VOLT_MIN") property Fact battAmpPerVolt: controller.getParameterFact(-1, "BATT_AMP_PERVOLT") property Fact battCapacity: controller.getParameterFact(-1, "BATT_CAPACITY") property Fact battCurrPin: controller.getParameterFact(-1, "BATT_CURR_PIN") property Fact battMonitor: controller.getParameterFact(-1, "BATT_MONITOR") property Fact battVoltMult: controller.getParameterFact(-1, "BATT_VOLT_MULT") property Fact battVoltPin: controller.getParameterFact(-1, "BATT_VOLT_PIN") property Fact vehicleVoltage: controller.vehicle.battery.voltage property Fact vehicleCurrent: controller.vehicle.battery.current } Item { height: ScreenTools.defaultFontPixelHeight width: 1 } QGCLabel { text: qsTr("Battery 2"); font.pointSize: ScreenTools.mediumFontPointSize } Loader { sourceComponent: powerSetupComponent property Fact armVoltMin: controller.getParameterFact(-1, "r.ARMING_VOLT2_MIN") property Fact battAmpPerVolt: controller.getParameterFact(-1, "BATT2_AMP_PERVOL") property Fact battCapacity: controller.getParameterFact(-1, "BATT2_CAPACITY") property Fact battCurrPin: controller.getParameterFact(-1, "BATT2_CURR_PIN") property Fact battMonitor: controller.getParameterFact(-1, "BATT2_MONITOR") property Fact battVoltMult: controller.getParameterFact(-1, "BATT2_VOLT_MULT") property Fact battVoltPin: controller.getParameterFact(-1, "BATT2_VOLT_PIN") property Fact vehicleVoltage: controller.vehicle.battery2.voltage property Fact vehicleCurrent: controller.vehicle.battery2.current } } } // Component - powerPageComponent Component { id: powerSetupComponent Column { spacing: _margins property real _margins: ScreenTools.defaultFontPixelHeight / 2 property bool _showAdvanced: sensorCombo.currentIndex === sensorModel.count - 1 property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 25 Component.onCompleted: calcSensor() function calcSensor() { for (var i=0; i 0) { battVoltMult.value = newVoltageMultiplier } } } } // Column } // QGCFlickable } // QGCViewDialog } // Component - calcVoltageMultiplierDlgComponent Component { id: calcAmpsPerVoltDlgComponent QGCViewDialog { id: calcAmpsPerVoltDlg QGCFlickable { anchors.fill: parent contentHeight: column.height contentWidth: column.width Column { id: column width: calcAmpsPerVoltDlg.width spacing: ScreenTools.defaultFontPixelHeight QGCLabel { width: parent.width wrapMode: Text.WordWrap text: qsTr("Measure current draw using an external current meter and enter the value below. Click Calculate to set the new amps per volt value.") } Grid { columns: 2 spacing: ScreenTools.defaultFontPixelHeight / 2 verticalItemAlignment: Grid.AlignVCenter QGCLabel { text: qsTr("Measured current:") } QGCTextField { id: measuredCurrent } QGCLabel { text: qsTr("Vehicle current:") } QGCLabel { text: vehicleCurrent.valueString } QGCLabel { text: qsTr("Amps per volt:") } FactLabel { fact: battAmpPerVolt } } QGCButton { text: "Calculate" onClicked: { var measuredCurrentValue = parseFloat(measuredCurrent.text) if (measuredCurrentValue == 0) { return } var newAmpsPerVolt = (measuredCurrentValue * battAmpPerVolt.value) / vehicleCurrent.value if (newAmpsPerVolt != 0) { battAmpPerVolt.value = newAmpsPerVolt } } } } // Column } // QGCFlickable } // QGCViewDialog } // Component - calcAmpsPerVoltDlgComponent } // SetupPage