5import QGroundControl.FactControls
6import QGroundControl.Controls
10 title: qsTr("Calculate Amps per Volt")
13 property int batteryIndex: 1
14 property var _controller: controller
15 property var _batteryFactGroup: controller.vehicle.getFactGroup("battery" + (batteryIndex - 1))
19 controller: _controller
20 batteryIndex: popupDialog.batteryIndex
24 spacing: ScreenTools.defaultFontPixelHeight
27 Layout.preferredWidth: gridLayout.width
28 wrapMode: Text.WordWrap
29 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.")
36 QGCLabel { text: qsTr("Measured current:") }
37 QGCTextField { id: measuredCurrent; numericValuesOnly: true }
39 QGCLabel { text: qsTr("Vehicle current:") }
40 QGCLabel { text: _batteryFactGroup.current.valueString }
42 QGCLabel { text: qsTr("Amps per volt:") }
43 FactLabel { fact: batParams.battAmpsPerVolt }
47 text: qsTr("Calculate")
50 var measuredCurrentValue = parseFloat(measuredCurrent.text)
51 if (measuredCurrentValue === 0 || isNaN(measuredCurrentValue)) {
54 var newAmpsPerVolt = (measuredCurrentValue * batParams.battAmpsPerVolt.value) / _batteryFactGroup.current.value
55 if (newAmpsPerVolt != 0) {
56 batParams.battAmpsPerVolt.value = newAmpsPerVolt