diff --git a/src/js/fc.js b/src/js/fc.js index 72faa27170c..e3886807947 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -153,6 +153,7 @@ const FC = { SDCARD: null, SENSOR_ALIGNMENT: null, SENSOR_CONFIG: null, + SENSOR_CONFIG_ACTIVE: null, SENSOR_DATA: null, SERIAL_CONFIG: null, SERVO_CONFIG: null, @@ -541,6 +542,8 @@ const FC = { sonar_hardware: 0, }; + this.SENSOR_CONFIG_ACTIVE = { ...this.SENSOR_CONFIG }; + this.RX_CONFIG = { serialrx_provider: 0, stick_max: 0, diff --git a/src/js/msp/MSPCodes.js b/src/js/msp/MSPCodes.js index fbde0dd9703..992b18debc8 100644 --- a/src/js/msp/MSPCodes.js +++ b/src/js/msp/MSPCodes.js @@ -184,20 +184,21 @@ const MSPCodes = { MSP_DEBUG: 254, // MSPv2 Common - MSP2_COMMON_SERIAL_CONFIG: 0x1009, - MSP2_COMMON_SET_SERIAL_CONFIG: 0x100A, + MSP2_COMMON_SERIAL_CONFIG: 0x1009, + MSP2_COMMON_SET_SERIAL_CONFIG: 0x100A, // MSPv2 Betaflight specific - MSP2_BETAFLIGHT_BIND: 0x3000, - MSP2_MOTOR_OUTPUT_REORDERING: 0x3001, - MSP2_SET_MOTOR_OUTPUT_REORDERING: 0x3002, - MSP2_SEND_DSHOT_COMMAND: 0x3003, - MSP2_GET_VTX_DEVICE_STATUS: 0x3004, - MSP2_GET_OSD_WARNINGS: 0x3005, - MSP2_GET_TEXT: 0x3006, - MSP2_SET_TEXT: 0x3007, - MSP2_GET_LED_STRIP_CONFIG_VALUES: 0x3008, - MSP2_SET_LED_STRIP_CONFIG_VALUES: 0x3009, + MSP2_BETAFLIGHT_BIND: 0x3000, + MSP2_MOTOR_OUTPUT_REORDERING: 0x3001, + MSP2_SET_MOTOR_OUTPUT_REORDERING: 0x3002, + MSP2_SEND_DSHOT_COMMAND: 0x3003, + MSP2_GET_VTX_DEVICE_STATUS: 0x3004, + MSP2_GET_OSD_WARNINGS: 0x3005, + MSP2_GET_TEXT: 0x3006, + MSP2_SET_TEXT: 0x3007, + MSP2_GET_LED_STRIP_CONFIG_VALUES: 0x3008, + MSP2_SET_LED_STRIP_CONFIG_VALUES: 0x3009, + MSP2_SENSOR_CONFIG_ACTIVE: 0x300A, // MSP2_GET_TEXT and MSP2_SET_TEXT variable types PILOT_NAME: 1, diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index 095b0952f4f..f1e8e02747a 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -1162,6 +1162,14 @@ MspHelper.prototype.process_data = function(dataHandler) { FC.SENSOR_CONFIG.sonar_hardware = data.readU8(); } break; + case MSPCodes.MSP2_SENSOR_CONFIG_ACTIVE: + FC.SENSOR_CONFIG_ACTIVE.acc_hardware = data.readU8(); + FC.SENSOR_CONFIG_ACTIVE.baro_hardware = data.readU8(); + FC.SENSOR_CONFIG_ACTIVE.mag_hardware = data.readU8(); + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + FC.SENSOR_CONFIG_ACTIVE.sonar_hardware = data.readU8(); + } + break; case MSPCodes.MSP_LED_STRIP_CONFIG: FC.LED_STRIP = []; diff --git a/src/js/tabs/setup.js b/src/js/tabs/setup.js index d2412b3e4a1..2e06fee27a3 100644 --- a/src/js/tabs/setup.js +++ b/src/js/tabs/setup.js @@ -334,33 +334,38 @@ setup.initialize = function (callback) { 'TF02', ]; - MSP.send_message(MSPCodes.MSP_SENSOR_CONFIG, false, false, function() { + MSP.send_message(MSPCodes.MSP2_SENSOR_CONFIG_ACTIVE, 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]]); - appendComma = true; + + sensor_e.append(`${i18n.getMessage('sensorStatusAccelShort')}: `); + if (FC.SENSOR_CONFIG_ACTIVE.acc_hardware == 0xFF) { + sensor_e.append('N/A'); + } else if (have_sensor(FC.CONFIG.activeSensors, "acc") && FC.SENSOR_CONFIG_ACTIVE.acc_hardware > 1) { + sensor_e.append(accElements[FC.SENSOR_CONFIG_ACTIVE.acc_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; + + sensor_e.append(`
${i18n.getMessage('sensorStatusBaroShort')}: `); + if (FC.SENSOR_CONFIG_ACTIVE.baro_hardware == 0xFF) { + sensor_e.append('N/A'); + } else if (have_sensor(FC.CONFIG.activeSensors, "baro") && FC.SENSOR_CONFIG_ACTIVE.baro_hardware > 1) { + sensor_e.append(baroElements[FC.SENSOR_CONFIG_ACTIVE.baro_hardware]); } - 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; + + sensor_e.append(`
${i18n.getMessage('sensorStatusMagShort')}: `); + if (FC.SENSOR_CONFIG_ACTIVE.mag_hardware == 0xFF) { + sensor_e.append('N/A'); + } else if (have_sensor(FC.CONFIG.activeSensors, "mag") && FC.SENSOR_CONFIG_ACTIVE.mag_hardware > 1) { + sensor_e.append(magElements[FC.SENSOR_CONFIG_ACTIVE.mag_hardware]); } - 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(', '); + + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + sensor_e.append(`
${i18n.getMessage('sensorStatusSonarShort')}: `); + if (FC.SENSOR_CONFIG_ACTIVE.sonar_hardware == 0xFF) { + sensor_e.append('N/A'); + } if (have_sensor(FC.CONFIG.activeSensors, "sonar") && FC.SENSOR_CONFIG_ACTIVE.sonar_hardware > 1) { + sensor_e.append(sonarElements[FC.SENSOR_CONFIG_ACTIVE.sonar_hardware]); } - sensor_e.append(i18n.getMessage('sensorStatusSonarShort'), ': ', sonarElements[[FC.SENSOR_CONFIG.sonar_hardware]]); } }); };