diff --git a/src/js/tabs/setup.js b/src/js/tabs/setup.js index 3bdde312c77..017821b3ce0 100644 --- a/src/js/tabs/setup.js +++ b/src/js/tabs/setup.js @@ -145,12 +145,32 @@ setup.initialize = function (callback) { $('#mag_calib_rest').hide(); }); - GUI.timeout_add('button_reset', function () { - gui_log(i18n.getMessage('initialSetupMagCalibEnded')); - _self.removeClass('calibrating'); - $('#mag_calib_running').hide(); - $('#mag_calib_rest').show(); - }, 30000); + function isCalibrationRunning() { + return FC.CONFIG.armingDisableFlags & (1 << 12) ? true : false; + } + + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + let cycle = 0; + const cycleMax = 45; + const interval = 1000; + const intervalId = setInterval(function () { + if (cycle >= cycleMax || !isCalibrationRunning()) { + clearInterval(intervalId); + gui_log(i18n.getMessage('initialSetupMagCalibEnded')); + _self.removeClass('calibrating'); + $('#mag_calib_running').hide(); + $('#mag_calib_rest').show(); + } + cycle++; + }, interval); + } else { + GUI.timeout_add('button_reset', function () { + gui_log(i18n.getMessage('initialSetupMagCalibEnded')); + _self.removeClass('calibrating'); + $('#mag_calib_running').hide(); + $('#mag_calib_rest').show(); + }, 30000); + } } });