mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 12:55:19 +03:00
simplify some interval cleaning code
This commit is contained in:
parent
c6700a8588
commit
aca493301a
2 changed files with 6 additions and 46 deletions
43
js/gui.js
43
js/gui.js
|
@ -191,45 +191,10 @@ GUI_control.prototype.log = function(message) {
|
||||||
// default switch doesn't require callback to be set
|
// default switch doesn't require callback to be set
|
||||||
GUI_control.prototype.tab_switch_cleanup = function(callback) {
|
GUI_control.prototype.tab_switch_cleanup = function(callback) {
|
||||||
MSP.callbacks_cleanup(); // we don't care about any old data that might or might not arrive
|
MSP.callbacks_cleanup(); // we don't care about any old data that might or might not arrive
|
||||||
|
GUI.interval_kill_all(); // all intervals (mostly data pulling) needs to be removed on tab switch
|
||||||
|
|
||||||
switch (this.active_tab) {
|
switch (this.active_tab) {
|
||||||
case 'initial_setup':
|
|
||||||
GUI.interval_kill_all();
|
|
||||||
|
|
||||||
if (callback) callback();
|
|
||||||
break;
|
|
||||||
case 'pid_tuning':
|
|
||||||
GUI.interval_kill_all();
|
|
||||||
|
|
||||||
if (callback) callback();
|
|
||||||
break;
|
|
||||||
case 'receiver':
|
|
||||||
GUI.interval_kill_all();
|
|
||||||
|
|
||||||
if (callback) callback();
|
|
||||||
break;
|
|
||||||
case 'auxiliary_configuration':
|
|
||||||
GUI.interval_kill_all();
|
|
||||||
|
|
||||||
if (callback) callback();
|
|
||||||
break;
|
|
||||||
case 'servos':
|
|
||||||
GUI.interval_kill_all();
|
|
||||||
|
|
||||||
if (callback) callback();
|
|
||||||
break;
|
|
||||||
case 'gps':
|
|
||||||
GUI.interval_kill_all();
|
|
||||||
|
|
||||||
if (callback) callback();
|
|
||||||
break;
|
|
||||||
case 'motor_outputs':
|
|
||||||
GUI.interval_kill_all();
|
|
||||||
|
|
||||||
if (callback) callback();
|
|
||||||
break;
|
|
||||||
case 'sensors':
|
case 'sensors':
|
||||||
GUI.interval_kill_all();
|
|
||||||
serial.empty_output_buffer();
|
serial.empty_output_buffer();
|
||||||
|
|
||||||
// sensor data tab uses scrollbars, emptying the content before loading another tab
|
// sensor data tab uses scrollbars, emptying the content before loading another tab
|
||||||
|
@ -261,11 +226,6 @@ GUI_control.prototype.tab_switch_cleanup = function(callback) {
|
||||||
}, 5000); // if we dont allow enough time to reboot, CRC of "first" command sent will fail, keep an eye for this one
|
}, 5000); // if we dont allow enough time to reboot, CRC of "first" command sent will fail, keep an eye for this one
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'logging':
|
|
||||||
GUI.interval_kill_all();
|
|
||||||
|
|
||||||
if (callback) callback();
|
|
||||||
break;
|
|
||||||
case 'firmware_flasher':
|
case 'firmware_flasher':
|
||||||
PortHandler.flush_callbacks();
|
PortHandler.flush_callbacks();
|
||||||
|
|
||||||
|
@ -274,6 +234,7 @@ GUI_control.prototype.tab_switch_cleanup = function(callback) {
|
||||||
|
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ function tab_initialize_logging(callback) {
|
||||||
// print header for the csv file
|
// print header for the csv file
|
||||||
print_head();
|
print_head();
|
||||||
|
|
||||||
function poll_data() {
|
function log_data_poll() {
|
||||||
if (requests) {
|
if (requests) {
|
||||||
// save current data (only after everything is initialized)
|
// save current data (only after everything is initialized)
|
||||||
crunch_data();
|
crunch_data();
|
||||||
|
@ -73,8 +73,8 @@ function tab_initialize_logging(callback) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI.interval_add('log_data_pull', poll_data, parseInt($('select.speed').val()), true); // refresh rate goes here
|
GUI.interval_add('log_data_poll', log_data_poll, parseInt($('select.speed').val()), true); // refresh rate goes here
|
||||||
GUI.interval_add('flush_data', function() {
|
GUI.interval_add('write_data', function write_data() {
|
||||||
if (log_buffer.length) { // only execute when there is actual data to write
|
if (log_buffer.length) { // only execute when there is actual data to write
|
||||||
if (fileWriter.readyState == 0 || fileWriter.readyState == 2) {
|
if (fileWriter.readyState == 0 || fileWriter.readyState == 2) {
|
||||||
append_to_file(log_buffer.join('\n'));
|
append_to_file(log_buffer.join('\n'));
|
||||||
|
@ -95,8 +95,7 @@ function tab_initialize_logging(callback) {
|
||||||
GUI.log(chrome.i18n.getMessage('loggingErrorOneProperty'));
|
GUI.log(chrome.i18n.getMessage('loggingErrorOneProperty'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GUI.interval_remove('log_data_pull');
|
GUI.interval_kill_all();
|
||||||
GUI.interval_remove('flush_data');
|
|
||||||
|
|
||||||
$('.speed').prop('disabled', false);
|
$('.speed').prop('disabled', false);
|
||||||
$(this).text(chrome.i18n.getMessage('loggingStart'));
|
$(this).text(chrome.i18n.getMessage('loggingStart'));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue