mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 12:25:13 +03:00
fix firmware version, moved compass calibrate (#323)
This commit is contained in:
parent
8243e36d0e
commit
b669fa4d16
6 changed files with 147 additions and 108 deletions
|
@ -983,6 +983,10 @@ var mspHelper = (function (gui) {
|
|||
break;
|
||||
|
||||
case MSPCodes.MSP_CALIBRATION_DATA:
|
||||
if (semver.lte(CONFIG.flightControllerVersion, "1.8.0")) {
|
||||
break;
|
||||
}
|
||||
|
||||
var callibrations = data.getUint8(0);
|
||||
CALIBRATION_DATA.acc.Pos0 = (1 & (callibrations >> 0));
|
||||
CALIBRATION_DATA.acc.Pos1 = (1 & (callibrations >> 1));
|
||||
|
@ -2278,7 +2282,7 @@ var mspHelper = (function (gui) {
|
|||
};
|
||||
|
||||
self.loadCalibrationData = function (callback) {
|
||||
if (semver.gte(CONFIG.flightControllerVersion, "1.6.0")) {
|
||||
if (semver.gte(CONFIG.flightControllerVersion, "1.8.1")) {
|
||||
MSP.send_message(MSPCodes.MSP_CALIBRATION_DATA, false, false, callback);
|
||||
} else {
|
||||
callback();
|
||||
|
@ -2286,7 +2290,7 @@ var mspHelper = (function (gui) {
|
|||
};
|
||||
|
||||
self.saveCalibrationData = function (callback) {
|
||||
if (semver.gte(CONFIG.flightControllerVersion, "1.6.0")) {
|
||||
if (semver.gte(CONFIG.flightControllerVersion, "1.8.1")) {
|
||||
MSP.send_message(MSPCodes.MSP_SET_CALIBRATION_DATA, mspHelper.crunch(MSPCodes.MSP_SET_CALIBRATION_DATA), false, callback);
|
||||
} else {
|
||||
callback();
|
||||
|
|
|
@ -169,7 +169,7 @@
|
|||
}
|
||||
|
||||
.buttonarea {
|
||||
min-height: 100px;
|
||||
/*min-height: 100px; */
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
<div class="steptitle">Step 6</div>
|
||||
<div class="indicator"></div>
|
||||
</div>
|
||||
<div class="gui_box grey">
|
||||
<div class="gui_box grey" id="accPosAll">
|
||||
<div class="gui_box_titlebar">
|
||||
<div class="spacer_box_title" data-i18n="calibrationHead2"></div>
|
||||
</div>
|
||||
|
@ -120,7 +120,7 @@
|
|||
</div>
|
||||
<div class="content_toolbar">
|
||||
<div class="btn save_btn">
|
||||
<a class="save" href="#" data-i18n="configurationButtonSave"></a>
|
||||
<a id="calibrateButtonSave" class="save" href="#" data-i18n="configurationButtonSave"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -52,25 +52,49 @@ TABS.calibration.initialize = function (callback) {
|
|||
GUI.active_tab = 'calibration';
|
||||
googleAnalytics.sendAppView('Calibration');
|
||||
}
|
||||
if (semver.gte(CONFIG.flightControllerVersion, "1.8.1")) {
|
||||
loadChainer.setChain([
|
||||
mspHelper.loadStatus,
|
||||
mspHelper.loadCalibrationData
|
||||
]);
|
||||
loadChainer.setExitPoint(loadHtml);
|
||||
loadChainer.execute();
|
||||
|
||||
loadChainer.setChain([
|
||||
mspHelper.loadStatus,
|
||||
mspHelper.loadCalibrationData
|
||||
]);
|
||||
loadChainer.setExitPoint(loadHtml);
|
||||
loadChainer.execute();
|
||||
saveChainer.setChain([
|
||||
mspHelper.saveCalibrationData
|
||||
]);
|
||||
saveChainer.setExitPoint(reboot);
|
||||
|
||||
saveChainer.setChain([
|
||||
mspHelper.saveCalibrationData
|
||||
]);
|
||||
saveChainer.setExitPoint(loadChainer.execute);
|
||||
MSP.send_message(MSPCodes.MSP_IDENT, false, false, loadHtml);
|
||||
} else {
|
||||
loadChainer.setChain([
|
||||
mspHelper.loadStatus
|
||||
]);
|
||||
loadChainer.setExitPoint(loadHtml);
|
||||
loadChainer.execute();
|
||||
|
||||
saveChainer.setExitPoint(reboot);
|
||||
}
|
||||
|
||||
function reboot() {
|
||||
//noinspection JSUnresolvedVariable
|
||||
GUI.log(chrome.i18n.getMessage('configurationEepromSaved'));
|
||||
|
||||
GUI.tab_switch_cleanup(function() {
|
||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize);
|
||||
});
|
||||
}
|
||||
|
||||
function reinitialize() {
|
||||
//noinspection JSUnresolvedVariable
|
||||
GUI.log(chrome.i18n.getMessage('deviceRebooting'));
|
||||
GUI.handleReconnect($('.tab_calibration a'));
|
||||
}
|
||||
|
||||
function loadHtml() {
|
||||
$('#content').load("./tabs/calibration.html", processHtml);
|
||||
}
|
||||
|
||||
MSP.send_message(MSPCodes.MSP_IDENT, false, false, loadHtml);
|
||||
|
||||
function updateCalibrationSteps() {
|
||||
for (var i = 0; i < 6; i++) {
|
||||
var $element = $('[data-step="' + (i + 1) + '"]');
|
||||
|
@ -107,7 +131,99 @@ TABS.calibration.initialize = function (callback) {
|
|||
updateSensorData();
|
||||
}
|
||||
|
||||
//For 1.8.0
|
||||
function calibrate() {
|
||||
var self = $(this);
|
||||
|
||||
if (!self.hasClass('disabled')) {
|
||||
self.addClass('disabled');
|
||||
MSP.send_message(MSPCodes.MSP_ACC_CALIBRATION, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupAccelCalibStarted'));
|
||||
});
|
||||
|
||||
helper.timeout.add('button_reset', function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupAccelCalibEnded'));
|
||||
|
||||
self.removeClass('disabled');
|
||||
|
||||
if (!bit_check(CONFIG.armingFlags & 0xff00, 13)) {
|
||||
for (var i = 0; i < 6; i++) {
|
||||
CALIBRATION_DATA.acc['Pos' + i] = 1;
|
||||
}
|
||||
updateCalibrationSteps();
|
||||
}
|
||||
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
function calibrateNew() {
|
||||
var newStep = null,
|
||||
$button = $(this);
|
||||
|
||||
if (TABS.calibration.model.getStep() === null) {
|
||||
for (var i = 0; i < 6; i++) {
|
||||
if (CALIBRATION_DATA.acc['Pos' + i] === 1) {
|
||||
CALIBRATION_DATA.acc['Pos' + i] = 0;
|
||||
}
|
||||
}
|
||||
updateCalibrationSteps();
|
||||
modalStart = new jBox('Modal', {
|
||||
width: 400,
|
||||
height: 200,
|
||||
animation: false,
|
||||
closeOnClick: false,
|
||||
closeOnEsc: false,
|
||||
content: $('#modal-acc-calibration-start')
|
||||
}).open();
|
||||
} else {
|
||||
newStep = TABS.calibration.model.next();
|
||||
}
|
||||
|
||||
/*
|
||||
* Communication
|
||||
*/
|
||||
if (newStep !== null) {
|
||||
$button.addClass('disabled');
|
||||
|
||||
modalProcessing = new jBox('Modal', {
|
||||
width: 400,
|
||||
height: 100,
|
||||
animation: false,
|
||||
closeOnClick: false,
|
||||
closeOnEsc: false,
|
||||
content: $('#modal-acc-processing')
|
||||
}).open();
|
||||
|
||||
MSP.send_message(MSPCodes.MSP_ACC_CALIBRATION, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupAccelCalibStarted'));
|
||||
});
|
||||
|
||||
helper.timeout.add('acc_calibration_timeout', function () {
|
||||
$button.removeClass('disabled');
|
||||
|
||||
modalProcessing.close();
|
||||
MSP.send_message(MSPCodes.MSP_CALIBRATION_DATA, false, false, checkFinishAccCalibrate);
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupAccelCalibEnded'));
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
function processHtml() {
|
||||
$('#calibrateButtonSave').on('click', function () {
|
||||
saveChainer.execute();
|
||||
});
|
||||
|
||||
if (semver.lte(CONFIG.flightControllerVersion, "1.8.0")) {
|
||||
$('#accPosAll, #mag-calibrated-data').hide();
|
||||
|
||||
var accIsCalibrate = +(!bit_check(CONFIG.armingFlags & 0xff00, 13));
|
||||
for (var i = 0; i < 6; i++) {
|
||||
CALIBRATION_DATA.acc['Pos' + i] = accIsCalibrate;
|
||||
}
|
||||
|
||||
updateCalibrationSteps();
|
||||
}
|
||||
|
||||
if (SENSOR_CONFIG.magnetometer === 0) {
|
||||
//Comment for test
|
||||
|
@ -141,65 +257,14 @@ TABS.calibration.initialize = function (callback) {
|
|||
|
||||
modalProcessing.close();
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupMagCalibEnded'));
|
||||
MSP.send_message(MSPCodes.MSP_CALIBRATION_DATA, false, false, updateSensorData);
|
||||
if (semver.gte(CONFIG.flightControllerVersion, "1.8.1")) {
|
||||
MSP.send_message(MSPCodes.MSP_CALIBRATION_DATA, false, false, updateSensorData);
|
||||
}
|
||||
helper.interval.remove('compass_calibration_interval');
|
||||
}
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
$('#calibrate-start-button').click(function () {
|
||||
var newStep = null,
|
||||
$button = $(this);
|
||||
|
||||
if (TABS.calibration.model.getStep() === null) {
|
||||
for (var i = 0; i < 6; i++) {
|
||||
if (CALIBRATION_DATA.acc['Pos' + i] === 1) {
|
||||
CALIBRATION_DATA.acc['Pos' + i] = 0;
|
||||
}
|
||||
}
|
||||
updateCalibrationSteps();
|
||||
modalStart = new jBox('Modal', {
|
||||
width: 400,
|
||||
height: 200,
|
||||
animation: false,
|
||||
closeOnClick: false,
|
||||
closeOnEsc: false,
|
||||
content: $('#modal-acc-calibration-start')
|
||||
}).open();
|
||||
} else {
|
||||
newStep = TABS.calibration.model.next();
|
||||
}
|
||||
|
||||
/*
|
||||
* Communication
|
||||
*/
|
||||
if (newStep !== null) {
|
||||
$button.addClass('disabled');
|
||||
|
||||
modalProcessing = new jBox('Modal', {
|
||||
width: 400,
|
||||
height: 100,
|
||||
animation: false,
|
||||
closeOnClick: false,
|
||||
closeOnEsc: false,
|
||||
content: $('#modal-acc-processing')
|
||||
}).open();
|
||||
|
||||
MSP.send_message(MSPCodes.MSP_ACC_CALIBRATION, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupAccelCalibStarted'));
|
||||
});
|
||||
|
||||
helper.timeout.add('acc_calibration_timeout', function () {
|
||||
$button.removeClass('disabled');
|
||||
|
||||
modalProcessing.close();
|
||||
MSP.send_message(MSPCodes.MSP_CALIBRATION_DATA, false, false, checkFinishAccCalibrate);
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupAccelCalibEnded'));
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('#modal-start-button').click(function () {
|
||||
modalStart.close();
|
||||
TABS.calibration.model.next();
|
||||
|
@ -211,7 +276,13 @@ TABS.calibration.initialize = function (callback) {
|
|||
|
||||
// translate to user-selected language
|
||||
localize();
|
||||
MSP.send_message(MSPCodes.MSP_CALIBRATION_DATA, false, false, updateSensorData);
|
||||
if (semver.gte(CONFIG.flightControllerVersion, "1.8.1")) {
|
||||
$('#calibrate-start-button').on('click', calibrateNew);
|
||||
|
||||
MSP.send_message(MSPCodes.MSP_CALIBRATION_DATA, false, false, updateSensorData);
|
||||
} else {
|
||||
$('#calibrate-start-button').on('click', calibrate);
|
||||
}
|
||||
GUI.content_ready(callback);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -8,27 +8,12 @@
|
|||
</div>
|
||||
<div class="cf_column fourth buttonarea">
|
||||
<div class="spacer_right">
|
||||
<div class="default_btn">
|
||||
<div id="mag_calib_rest">
|
||||
<a class="calibrateMag" href="#" data-i18n="initialSetupButtonCalibrateMag"></a>
|
||||
</div>
|
||||
|
||||
<div id="mag_calib_running">
|
||||
<div class="data-loading-setup">
|
||||
<p>Calibrating...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="default_btn">
|
||||
<a class="resetSettings" href="#" data-i18n="initialSetupButtonReset"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="threefourth_right setupinfo">
|
||||
|
||||
<div class="cell_setup">
|
||||
<span data-i18n="initialSetupCalibrateMagText"></span>
|
||||
</div>
|
||||
<div class="cell_setup">
|
||||
<span data-i18n="initialSetupResetText"></span>
|
||||
</div>
|
||||
|
|
|
@ -54,27 +54,6 @@ TABS.setup.initialize = function (callback) {
|
|||
|
||||
self.initializeInstruments();
|
||||
|
||||
$('a.calibrateMag').click(function () {
|
||||
var self = $(this);
|
||||
|
||||
if (!self.hasClass('calibrating') && !self.hasClass('disabled')) {
|
||||
self.addClass('calibrating');
|
||||
|
||||
MSP.send_message(MSPCodes.MSP_MAG_CALIBRATION, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupMagCalibStarted'));
|
||||
$('#mag_calib_running').show();
|
||||
$('#mag_calib_rest').hide();
|
||||
});
|
||||
|
||||
helper.timeout.add('button_reset', function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupMagCalibEnded'));
|
||||
self.removeClass('calibrating');
|
||||
$('#mag_calib_running').hide();
|
||||
$('#mag_calib_rest').show();
|
||||
}, 30000);
|
||||
}
|
||||
});
|
||||
|
||||
$('a.resetSettings').click(function () {
|
||||
MSP.send_message(MSPCodes.MSP_RESET_CONF, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupSettingsRestored'));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue