mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 12:25:13 +03:00
hookup new cleanup system
This commit is contained in:
parent
31dcbbfa91
commit
75e0accf75
4 changed files with 33 additions and 46 deletions
46
js/gui.js
46
js/gui.js
|
@ -196,51 +196,7 @@ 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
|
GUI.interval_kill_all(); // all intervals (mostly data pulling) needs to be removed on tab switch
|
||||||
|
|
||||||
switch (this.active_tab) {
|
this.active_tab_ref.cleanup(callback);
|
||||||
case 'sensors':
|
|
||||||
serial.empty_output_buffer();
|
|
||||||
|
|
||||||
// sensor data tab uses scrollbars, emptying the content before loading another tab
|
|
||||||
// prevents scrollbar exposure to any of the tabs while new content is loaded in
|
|
||||||
$('#content').empty();
|
|
||||||
|
|
||||||
if (callback) callback();
|
|
||||||
break;
|
|
||||||
case 'cli':
|
|
||||||
var bufferOut = new ArrayBuffer(5);
|
|
||||||
var bufView = new Uint8Array(bufferOut);
|
|
||||||
|
|
||||||
bufView[0] = 0x65; // e
|
|
||||||
bufView[1] = 0x78; // x
|
|
||||||
bufView[2] = 0x69; // i
|
|
||||||
bufView[3] = 0x74; // t
|
|
||||||
bufView[4] = 0x0D; // enter
|
|
||||||
|
|
||||||
serial.send(bufferOut, function(writeInfo) {
|
|
||||||
// we could handle this "nicely", but this will do for now
|
|
||||||
// (another approach is however much more complicated):
|
|
||||||
// we can setup an interval asking for data lets say every 200ms, when data arrives, callback will be triggered and tab switched
|
|
||||||
// we could probably implement this someday
|
|
||||||
GUI.timeout_add('waiting_for_bootup', function() {
|
|
||||||
CLI_active = false;
|
|
||||||
CLI_valid = false;
|
|
||||||
|
|
||||||
if (callback) callback();
|
|
||||||
}, 5000); // if we dont allow enough time to reboot, CRC of "first" command sent will fail, keep an eye for this one
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case 'firmware_flasher':
|
|
||||||
PortHandler.flush_callbacks();
|
|
||||||
|
|
||||||
// unbind "global" events
|
|
||||||
$(document).unbind('keypress');
|
|
||||||
|
|
||||||
if (callback) callback();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if (callback) callback();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// initialize object into GUI variable
|
// initialize object into GUI variable
|
||||||
|
|
22
tabs/cli.js
22
tabs/cli.js
|
@ -85,7 +85,27 @@ tabs.cli.initialize = function(callback) {
|
||||||
};
|
};
|
||||||
|
|
||||||
tabs.cli.cleanup = function(callback) {
|
tabs.cli.cleanup = function(callback) {
|
||||||
if (callback) callback();
|
var bufferOut = new ArrayBuffer(5);
|
||||||
|
var bufView = new Uint8Array(bufferOut);
|
||||||
|
|
||||||
|
bufView[0] = 0x65; // e
|
||||||
|
bufView[1] = 0x78; // x
|
||||||
|
bufView[2] = 0x69; // i
|
||||||
|
bufView[3] = 0x74; // t
|
||||||
|
bufView[4] = 0x0D; // enter
|
||||||
|
|
||||||
|
serial.send(bufferOut, function(writeInfo) {
|
||||||
|
// we could handle this "nicely", but this will do for now
|
||||||
|
// (another approach is however much more complicated):
|
||||||
|
// we can setup an interval asking for data lets say every 200ms, when data arrives, callback will be triggered and tab switched
|
||||||
|
// we could probably implement this someday
|
||||||
|
GUI.timeout_add('waiting_for_bootup', function() {
|
||||||
|
CLI_active = false;
|
||||||
|
CLI_valid = false;
|
||||||
|
|
||||||
|
if (callback) callback();
|
||||||
|
}, 5000); // if we dont allow enough time to reboot, CRC of "first" command sent will fail, keep an eye for this one
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function send_slowly(out_arr, i, timeout_needle) {
|
function send_slowly(out_arr, i, timeout_needle) {
|
||||||
|
|
|
@ -237,6 +237,11 @@ tabs.firmware_flasher.initialize = function(callback) {
|
||||||
};
|
};
|
||||||
|
|
||||||
tabs.firmware_flasher.cleanup = function(callback) {
|
tabs.firmware_flasher.cleanup = function(callback) {
|
||||||
|
PortHandler.flush_callbacks();
|
||||||
|
|
||||||
|
// unbind "global" events
|
||||||
|
$(document).unbind('keypress');
|
||||||
|
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -414,5 +414,11 @@ tabs.sensors.initialize = function(callback) {
|
||||||
};
|
};
|
||||||
|
|
||||||
tabs.sensors.cleanup = function(callback) {
|
tabs.sensors.cleanup = function(callback) {
|
||||||
|
serial.empty_output_buffer();
|
||||||
|
|
||||||
|
// sensor data tab uses scrollbars, emptying the content before loading another tab
|
||||||
|
// prevents scrollbar exposure to any of the tabs while new content is loaded in
|
||||||
|
$('#content').empty();
|
||||||
|
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue