diff --git a/src/js/fc.js b/src/js/fc.js index d3d8ccc5..fc19d195 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -313,7 +313,6 @@ const FC = { cno: [], }; - this.VOLTAGE_METERS = []; this.VOLTAGE_METER_CONFIGS = []; this.CURRENT_METERS = []; @@ -538,6 +537,7 @@ const FC = { acc_hardware: 0, baro_hardware: 0, mag_hardware: 0, + sonar_hardware: 0, }; this.RX_CONFIG = { @@ -767,7 +767,6 @@ const FC = { return name; }, - MCU_TYPES: { 0: "SIMULATOR", 1: "F40X", diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index b7841780..63669de2 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -1170,6 +1170,9 @@ MspHelper.prototype.process_data = function(dataHandler) { FC.SENSOR_CONFIG.acc_hardware = data.readU8(); FC.SENSOR_CONFIG.baro_hardware = data.readU8(); FC.SENSOR_CONFIG.mag_hardware = data.readU8(); + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + FC.SENSOR_CONFIG.sonar_hardware = data.readU8(); + } break; case MSPCodes.MSP_LED_STRIP_CONFIG: diff --git a/src/js/tabs/setup.js b/src/js/tabs/setup.js index 2c7eb100..c11f0830 100644 --- a/src/js/tabs/setup.js +++ b/src/js/tabs/setup.js @@ -326,19 +326,42 @@ setup.initialize = function (callback) { 'MPU925X_AK8963', ]; + let sonarElements = [ + 'NONE', + 'HCSR04', + 'TFMINI', + 'TF02', + ]; + MSP.send_message(MSPCodes.MSP_SENSOR_CONFIG, false, false, function() { // Sensor info + let appendComma = false; sensor_e.text(''); - if(have_sensor(FC.CONFIG.activeSensors, "acc") && FC.SENSOR_CONFIG.acc_hardware > 1) { - sensor_e.append(i18n.getMessage('sensorStatusAccelShort'), ': ', accElements[[FC.SENSOR_CONFIG.acc_hardware]], ', '); + if (have_sensor(FC.CONFIG.activeSensors, "acc") && FC.SENSOR_CONFIG.acc_hardware > 1) { + sensor_e.append(i18n.getMessage('sensorStatusAccelShort'), ': ', accElements[[FC.SENSOR_CONFIG.acc_hardware]]); + appendComma = true; } - if(have_sensor(FC.CONFIG.activeSensors, "baro") && FC.SENSOR_CONFIG.baro_hardware > 1) { - sensor_e.append(i18n.getMessage('sensorStatusBaroShort'), ': ', baroElements[[FC.SENSOR_CONFIG.baro_hardware]], ', '); + if (have_sensor(FC.CONFIG.activeSensors, "baro") && FC.SENSOR_CONFIG.baro_hardware > 1) { + if (appendComma) { + sensor_e.append(', '); + } + sensor_e.append(i18n.getMessage('sensorStatusBaroShort'), ': ', baroElements[[FC.SENSOR_CONFIG.baro_hardware]]); + appendComma = true; } - if(have_sensor(FC.CONFIG.activeSensors, "mag") && FC.SENSOR_CONFIG.mag_hardware > 1) { + if (have_sensor(FC.CONFIG.activeSensors, "mag") && FC.SENSOR_CONFIG.mag_hardware > 1) { + if (appendComma) { + sensor_e.append(', '); + } sensor_e.append(i18n.getMessage('sensorStatusMagShort'), ': ', magElements[[FC.SENSOR_CONFIG.mag_hardware]]); + appendComma = true; } - }); + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46) && have_sensor(FC.CONFIG.activeSensors, "sonar") && FC.SENSOR_CONFIG.sonar_hardware > 1) { + if (appendComma) { + sensor_e.append(', '); + } + sensor_e.append(i18n.getMessage('sensorStatusSonarShort'), ': ', sonarElements[[FC.SENSOR_CONFIG.sonar_hardware]]); + } +}); }; const showFirmwareInfo = function() {