1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-23 00:05:22 +03:00

Added analytics for battery calibration.

This commit is contained in:
Michael Keller 2019-09-16 15:48:29 +12:00 committed by mikeller
parent 41d09d9796
commit fa0325c1c7
2 changed files with 45 additions and 1 deletions

View file

@ -3715,6 +3715,9 @@
"powerCalibrationManagerSourceNote": {
"message": "<span class=\"message-negative\">Warning:</span> Voltage and/or amperage meter sources <strong>have been changed but not saved.</strong> Please set the correct meter sources and save them before trying to calibrate."
},
"powerCalibrationManagerConfirmationTitle": {
"message": "Calibration Manager Confirmation"
},
"powerCalibrationSave": {
"message": "Calibrate"
},

View file

@ -2,6 +2,7 @@
TABS.power = {
supported: false,
analyticsChanges: {},
};
TABS.power.initialize = function (callback) {
@ -114,6 +115,14 @@ TABS.power.initialize = function (callback) {
$('input[name="vbatresdivmultiplier-' + index + '"]').val(voltageDataSource[index].vbatresdivmultiplier);
}
$('input[name="vbatscale-0"]').change(function () {
let value = parseInt($(this).val());
if (value !== voltageDataSource[0].vbatscale) {
self.analyticsChanges['PowerVBatUpdated'] = value;
}
});
// amperage meters
if (BATTERY_CONFIG.currentMeterSource == 0) {
$('.boxAmperageConfiguration').hide();
@ -164,6 +173,26 @@ TABS.power.initialize = function (callback) {
$('input[name="amperageoffset-' + index + '"]').val(currentDataSource[index].offset);
}
$('input[name="amperagescale-0"]').change(function () {
if (BATTERY_CONFIG.currentMeterSource === 1) {
let value = parseInt($(this).val());
if (value !== currentDataSource[0].scale) {
self.analyticsChanges['PowerAmperageUpdated'] = value;
}
}
});
$('input[name="amperagescale-1"]').change(function () {
if (BATTERY_CONFIG.currentMeterSource === 2) {
let value = parseInt($(this).val());
if (value !== currentDataSource[1].scale) {
self.analyticsChanges['PowerAmperageUpdated'] = value;
}
}
});
if(BATTERY_CONFIG.voltageMeterSource == 1 || BATTERY_CONFIG.currentMeterSource == 1 || BATTERY_CONFIG.currentMeterSource == 2) {
$('.calibration').show();
} else {
@ -324,7 +353,7 @@ TABS.power.initialize = function (callback) {
closeButton: 'title',
animation: false,
attach: $('#calibrate'),
title: 'Calibration Manager Confirmation',
title: i18n.getMessage('powerCalibrationManagerConfirmationTitle'),
content: $('#calibrationmanagerconfirmcontent'),
onCloseComplete: function() {
GUI.calibrationManager.close();
@ -409,6 +438,14 @@ TABS.power.initialize = function (callback) {
$('output[name="amperagenewscale"').val(amperagenewscale);
$('a.applycalibration').click(function() {
if (vbatscalechanged) {
self.analyticsChanges['PowerVBatUpdated'] = 'Calibrated';
}
if (amperagescalechanged) {
self.analyticsChanges['PowerAmperageUpdated'] = 'Calibrated';
}
calibrationconfirmed = true;
GUI.calibrationManagerConfirmation.close();
updateDisplay(VOLTAGE_METER_CONFIGS, CURRENT_METER_CONFIGS);
@ -440,6 +477,8 @@ TABS.power.initialize = function (callback) {
BATTERY_CONFIG.vbatwarningcellvoltage = parseFloat($('input[name="warningcellvoltage"]').val());
BATTERY_CONFIG.capacity = parseInt($('input[name="capacity"]').val());
analytics.sendChangeEvents(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, self.analyticsChanges);
save_power_config();
});
@ -483,6 +522,8 @@ TABS.power.initialize = function (callback) {
function process_html() {
initDisplay();
self.analyticsChanges = {};
// translate to user-selected language
i18n.localizePage();