utilizing tab_switch_cleanup functionality

10.3.x-maintenance
cTn 2013-11-09 06:14:21 +01:00
parent 36604ca724
commit 0f23b5f5d9
4 changed files with 65 additions and 54 deletions

View File

@ -124,6 +124,27 @@ GUI_control.prototype.timeout_kill_all = function() {
GUI_control.prototype.tab_switch_cleanup = function(callback) { GUI_control.prototype.tab_switch_cleanup = function(callback) {
switch (this.active_tab) { switch (this.active_tab) {
case 'cli': 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; break;
default: default:
if (callback) { if (callback) {

View File

@ -44,41 +44,40 @@ $(document).ready(function() {
return; return;
} }
var self = this;
// Disable any active "data pulling" timer // Disable any active "data pulling" timer
disable_timers(); disable_timers();
// Disable CLI (there is no "nicer way of doing so right now) GUI.tab_switch_cleanup(function() {
if (CLI_active == true) { // Disable previous active button
leave_CLI(); $('li', tabs).removeClass('active');
}
// Highlight selected button
// Disable previous active button $(self).parent().addClass('active');
$('li', tabs).removeClass('active');
if ($(self).parent().hasClass('tab_initial_setup')) {
// Highlight selected button $('#content').load("./tabs/initial_setup.html", tab_initialize_initial_setup);
$(this).parent().addClass('active'); } else if ($(self).parent().hasClass('tab_pid_tuning')) {
$('#content').load("./tabs/pid_tuning.html", tab_initialize_pid_tuning);
if ($(this).parent().hasClass('tab_initial_setup')) { } else if ($(self).parent().hasClass('tab_receiver')) {
$('#content').load("./tabs/initial_setup.html", tab_initialize_initial_setup); $('#content').load("./tabs/receiver.html", tab_initialize_receiver);
} else if ($(this).parent().hasClass('tab_pid_tuning')) { } else if ($(self).parent().hasClass('tab_auxiliary_configuration')) {
$('#content').load("./tabs/pid_tuning.html", tab_initialize_pid_tuning); $('#content').load("./tabs/auxiliary_configuration.html", tab_initialize_auxiliary_configuration);
} else if ($(this).parent().hasClass('tab_receiver')) { } else if ($(self).parent().hasClass('tab_servos')) {
$('#content').load("./tabs/receiver.html", tab_initialize_receiver); $('#content').load("./tabs/servos.html", tab_initialize_servos);
} else if ($(this).parent().hasClass('tab_auxiliary_configuration')) { } else if ($(self).parent().hasClass('tab_gps')) {
$('#content').load("./tabs/auxiliary_configuration.html", tab_initialize_auxiliary_configuration); $('#content').load("./tabs/gps.html", tab_initialize_gps);
} else if ($(this).parent().hasClass('tab_servos')) { } else if ($(self).parent().hasClass('tab_motor_outputs')) {
$('#content').load("./tabs/servos.html", tab_initialize_servos); $('#content').load("./tabs/motor_outputs.html", tab_initialize_motor_outputs);
} else if ($(this).parent().hasClass('tab_gps')) { } else if ($(self).parent().hasClass('tab_sensors')) {
$('#content').load("./tabs/gps.html", tab_initialize_gps); $('#content').load("./tabs/sensors.html", tab_initialize_sensors);
} else if ($(this).parent().hasClass('tab_motor_outputs')) { } else if ($(self).parent().hasClass('tab_cli')) {
$('#content').load("./tabs/motor_outputs.html", tab_initialize_motor_outputs); $('#content').load("./tabs/cli.html", tab_initialize_cli);
} else if ($(this).parent().hasClass('tab_sensors')) { } else if ($(self).parent().hasClass('tab_about')) {
$('#content').load("./tabs/sensors.html", tab_initialize_sensors); $('#content').load("./tabs/about.html", tab_initialize_about);
} 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);
}
} }
}); });

View File

@ -144,13 +144,24 @@ $(document).ready(function() {
// Disable CLI (there is no "nicer way of doing so right now) // Disable CLI (there is no "nicer way of doing so right now)
if (CLI_active == true) { 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); chrome.serial.close(connectionId, onClosed);
clearTimeout(connection_delay); clearTimeout(connection_delay);
clearInterval(serial_poll); clearInterval(serial_poll);
clearInterval(port_usage_poll); clearInterval(port_usage_poll);
}); });
CLI_active = false;
} else { } else {
chrome.serial.close(connectionId, onClosed); chrome.serial.close(connectionId, onClosed);

View File

@ -98,26 +98,6 @@ function send_slowly(out_arr, i, timeout_needle) {
}, timeout_needle * 5); }, 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 /* Some info about handling line feeds and carriage return
line feed = LF = \n = 0x0A = 10 line feed = LF = \n = 0x0A = 10