5import QGroundControl.FactControls
6import QGroundControl.Controls
9 title: qsTr("Calculate Voltage Multiplier")
12 property int batteryIndex: 0
13 property var _controller: controller
14 property var _batteryFactGroup: controller.vehicle.getFactGroup("battery" + batteryIndex)
18 controller: _controller
19 batteryIndex: parent.batteryIndex
23 spacing: ScreenTools.defaultFontPixelHeight
26 Layout.preferredWidth: gridLayout.width
27 wrapMode: Text.WordWrap
28 text: qsTr("Measure battery voltage using an external voltmeter and enter the value below. Click Calculate to set the new adjusted voltage multiplier.")
32 Layout.preferredWidth: gridLayout.width
33 wrapMode: Text.WordWrap
34 visible: !_batteryFactGroup || _batteryFactGroup.voltage.value === 0
35 text: qsTr("Vehicle voltage telemetry is not available. Connect to a vehicle with a powered battery to enable automatic calculation.")
36 color: qgcPal.warningText
43 QGCLabel { text: qsTr("Measured voltage:") }
44 QGCTextField { id: measuredVoltage; numericValuesOnly: true }
47 text: qsTr("Vehicle voltage:")
48 visible: _batteryFactGroup && _batteryFactGroup.voltage.value !== 0
51 text: _batteryFactGroup ? _batteryFactGroup.voltage.valueString : ""
52 visible: _batteryFactGroup && _batteryFactGroup.voltage.value !== 0
55 QGCLabel { text: qsTr("Voltage multiplier:") }
56 FactLabel { fact: batParams.battVoltMult }
60 text: qsTr("Calculate And Set")
61 enabled: _batteryFactGroup && _batteryFactGroup.voltage.value !== 0
64 let measuredVoltageValue = parseFloat(measuredVoltage.text)
65 if (measuredVoltageValue === 0 || isNaN(measuredVoltageValue)) {
68 let newVoltageMultiplier = (measuredVoltageValue * batParams.battVoltMult.value) / _batteryFactGroup.voltage.value
69 if (newVoltageMultiplier > 0) {
70 batParams.battVoltMult.value = newVoltageMultiplier