Add sensor / range finder information at Setup tab (#3410)

* Show sonar at setup.js

* Changed logic for , seperator

* Changed logic for , seperator
master
HThuren 2023-04-09 21:34:05 +02:00 committed by GitHub
parent c20d527343
commit 56338c2de6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 8 deletions

View File

@ -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",

View File

@ -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:

View File

@ -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 (appendComma) {
sensor_e.append(', ');
}
if(have_sensor(FC.CONFIG.activeSensors, "mag") && FC.SENSOR_CONFIG.mag_hardware > 1) {
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() {