Show sonar altitude, if sensor exist (#3414)

* Show sonar altitude, if sensor exist

* Review resolved
master
HThuren 2023-04-12 18:50:45 +02:00 committed by GitHub
parent 1406dc07b4
commit db97687d17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 1 deletions

View File

@ -1037,6 +1037,16 @@
"message": "Shows GPS info, if proper activated in Ports tab, Configuration Tab and GPS tab",
"description": "Message that pops up to describe the GPS section"
},
"initialSetupSonarHead": {
"message": "Sonar"
},
"initialSetupSonarHeadHelp": {
"message": "Shows Sonar info, if proper activated in Configuration Tab",
"description": "Message that pops up to describe the Sonar section"
},
"initialSetupAltitudeSonar": {
"message": "Altitude"
},
"initialSetupInstrumentsHead": {
"message": "Instruments"
},

View File

@ -35,7 +35,7 @@ const MSPCodes = {
MSP_SET_CF_SERIAL_CONFIG: 55,
MSP_VOLTAGE_METER_CONFIG: 56,
MSP_SET_VOLTAGE_METER_CONFIG: 57,
MSP_SONAR: 58,
MSP_SONAR: 58, // notice, in firmware named as MSP_SONAR_ALTITUDE
MSP_PID_CONTROLLER: 59,
MSP_SET_PID_CONTROLLER: 60,
MSP_ARMING_CONFIG: 61,

View File

@ -199,6 +199,7 @@ setup.initialize = function (callback) {
roll_e = $('dd.roll'),
pitch_e = $('dd.pitch'),
heading_e = $('dd.heading'),
sonar_e = $('.sonarAltitude'),
// Sensor info
sensor_e = $('.sensor-hw'),
// Firmware info
@ -399,6 +400,11 @@ setup.initialize = function (callback) {
showSensorInfo();
showFirmwareInfo();
// Show Sonar info box if sensor exist
if (! have_sensor(FC.CONFIG.activeSensors, 'sonar')) {
$('.sonarBox').hide();
}
function get_slow_data() {
// Status info is acquired in the background using update_live_status() in serial_backend.js
@ -437,6 +443,12 @@ setup.initialize = function (callback) {
self.renderModel();
self.updateInstruments();
});
// get Sonar altitude if sensor exist
if (have_sensor(FC.CONFIG.activeSensors, 'sonar')) {
MSP.send_message(MSPCodes.MSP_SONAR, false, false, function () {
sonar_e.text(`${FC.SENSOR_DATA.sonar.toFixed(1)} cm`);
});
}
}
GUI.interval_add('setup_data_pull_fast', get_fast_data, 33, true); // 30 fps

View File

@ -139,6 +139,22 @@
</table>
</div>
</div>
<div class="gui_box grey sonarBox">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="initialSetupSonarHead"></div>
<div class="helpicon cf_tip" i18n_title="initialSetupSonarHeadHelp"></div>
</div>
<div class="spacer_box">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="cf_table">
<tbody>
<tr>
<td id="sonarAltitude" i18n="initialSetupAltitudeSonar"></td>
<td class="sonarAltitude">0.0 cm</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="initialSetupInfoHead"></div>