diff --git a/locales/en/messages.json b/locales/en/messages.json index 29ff6251..e83656c9 100755 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -1404,7 +1404,7 @@ "message": "The magnetometer alignment is the orientation of the magnetometer sensor on the flight controller board. The default is usually correct, but if you have a custom build or a flight controller with a different magnetometer orientation, you may need to adjust this setting." }, "configurationMagDeclination": { - "message": "Magnetometer Declination" + "message": "Magnetic Declination" }, "configurationMagDeclinationInput": { "message": "Declination Degrees" diff --git a/src/js/tabs/gps.js b/src/js/tabs/gps.js index 4a74b76d..788c5115 100644 --- a/src/js/tabs/gps.js +++ b/src/js/tabs/gps.js @@ -20,10 +20,6 @@ gps.initialize = async function (callback) { GUI.active_tab = "gps"; await MSP.promise(MSPCodes.MSP_FEATURE_CONFIG); - - // mag support added in 1.46 - const hasMag = have_sensor(FC.CONFIG.activeSensors, "mag") && semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46); - await MSP.promise(MSPCodes.MSP_GPS_CONFIG); load_html(); @@ -48,6 +44,9 @@ gps.initialize = async function (callback) { // translate to user-selected languageconsole.log('Online'); i18n.localizePage(); + const hasMag = + have_sensor(FC.CONFIG.activeSensors, "mag") && semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46); + function get_raw_gps_data() { MSP.send_message(MSPCodes.MSP_RAW_GPS, false, false, get_comp_gps_data); } @@ -65,7 +64,15 @@ gps.initialize = async function (callback) { } function get_imu_data() { - MSP.send_message(MSPCodes.MSP_RAW_IMU, false, false, update_ui); + MSP.send_message(MSPCodes.MSP_RAW_IMU, false, false, get_mag_data); + } + + function get_mag_data() { + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + MSP.send_message(MSPCodes.MSP_COMPASS_CONFIG, false, false, update_ui); + } else { + update_ui(); + } } // GPS Configuration @@ -338,6 +345,13 @@ gps.initialize = async function (callback) { if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { const positionalDop = FC.GPS_DATA.positionalDop / 100; $(".GPS_info td.positionalDop").text(`${positionalDop.toFixed(2)}`); + if (hasMag) { + $(".GPS_info td.magDeclination").text( + `${FC.COMPASS_CONFIG.mag_declination.toFixed(1)} ${gpsUnitText}`, + ); + } else { + $(".GPS_info td.magDeclination").parent().hide(); + } } updateSignalStrengths(); @@ -367,14 +381,7 @@ gps.initialize = async function (callback) { } // enable data pulling - GUI.interval_add( - "gps_pull", - function gps_update() { - get_raw_gps_data(); - }, - 75, - true, - ); + GUI.interval_add("gps_pull", get_raw_gps_data, 100, true); //check for internet connection on load if (ispConnected()) { diff --git a/src/tabs/gps.html b/src/tabs/gps.html index 211b75da..70905925 100755 --- a/src/tabs/gps.html +++ b/src/tabs/gps.html @@ -117,6 +117,10 @@