diff --git a/locale/en/messages.json b/locale/en/messages.json index c5e53172e..e6fb10a66 100644 --- a/locale/en/messages.json +++ b/locale/en/messages.json @@ -735,6 +735,9 @@ "initialSetupMagCalibStarted": { "message": "Magnetometer calibration started" }, + "initialSetupMagFixedCalibStarted": { + "message": "Large vehicle Magnetometer calibration started" + }, "initialSetupMagCalibEnded": { "message": "Magnetometer calibration finished" }, @@ -2877,9 +2880,6 @@ "calibrationHead2": { "message": "Accelerometer Values" }, - "calibrationHead3": { - "message": "Level Calibration" - }, "calibrationHead4": { "message": "Compass Calibration" }, @@ -2926,6 +2926,9 @@ "MagXText": { "message": "Zero X" }, + "MagFixedText": { + "message": "True Heading in Degrees (0 - 359)" + }, "MagYText": { "message": "Zero Y" }, @@ -2948,16 +2951,16 @@ "message": "Reset Accelerometer Calibration" }, "MagCalText": { - "message": "After pressing the button you have 30 seconds to hold the model in the air and rotate it so that each side (front, back, left, right, top and bottom) points down towards the earth. Be sure that your compass is not near magnets or electromagnets when installed in the craft or performing the calibration." + "message": "After pressing the button 'Calibrate Compass' you have 30 seconds to hold the model in the air and rotate it so that each side (front, back, left, right, top and bottom) points down towards the earth. Be sure that your compass is not near magnets or electromagnets when installed in the craft or performing the calibration." + }, + "MagFixedCalText": { + "message": "Large or heavy vehicles are impractical to use the primary method and manually rotate all axles. This feature allows for very accurate calibration if the GPS has 3D Fix status and the vehicles actual heading is known. First make sure you have aligned (CLI Param 'align_mag') your Compass correctly. With the help of a compass (for example, the one on your smartphone) you must enter your vehicle heading. The heading entered should be TRUE, not MAGNETIC. Finally, click on the 'Large Vehicles Compass Calibration' button and wait for the calibration result." }, "MagBtn": { "message": "Calibrate Compass" }, - "LevCalText": { - "message": "Please put some Text hereā€¦" - }, - "LevBtn": { - "message": "Level calibration" + "FixedMagBtn": { + "message": "Large Vehicle Compass Calibration" }, "tabMixer": { "message": "Mixer" diff --git a/src/css/tabs/calibration.css b/src/css/tabs/calibration.css index 9f575d08d..144ef7293 100755 --- a/src/css/tabs/calibration.css +++ b/src/css/tabs/calibration.css @@ -178,10 +178,6 @@ margin-top: 10px; } -.tab-calibration #level_btn { - margin-top: 10px; - } - .tab-calibration .acc tr td { width: 25%; } diff --git a/tabs/calibration.html b/tabs/calibration.html index b0414cbaa..8d75a6a01 100755 --- a/tabs/calibration.html +++ b/tabs/calibration.html @@ -17,7 +17,8 @@
- +
@@ -54,15 +55,21 @@ - - - + + + - - - + + +
@@ -71,76 +78,85 @@ -
- -
-
-
-
-
- text -
-
- +
+ text +
+
+ +
+
+ text +

+ + + + + +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+
- - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
-
-
- text -
-
- +
+
+
+
+
+ text +
+
+ +
+ + + + + +
- - - - - -
diff --git a/tabs/calibration.js b/tabs/calibration.js index 4566fc416..a905d13da 100755 --- a/tabs/calibration.js +++ b/tabs/calibration.js @@ -230,16 +230,87 @@ TABS.calibration.initialize = function (callback) { if (FC.SENSOR_CONFIG.magnetometer === 0) { //Comment for test - $('#mag_btn, #mag-calibrated-data').css('pointer-events', 'none').css('opacity', '0.4'); + $('#mag_btn, #mag-calibrated-data, #magfixed_btn, #mag-fixed-calibrated-data').css('pointer-events', 'none').css('opacity', '0.4'); } if (FC.SENSOR_CONFIG.opflow === 0) { //Comment for test $('#opflow_btn, #opflow-calibrated-data').css('pointer-events', 'none').css('opacity', '0.4'); } + + $('#magfixed_btn').on('click', function () { + + const yawBoxIsEmpty = $('[name=YawFixedDegrees]').val().length === 0; + + if (yawBoxIsEmpty) { + GUI.log("Heading box value is empty!"); + return; + } + + if (!(FC.GPS_DATA.fix >= 2)) { + GUI.log("GPS without 3D Fix!"); + return; + } + + const yawBoxValue = parseInt($('[name=YawFixedDegrees]').val()); + + if (yawBoxValue > 360) { + GUI.log("Heading box value Min = 0 and Max = 360"); + return; + } + + var buffer = []; + + var button = $(this); + + $(button).addClass('disabled'); + + buffer.push(0x00FF & yawBoxValue); + buffer.push(yawBoxValue >> 8); + + MSP.send_message(MSPCodes.MSP_MAG_CALIBRATION, buffer, false, function () { + GUI.log(i18n.getMessage('initialSetupMagFixedCalibStarted')); + }); + + let modalProcessing = new jBox('Modal', { + width: 400, + height: 120, + animation: false, + closeOnClick: false, + closeOnEsc: false, + content: $('#modal-compass-processing').clone() + }).open(); + + var countdown = 1; + interval.add('compass_calibration_interval', function () { + countdown--; + if (countdown === 0) { + setTimeout(function () { + $(button).removeClass('disabled'); + + modalProcessing.close(); + GUI.log(i18n.getMessage('initialSetupMagCalibEnded')); + + MSP.send_message(MSPCodes.MSP_CALIBRATION_DATA, false, false, updateSensorData); + interval.remove('compass_calibration_interval'); + + //Cleanup + //delete modalProcessing; + $('.jBox-wrapper').remove(); + }, 1000); + } + + }, 1000); + }); $('#mag_btn').on('click', function () { - MSP.send_message(MSPCodes.MSP_MAG_CALIBRATION, false, false, function () { + var buffer = []; + + // 32767 = Indicates to INAV that sample calibration will be used + buffer.push(0x00FF & 32767); + buffer.push(32767 >> 8); + + MSP.send_message(MSPCodes.MSP_MAG_CALIBRATION, buffer, false, function () { GUI.log(i18n.getMessage('initialSetupMagCalibStarted')); });