Skip to content

Commit 340087a

Browse files
authored
Merge pull request #2786 from PascalLuginbuehl/fix-battery-calibration
fix: battery calibration in power tab
2 parents 3018ac3 + 78c34ed commit 340087a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/js/tabs/power.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,14 @@ TABS.power.initialize = function (callback) {
396396

397397
let vbatscalechanged = false;
398398
let amperagescalechanged = false;
399+
let vbatnewscale = 0;
400+
let amperagenewscale = 0;
401+
399402
$('a.calibrate').click(function() {
400403
if (FC.BATTERY_CONFIG.voltageMeterSource == 1) {
401404
const vbatcalibration = parseFloat($('input[name="vbatcalibration"]').val());
402405
if (vbatcalibration != 0) {
403-
const vbatnewscale = Math.round(FC.VOLTAGE_METER_CONFIGS[0].vbatscale * (vbatcalibration / FC.VOLTAGE_METERS[0].voltage));
406+
vbatnewscale = Math.round(FC.VOLTAGE_METER_CONFIGS[0].vbatscale * (vbatcalibration / FC.VOLTAGE_METERS[0].voltage));
404407
if (vbatnewscale >= 10 && vbatnewscale <= 255) {
405408
FC.VOLTAGE_METER_CONFIGS[0].vbatscale = vbatnewscale;
406409
vbatscalechanged = true;
@@ -413,7 +416,7 @@ TABS.power.initialize = function (callback) {
413416
const amperageoffset = FC.CURRENT_METER_CONFIGS[ampsource - 1].offset / 1000;
414417
if (amperagecalibration != 0) {
415418
if (FC.CURRENT_METERS[ampsource - 1].amperage != amperageoffset && amperagecalibration != amperageoffset) {
416-
const amperagenewscale = Math.round(FC.CURRENT_METER_CONFIGS[ampsource - 1].scale *
419+
amperagenewscale = Math.round(FC.CURRENT_METER_CONFIGS[ampsource - 1].scale *
417420
((FC.CURRENT_METERS[ampsource - 1].amperage - amperageoffset) / (amperagecalibration - amperageoffset)));
418421
if (amperagenewscale > -16000 && amperagenewscale < 16000 && amperagenewscale != 0) {
419422
FC.CURRENT_METER_CONFIGS[ampsource - 1].scale = amperagenewscale;

0 commit comments

Comments
 (0)