Merge pull request #119 from gaelj/BF_Show_CPU_load

Implement MSP_STATUS_EX to display CPU load
10.3.x-maintenance
borisbstyle 2016-07-17 23:25:52 +02:00 committed by GitHub
commit 91bd81bcfa
4 changed files with 38 additions and 9 deletions

View File

@ -214,6 +214,9 @@
"statusbar_cycle_time": {
"message": "Cycle Time:"
},
"statusbar_cpu_load": {
"message": "CPU Load: $1%"
},
"dfu_connect_message": {
"message": "Please use the Firmware Flasher to access DFU devices"

View File

@ -88,6 +88,7 @@ var MSP_codes = {
MSP_RC_DEADBAND: 125,
MSP_SENSOR_ALIGNMENT: 126,
MSP_LED_STRIP_MODECOLOR:127,
MSP_STATUS_EX: 150,
MSP_SET_RAW_RC: 200,
MSP_SET_RAW_GPS: 201,
@ -288,6 +289,21 @@ var MSP = {
$('span.i2c-error').text(CONFIG.i2cError);
$('span.cycle-time').text(CONFIG.cycleTime);
break;
case MSP_codes.MSP_STATUS_EX:
CONFIG.cycleTime = data.getUint16(0, 1);
CONFIG.i2cError = data.getUint16(2, 1);
CONFIG.activeSensors = data.getUint16(4, 1);
CONFIG.mode = data.getUint32(6, 1);
CONFIG.profile = data.getUint8(10);
CONFIG.cpuload = data.getUint16(11, 1);
$('select[name="profilechange"]').val(CONFIG.profile);
sensor_status(CONFIG.activeSensors);
$('span.i2c-error').text(CONFIG.i2cError);
$('span.cycle-time').text(CONFIG.cycleTime);
$('span.cpu-load').text(chrome.i18n.getMessage('statusbar_cpu_load', [CONFIG.cpuload]));
break;
case MSP_codes.MSP_RAW_IMU:
// 512 for mpu6050, 256 for mma
// currently we are unable to differentiate between the sensor types, so we are goign with 512
@ -1201,7 +1217,6 @@ var MSP = {
case MSP_codes.MSP_SET_NAME:
console.log('Name set');
break;
default:
console.log('Unknown code detected: ' + code);
} else {

View File

@ -73,6 +73,8 @@ $(document).ready(function () {
// Reset various UI elements
$('span.i2c-error').text(0);
$('span.cycle-time').text(0);
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0"))
$('span.cpu-load').text('');
// unlock port select & baud
$('div#port-picker #port').prop('disabled', false);
@ -250,6 +252,9 @@ function onConnect() {
$('#tabs ul.mode-disconnected').hide();
$('#tabs ul.mode-connected').show();
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0"))
MSP.send_message(MSP_codes.MSP_STATUS_EX, false, false);
else
MSP.send_message(MSP_codes.MSP_STATUS, false, false);
MSP.send_message(MSP_codes.MSP_DATAFLASH_SUMMARY, false, false);
@ -432,6 +437,9 @@ function update_live_status() {
if (GUI.active_tab != 'cli') {
MSP.send_message(MSP_codes.MSP_BOXNAMES, false, false);
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0"))
MSP.send_message(MSP_codes.MSP_STATUS_EX, false, false);
else
MSP.send_message(MSP_codes.MSP_STATUS, false, false);
MSP.send_message(MSP_codes.MSP_ANALOG, false, false);
}

View File

@ -250,6 +250,9 @@
<div>
<span i18n="statusbar_cycle_time"></span> <span class="cycle-time">0</span>
</div>
<div>
<span class="cpu-load"> </span>
</div>
<div class="version">
<!-- configuration version generated here -->
</div>