diff --git a/locales/en/messages.json b/locales/en/messages.json index 1e58a99eab..41d446f157 100755 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -894,11 +894,32 @@ "initialSetupRSSI": { "message": "RSSI:" }, + "initialSetupRSSIValue": { + "message": "$1 dBm" + }, "initialSetupSensorHardware": { "message": "Sensors:" }, - "initialSetupRSSIValue": { - "message": "$1 %" + "initialSetupSensorGyro": { + "message": "Gyro:" + }, + "initialSetupSensorAcc": { + "message": "Acc:" + }, + "initialSetupSensorMag": { + "message": "Mag:" + }, + "initialSetupSensorBaro": { + "message": "Baro:" + }, + "initialSetupSensorGPS": { + "message": "GPS:" + }, + "initialSetupSensorSonar": { + "message": "Sonar:" + }, + "initialSetupSensorRadar": { + "message": "Radar:" }, "initialSetupArmingDisableFlags": { "message": "Arming Disable Flags:" diff --git a/src/js/fc.js b/src/js/fc.js index e388680794..2a596d5415 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -542,7 +542,7 @@ const FC = { sonar_hardware: 0, }; - this.SENSOR_CONFIG_ACTIVE = { ...this.SENSOR_CONFIG }; + this.SENSOR_CONFIG_ACTIVE = { gyro_hardware: 0, ...this.SENSOR_CONFIG }; this.RX_CONFIG = { serialrx_provider: 0, diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index f1e8e02747..be03d95e82 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -1163,12 +1163,19 @@ MspHelper.prototype.process_data = function(dataHandler) { } break; case MSPCodes.MSP2_SENSOR_CONFIG_ACTIVE: + FC.SENSOR_CONFIG_ACTIVE.gyro_hardware = data.readU8(); 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(); } + + console.log(FC.SENSOR_CONFIG_ACTIVE.gyro_hardware); + console.log(FC.SENSOR_CONFIG_ACTIVE.acc_hardware); + console.log(FC.SENSOR_CONFIG_ACTIVE.baro_hardware); + console.log(FC.SENSOR_CONFIG_ACTIVE.mag_hardware); + console.log(FC.SENSOR_CONFIG_ACTIVE.sonar_hardware); break; case MSPCodes.MSP_LED_STRIP_CONFIG: diff --git a/src/js/tabs/setup.js b/src/js/tabs/setup.js index 5013bfeb45..4758003914 100644 --- a/src/js/tabs/setup.js +++ b/src/js/tabs/setup.js @@ -200,7 +200,11 @@ setup.initialize = function (callback) { heading_e = $('dd.heading'), sonar_e = $('.sonarAltitude'), // Sensor info - sensor_e = $('.sensor-hw'), + sensor_gyro_e = $('.sensor_gyro_hw'), + sensor_acc_e = $('.sensor_acc_hw'), + sensor_mag_e = $('.sensor_mag_hw'), + sensor_baro_e = $('.sensor_baro_hw'), + sensor_sonar_e = $('.sensor_sonar_hw'), // Firmware info msp_api_e = $('.api-version'), build_date_e = $('.build-date'), @@ -277,7 +281,30 @@ setup.initialize = function (callback) { }; const showSensorInfo = function() { - let accElements = [ + const gyroElements = [ + 'NONE', + 'DEFAULT', + 'MPU6050', + 'L3G4200D', + 'MPU3050', + 'L3GD20', + 'MPU6000', + 'MPU6500', + 'MPU9250', + 'ICM20601', + 'ICM20602', + 'ICM20608G', + 'ICM20649', + 'ICM20689', + 'ICM42605', + 'ICM42688P', + 'BMI160', + 'BMI270', + 'LSM6DSO', + 'VIRTUAL', + ]; + + const accElements = [ 'DEFAULT', 'NONE', 'ADXL345', @@ -301,7 +328,7 @@ setup.initialize = function (callback) { 'VIRTUAL', ]; - let baroElements = [ + const baroElements = [ 'DEFAULT', 'NONE', 'BMP085', @@ -315,7 +342,7 @@ setup.initialize = function (callback) { 'VIRTUAL', ]; - let magElements = [ + const magElements = [ 'DEFAULT', 'NONE', 'HMC5883', @@ -327,47 +354,60 @@ setup.initialize = function (callback) { 'IST8310', ]; - let sonarElements = [ + const sonarElements = [ 'NONE', 'HCSR04', 'TFMINI', 'TF02', ]; - MSP.send_message(MSPCodes.MSP2_SENSOR_CONFIG_ACTIVE, false, false, function() { - // Sensor info - sensor_e.text(''); + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + MSP.send_message(MSPCodes.MSP2_SENSOR_CONFIG_ACTIVE, false, false, function() { + // Sensor info + const textNA = 'N/A'; + const textDisabled = 'disabled'; + + if (FC.SENSOR_CONFIG_ACTIVE.gyro_hardware == 0xFF) { + sensor_gyro_e.text(textNA); + } else if (have_sensor(FC.CONFIG.activeSensors, "gyro") && FC.SENSOR_CONFIG_ACTIVE.gyro_hardware > 1) { + sensor_gyro_e.text(gyroElements[FC.SENSOR_CONFIG_ACTIVE.gyro_hardware]); + } else { + sensor_gyro_e.text(textDisabled); + } - 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 (FC.SENSOR_CONFIG_ACTIVE.acc_hardware == 0xFF) { + sensor_acc_e.text(textNA); + } else if (have_sensor(FC.CONFIG.activeSensors, "acc") && FC.SENSOR_CONFIG_ACTIVE.acc_hardware > 1) { + sensor_acc_e.text(accElements[FC.SENSOR_CONFIG_ACTIVE.acc_hardware]); + } else { + sensor_acc_e.text(textDisabled); + } - 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 (FC.SENSOR_CONFIG_ACTIVE.baro_hardware == 0xFF) { + sensor_baro_e.text(textNA); + } else if (have_sensor(FC.CONFIG.activeSensors, "baro") && FC.SENSOR_CONFIG_ACTIVE.baro_hardware > 1) { + sensor_baro_e.text(baroElements[FC.SENSOR_CONFIG_ACTIVE.baro_hardware]); + } else { + sensor_baro_e.text(textDisabled); + } - 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 (FC.SENSOR_CONFIG_ACTIVE.mag_hardware == 0xFF) { + sensor_mag_e.text(textNA); + } else if (have_sensor(FC.CONFIG.activeSensors, "mag") && FC.SENSOR_CONFIG_ACTIVE.mag_hardware > 1) { + sensor_mag_e.text(magElements[FC.SENSOR_CONFIG_ACTIVE.mag_hardware]); + } else { + sensor_mag_e.text(textDisabled); + } - 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'); + sensor_sonar_e.text(textNA); } else 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_sonar_e.text(sonarElements[FC.SENSOR_CONFIG_ACTIVE.sonar_hardware]); + } else { + sensor_sonar_e.text(textDisabled); } - } - }); + }); + } }; const showFirmwareInfo = function() { diff --git a/src/tabs/setup.html b/src/tabs/setup.html index a1b500dd39..9184ab5cf8 100644 --- a/src/tabs/setup.html +++ b/src/tabs/setup.html @@ -184,10 +184,25 @@ 0 ℃ - - + + + + + + + + + + + + + + + + + + -