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