5import QGroundControl.FactControls
6import QGroundControl.Controls
9 title: qsTr("Calculate Amps per Volt")
12 property int batteryIndex: 1
13 property var _controller: controller
14 property var _batteryFactGroup: controller.vehicle.getFactGroup("battery" + (batteryIndex - 1))
18 controller: _controller
19 batteryIndex: parent.batteryIndex
23 spacing: ScreenTools.defaultFontPixelHeight
26 Layout.preferredWidth: gridLayout.width
27 wrapMode: Text.WordWrap
28 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.")
35 QGCLabel { text: qsTr("Measured current:") }
36 QGCTextField { id: measuredCurrent; numericValuesOnly: true }
38 QGCLabel { text: qsTr("Vehicle current:") }
39 QGCLabel { text: _batteryFactGroup.current.valueString }
41 QGCLabel { text: qsTr("Amps per volt:") }
42 FactLabel { fact: batParams.battAmpsPerVolt }
46 text: qsTr("Calculate")
49 var measuredCurrentValue = parseFloat(measuredCurrent.text)
50 if (measuredCurrentValue === 0 || isNaN(measuredCurrentValue)) {
53 var newAmpsPerVolt = (measuredCurrentValue * batParams.battAmpsPerVolt.value) / _batteryFactGroup.current.value
54 if (newAmpsPerVolt != 0) {
55 batParams.battAmpsPerVolt.value = newAmpsPerVolt