Fix calibration button

There was an issue with the calibration button on _some_ flight controllers; after performing a fresh installation of INAV. This issue did not appear on my test F405-WING. I have moved the check to the FC object, and added extra checks for the default accelerometer values. Works as expected on my test FC.
pull/1664/head
Darren Lines 2 years ago
parent aebe7903d6
commit 5e039ec702

@ -763,6 +763,24 @@ var FC = {
return retVal;
},
getAccelerometerCalibrated: function () {
var calibrated = true;
var flagNames = FC.getArmingFlags();
if (CALIBRATION_DATA.accGain.X === 4096 && CALIBRATION_DATA.accGain.Y === 4096 && CALIBRATION_DATA.accGain.Z === 4096 &&
CALIBRATION_DATA.accZero.X === 0 && CALIBRATION_DATA.accZero.Y === 0 && CALIBRATION_DATA.accZero.Z === 0
) {
calibrated = false;
}
if ((calibrated) && flagNames.hasOwnProperty(13)) {
if (bit_check(CONFIG.armingFlags, 13)) {
calibrated = false;
}
}
return calibrated;
},
getUserControlMode: function () {
return [
"Attitude",

@ -176,24 +176,16 @@ TABS.calibration.initialize = function (callback) {
}
function setupCalibrationButton(callback) {
let showCalibrate = false;
var flagNames = FC.getArmingFlags();
if (flagNames.hasOwnProperty(13)) {
if (bit_check(CONFIG.armingFlags, 13)) {
showCalibrate = true;
}
}
if (showCalibrate) {
$('#calibrate-start-button').html(chrome.i18n.getMessage("AccBtn"));
$('#calibrate-start-button').prop("title", chrome.i18n.getMessage("AccBtn"));
$('#calibrate-start-button').addClass("calibrate");
$('#calibrate-start-button').removeClass("resetCalibration");
} else {
if (FC.getAccelerometerCalibrated()) {
$('#calibrate-start-button').html(chrome.i18n.getMessage("AccResetBtn"));
$('#calibrate-start-button').prop("title", chrome.i18n.getMessage("AccResetBtn"));
$('#calibrate-start-button').removeClass("calibrate");
$('#calibrate-start-button').addClass("resetCalibration");
} else {
$('#calibrate-start-button').html(chrome.i18n.getMessage("AccBtn"));
$('#calibrate-start-button').prop("title", chrome.i18n.getMessage("AccBtn"));
$('#calibrate-start-button').addClass("calibrate");
$('#calibrate-start-button').removeClass("resetCalibration");
}
if (callback) callback();

Loading…
Cancel
Save