mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-13 11:29:53 +03:00
adding support for connect_lock property in GUI
This commit is contained in:
parent
b6fb43993a
commit
75ff1dcc90
1 changed files with 40 additions and 38 deletions
|
@ -134,45 +134,47 @@ $(document).ready(function() {
|
|||
$('div#port-picker a.refresh').click();
|
||||
|
||||
$('div#port-picker a.connect').click(function() {
|
||||
var clicks = $(this).data('clicks');
|
||||
|
||||
selected_port = String($(port_picker).val());
|
||||
selected_baud = parseInt(baud_picker.val());
|
||||
connection_delay = parseInt(delay_picker.val());
|
||||
|
||||
if (selected_port != '0') {
|
||||
if (clicks) { // odd number of clicks
|
||||
// Disable any active "data pulling" timer
|
||||
disable_timers();
|
||||
|
||||
GUI.tab_switch_cleanup();
|
||||
|
||||
chrome.serial.close(connectionId, onClosed);
|
||||
|
||||
clearTimeout(connection_delay);
|
||||
clearInterval(serial_poll);
|
||||
clearInterval(port_usage_poll);
|
||||
|
||||
// Change port utilization to 0
|
||||
$('span.port-usage').html('0%');
|
||||
|
||||
// reset valid config received variable (used to block tabs while not connected properly)
|
||||
configuration_received = false;
|
||||
|
||||
$(this).text('Connect');
|
||||
$(this).removeClass('active');
|
||||
} else { // even number of clicks
|
||||
console.log('Connecting to: ' + selected_port);
|
||||
|
||||
chrome.serial.open(selected_port, {
|
||||
bitrate: selected_baud
|
||||
}, onOpen);
|
||||
|
||||
$(this).text('Disconnect');
|
||||
$(this).addClass('active');
|
||||
}
|
||||
if (GUI.connect_lock != true) { // GUI control overrides the user control
|
||||
var clicks = $(this).data('clicks');
|
||||
|
||||
$(this).data("clicks", !clicks);
|
||||
selected_port = String($(port_picker).val());
|
||||
selected_baud = parseInt(baud_picker.val());
|
||||
connection_delay = parseInt(delay_picker.val());
|
||||
|
||||
if (selected_port != '0') {
|
||||
if (clicks) { // odd number of clicks
|
||||
// Disable any active "data pulling" timer
|
||||
disable_timers();
|
||||
|
||||
GUI.tab_switch_cleanup();
|
||||
|
||||
chrome.serial.close(connectionId, onClosed);
|
||||
|
||||
clearTimeout(connection_delay);
|
||||
clearInterval(serial_poll);
|
||||
clearInterval(port_usage_poll);
|
||||
|
||||
// Change port utilization to 0
|
||||
$('span.port-usage').html('0%');
|
||||
|
||||
// reset valid config received variable (used to block tabs while not connected properly)
|
||||
configuration_received = false;
|
||||
|
||||
$(this).text('Connect');
|
||||
$(this).removeClass('active');
|
||||
} else { // even number of clicks
|
||||
console.log('Connecting to: ' + selected_port);
|
||||
|
||||
chrome.serial.open(selected_port, {
|
||||
bitrate: selected_baud
|
||||
}, onOpen);
|
||||
|
||||
$(this).text('Disconnect');
|
||||
$(this).addClass('active');
|
||||
}
|
||||
|
||||
$(this).data("clicks", !clicks);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue