Skip to content

Commit 56338c2

Browse files
authored
Add sensor / range finder information at Setup tab (#3410)
* Show sonar at setup.js * Changed logic for , seperator * Changed logic for , seperator
1 parent c20d527 commit 56338c2

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

src/js/fc.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ const FC = {
313313
cno: [],
314314
};
315315

316-
317316
this.VOLTAGE_METERS = [];
318317
this.VOLTAGE_METER_CONFIGS = [];
319318
this.CURRENT_METERS = [];
@@ -538,6 +537,7 @@ const FC = {
538537
acc_hardware: 0,
539538
baro_hardware: 0,
540539
mag_hardware: 0,
540+
sonar_hardware: 0,
541541
};
542542

543543
this.RX_CONFIG = {
@@ -767,7 +767,6 @@ const FC = {
767767
return name;
768768
},
769769

770-
771770
MCU_TYPES: {
772771
0: "SIMULATOR",
773772
1: "F40X",

src/js/msp/MSPHelper.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
11701170
FC.SENSOR_CONFIG.acc_hardware = data.readU8();
11711171
FC.SENSOR_CONFIG.baro_hardware = data.readU8();
11721172
FC.SENSOR_CONFIG.mag_hardware = data.readU8();
1173+
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) {
1174+
FC.SENSOR_CONFIG.sonar_hardware = data.readU8();
1175+
}
11731176
break;
11741177

11751178
case MSPCodes.MSP_LED_STRIP_CONFIG:

src/js/tabs/setup.js

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,19 +326,42 @@ setup.initialize = function (callback) {
326326
'MPU925X_AK8963',
327327
];
328328

329+
let sonarElements = [
330+
'NONE',
331+
'HCSR04',
332+
'TFMINI',
333+
'TF02',
334+
];
335+
329336
MSP.send_message(MSPCodes.MSP_SENSOR_CONFIG, false, false, function() {
330337
// Sensor info
338+
let appendComma = false;
331339
sensor_e.text('');
332-
if(have_sensor(FC.CONFIG.activeSensors, "acc") && FC.SENSOR_CONFIG.acc_hardware > 1) {
333-
sensor_e.append(i18n.getMessage('sensorStatusAccelShort'), ': ', accElements[[FC.SENSOR_CONFIG.acc_hardware]], ', ');
340+
if (have_sensor(FC.CONFIG.activeSensors, "acc") && FC.SENSOR_CONFIG.acc_hardware > 1) {
341+
sensor_e.append(i18n.getMessage('sensorStatusAccelShort'), ': ', accElements[[FC.SENSOR_CONFIG.acc_hardware]]);
342+
appendComma = true;
334343
}
335-
if(have_sensor(FC.CONFIG.activeSensors, "baro") && FC.SENSOR_CONFIG.baro_hardware > 1) {
336-
sensor_e.append(i18n.getMessage('sensorStatusBaroShort'), ': ', baroElements[[FC.SENSOR_CONFIG.baro_hardware]], ', ');
344+
if (have_sensor(FC.CONFIG.activeSensors, "baro") && FC.SENSOR_CONFIG.baro_hardware > 1) {
345+
if (appendComma) {
346+
sensor_e.append(', ');
347+
}
348+
sensor_e.append(i18n.getMessage('sensorStatusBaroShort'), ': ', baroElements[[FC.SENSOR_CONFIG.baro_hardware]]);
349+
appendComma = true;
337350
}
338-
if(have_sensor(FC.CONFIG.activeSensors, "mag") && FC.SENSOR_CONFIG.mag_hardware > 1) {
351+
if (have_sensor(FC.CONFIG.activeSensors, "mag") && FC.SENSOR_CONFIG.mag_hardware > 1) {
352+
if (appendComma) {
353+
sensor_e.append(', ');
354+
}
339355
sensor_e.append(i18n.getMessage('sensorStatusMagShort'), ': ', magElements[[FC.SENSOR_CONFIG.mag_hardware]]);
356+
appendComma = true;
340357
}
341-
});
358+
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46) && have_sensor(FC.CONFIG.activeSensors, "sonar") && FC.SENSOR_CONFIG.sonar_hardware > 1) {
359+
if (appendComma) {
360+
sensor_e.append(', ');
361+
}
362+
sensor_e.append(i18n.getMessage('sensorStatusSonarShort'), ': ', sonarElements[[FC.SENSOR_CONFIG.sonar_hardware]]);
363+
}
364+
});
342365
};
343366

344367
const showFirmwareInfo = function() {

0 commit comments

Comments
 (0)