utilizing tab_switch_cleanup functionality
parent
36604ca724
commit
0f23b5f5d9
21
js/gui.js
21
js/gui.js
|
@ -124,6 +124,27 @@ GUI_control.prototype.timeout_kill_all = function() {
|
|||
GUI_control.prototype.tab_switch_cleanup = function(callback) {
|
||||
switch (this.active_tab) {
|
||||
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
|
||||
|
||||
chrome.serial.write(connectionId, bufferOut, function(writeInfo) {
|
||||
if (callback) {
|
||||
// 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;
|
||||
callback();
|
||||
}, 3000);
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
if (callback) {
|
||||
|
|
63
js/main.js
63
js/main.js
|
@ -44,41 +44,40 @@ $(document).ready(function() {
|
|||
return;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
||||
// Disable any active "data pulling" timer
|
||||
disable_timers();
|
||||
|
||||
// Disable CLI (there is no "nicer way of doing so right now)
|
||||
if (CLI_active == true) {
|
||||
leave_CLI();
|
||||
}
|
||||
|
||||
// Disable previous active button
|
||||
$('li', tabs).removeClass('active');
|
||||
|
||||
// Highlight selected button
|
||||
$(this).parent().addClass('active');
|
||||
|
||||
if ($(this).parent().hasClass('tab_initial_setup')) {
|
||||
$('#content').load("./tabs/initial_setup.html", tab_initialize_initial_setup);
|
||||
} else if ($(this).parent().hasClass('tab_pid_tuning')) {
|
||||
$('#content').load("./tabs/pid_tuning.html", tab_initialize_pid_tuning);
|
||||
} else if ($(this).parent().hasClass('tab_receiver')) {
|
||||
$('#content').load("./tabs/receiver.html", tab_initialize_receiver);
|
||||
} else if ($(this).parent().hasClass('tab_auxiliary_configuration')) {
|
||||
$('#content').load("./tabs/auxiliary_configuration.html", tab_initialize_auxiliary_configuration);
|
||||
} else if ($(this).parent().hasClass('tab_servos')) {
|
||||
$('#content').load("./tabs/servos.html", tab_initialize_servos);
|
||||
} else if ($(this).parent().hasClass('tab_gps')) {
|
||||
$('#content').load("./tabs/gps.html", tab_initialize_gps);
|
||||
} else if ($(this).parent().hasClass('tab_motor_outputs')) {
|
||||
$('#content').load("./tabs/motor_outputs.html", tab_initialize_motor_outputs);
|
||||
} else if ($(this).parent().hasClass('tab_sensors')) {
|
||||
$('#content').load("./tabs/sensors.html", tab_initialize_sensors);
|
||||
} else if ($(this).parent().hasClass('tab_cli')) {
|
||||
$('#content').load("./tabs/cli.html", tab_initialize_cli);
|
||||
} else if ($(this).parent().hasClass('tab_about')) {
|
||||
$('#content').load("./tabs/about.html", tab_initialize_about);
|
||||
}
|
||||
GUI.tab_switch_cleanup(function() {
|
||||
// Disable previous active button
|
||||
$('li', tabs).removeClass('active');
|
||||
|
||||
// Highlight selected button
|
||||
$(self).parent().addClass('active');
|
||||
|
||||
if ($(self).parent().hasClass('tab_initial_setup')) {
|
||||
$('#content').load("./tabs/initial_setup.html", tab_initialize_initial_setup);
|
||||
} else if ($(self).parent().hasClass('tab_pid_tuning')) {
|
||||
$('#content').load("./tabs/pid_tuning.html", tab_initialize_pid_tuning);
|
||||
} else if ($(self).parent().hasClass('tab_receiver')) {
|
||||
$('#content').load("./tabs/receiver.html", tab_initialize_receiver);
|
||||
} else if ($(self).parent().hasClass('tab_auxiliary_configuration')) {
|
||||
$('#content').load("./tabs/auxiliary_configuration.html", tab_initialize_auxiliary_configuration);
|
||||
} else if ($(self).parent().hasClass('tab_servos')) {
|
||||
$('#content').load("./tabs/servos.html", tab_initialize_servos);
|
||||
} else if ($(self).parent().hasClass('tab_gps')) {
|
||||
$('#content').load("./tabs/gps.html", tab_initialize_gps);
|
||||
} else if ($(self).parent().hasClass('tab_motor_outputs')) {
|
||||
$('#content').load("./tabs/motor_outputs.html", tab_initialize_motor_outputs);
|
||||
} else if ($(self).parent().hasClass('tab_sensors')) {
|
||||
$('#content').load("./tabs/sensors.html", tab_initialize_sensors);
|
||||
} else if ($(self).parent().hasClass('tab_cli')) {
|
||||
$('#content').load("./tabs/cli.html", tab_initialize_cli);
|
||||
} else if ($(self).parent().hasClass('tab_about')) {
|
||||
$('#content').load("./tabs/about.html", tab_initialize_about);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -144,13 +144,24 @@ $(document).ready(function() {
|
|||
|
||||
// Disable CLI (there is no "nicer way of doing so right now)
|
||||
if (CLI_active == true) {
|
||||
leave_CLI(function() {
|
||||
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
|
||||
|
||||
chrome.serial.write(connectionId, bufferOut, function(writeInfo) {
|
||||
chrome.serial.close(connectionId, onClosed);
|
||||
|
||||
clearTimeout(connection_delay);
|
||||
clearInterval(serial_poll);
|
||||
clearInterval(port_usage_poll);
|
||||
});
|
||||
});
|
||||
|
||||
CLI_active = false;
|
||||
} else {
|
||||
chrome.serial.close(connectionId, onClosed);
|
||||
|
||||
|
|
20
tabs/cli.js
20
tabs/cli.js
|
@ -98,26 +98,6 @@ function send_slowly(out_arr, i, timeout_needle) {
|
|||
}, timeout_needle * 5);
|
||||
}
|
||||
|
||||
function leave_CLI(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
|
||||
|
||||
chrome.serial.write(connectionId, bufferOut, function(writeInfo) {
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
|
||||
CLI_active = false;
|
||||
}
|
||||
|
||||
|
||||
/* Some info about handling line feeds and carriage return
|
||||
|
||||
line feed = LF = \n = 0x0A = 10
|
||||
|
|
Loading…
Reference in New Issue