1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-13 19:40:22 +03:00

cleanup & improvements, callback approach

This commit is contained in:
cTn 2014-01-18 12:55:09 +01:00
parent 643a894730
commit e27f8019d7

View file

@ -235,7 +235,7 @@ function onOpen(openInfo) {
}); });
serial.onReceive.addListener(read_serial); serial.onReceive.addListener(read_serial);
GUI.interval_add('port_usage', port_usage, 1000); GUI.interval_add('port_usage', port_usage, 1000, true);
// disconnect after 10 seconds with error if we don't get IDENT data // disconnect after 10 seconds with error if we don't get IDENT data
GUI.timeout_add('connecting', function() { GUI.timeout_add('connecting', function() {
@ -247,17 +247,17 @@ function onOpen(openInfo) {
}, 10000); }, 10000);
// request configuration data // request configuration data
send_message(MSP_codes.MSP_UID, MSP_codes.MSP_UID); send_message(MSP_codes.MSP_UID, MSP_codes.MSP_UID, false, function() {
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS); // in theory this could be removed (MSP_STATUS is pulled in initial tab) send_message(MSP_codes.MSP_IDENT, MSP_codes.MSP_IDENT, false, function() {
send_message(MSP_codes.MSP_IDENT, MSP_codes.MSP_IDENT, false, function() { GUI.timeout_remove('connecting'); // kill connecting timer
GUI.timeout_remove('connecting'); // kill connecting timer
// Update UI elements that doesn't need consistent refreshing
// Update UI elements that doesn't need consistent refreshing $('.software-version').html(CONFIG.version);
$('.software-version').html(CONFIG.version);
configuration_received = true;
configuration_received = true; $('div#port-picker a.connect').text('Disconnect').addClass('active');
$('div#port-picker a.connect').text('Disconnect').addClass('active'); $('#tabs li a:first').click();
$('#tabs li a:first').click(); });
}); });
} else { } else {
console.log('Failed to open serial port'); console.log('Failed to open serial port');