mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 12:25:13 +03:00
removing obsolete code
This commit is contained in:
parent
01a5c753aa
commit
3574953c38
2 changed files with 33 additions and 57 deletions
|
@ -1,5 +1,4 @@
|
||||||
var connectionId = -1;
|
var connectionId = -1;
|
||||||
var connection_delay = 0; // delay which defines "when" will the configurator request configurator data after connection was established
|
|
||||||
var configuration_received = false;
|
var configuration_received = false;
|
||||||
|
|
||||||
var CONFIG = {
|
var CONFIG = {
|
||||||
|
@ -89,10 +88,6 @@ var BATTERY = {
|
||||||
var CLI_active = false;
|
var CLI_active = false;
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
port_picker = $('div#port-picker .port select');
|
|
||||||
baud_picker = $('div#port-picker #baud');
|
|
||||||
delay_picker = $('div#port-picker #delay');
|
|
||||||
|
|
||||||
console.log('Scanning for new ports...');
|
console.log('Scanning for new ports...');
|
||||||
update_ports();
|
update_ports();
|
||||||
|
|
||||||
|
@ -100,9 +95,8 @@ $(document).ready(function() {
|
||||||
if (GUI.connect_lock != true) { // GUI control overrides the user control
|
if (GUI.connect_lock != true) { // GUI control overrides the user control
|
||||||
var clicks = $(this).data('clicks');
|
var clicks = $(this).data('clicks');
|
||||||
|
|
||||||
selected_port = String($(port_picker).val());
|
var selected_port = String($('div#port-picker .port select').val());
|
||||||
selected_baud = parseInt(baud_picker.val());
|
var selected_baud = parseInt($('div#port-picker #baud').val());
|
||||||
connection_delay = parseInt(delay_picker.val());
|
|
||||||
|
|
||||||
if (selected_port != '0') {
|
if (selected_port != '0') {
|
||||||
if (!clicks) {
|
if (!clicks) {
|
||||||
|
@ -120,7 +114,6 @@ $(document).ready(function() {
|
||||||
|
|
||||||
GUI.tab_switch_cleanup();
|
GUI.tab_switch_cleanup();
|
||||||
GUI.timeout_remove('connecting');
|
GUI.timeout_remove('connecting');
|
||||||
GUI.timeout_remove('connection_delay');
|
|
||||||
|
|
||||||
chrome.serial.close(connectionId, onClosed);
|
chrome.serial.close(connectionId, onClosed);
|
||||||
|
|
||||||
|
@ -160,23 +153,22 @@ function onOpen(openInfo) {
|
||||||
// save selected port with chrome.storage if the port differs
|
// save selected port with chrome.storage if the port differs
|
||||||
chrome.storage.local.get('last_used_port', function(result) {
|
chrome.storage.local.get('last_used_port', function(result) {
|
||||||
if (typeof result.last_used_port != 'undefined') {
|
if (typeof result.last_used_port != 'undefined') {
|
||||||
if (result.last_used_port != selected_port) {
|
if (result.last_used_port != GUI.connected_to) {
|
||||||
// last used port doesn't match the one found in local db, we will store the new one
|
// last used port doesn't match the one found in local db, we will store the new one
|
||||||
chrome.storage.local.set({'last_used_port': selected_port}, function() {
|
chrome.storage.local.set({'last_used_port': GUI.connected_to}, function() {
|
||||||
// Debug message is currently disabled (we dont need to spam the console log with that)
|
// Debug message is currently disabled (we dont need to spam the console log with that)
|
||||||
// console.log('Last selected port was saved in chrome.storage.');
|
// console.log('Last selected port was saved in chrome.storage.');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// variable isn't stored yet, saving
|
// variable isn't stored yet, saving
|
||||||
chrome.storage.local.set({'last_used_port': selected_port}, function() {
|
chrome.storage.local.set({'last_used_port': GUI.connected_to}, function() {
|
||||||
// Debug message is currently disabled (we dont need to spam the console log with that)
|
// Debug message is currently disabled (we dont need to spam the console log with that)
|
||||||
// console.log('Last selected port was saved in chrome.storage.');
|
// console.log('Last selected port was saved in chrome.storage.');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
GUI.timeout_add('connection_delay', function() {
|
|
||||||
// start polling
|
// start polling
|
||||||
GUI.interval_add('serial_read', readPoll, 10);
|
GUI.interval_add('serial_read', readPoll, 10);
|
||||||
GUI.interval_add('port_usage', port_usage, 1000);
|
GUI.interval_add('port_usage', port_usage, 1000);
|
||||||
|
@ -204,7 +196,6 @@ function onOpen(openInfo) {
|
||||||
$('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();
|
||||||
});
|
});
|
||||||
}, connection_delay * 1000);
|
|
||||||
} else {
|
} else {
|
||||||
console.log('Failed to open serial port');
|
console.log('Failed to open serial port');
|
||||||
notify('Failed to open serial port', 'red');
|
notify('Failed to open serial port', 'red');
|
||||||
|
@ -240,7 +231,7 @@ function readPoll() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function port_usage() {
|
function port_usage() {
|
||||||
var port_usage = (char_counter * 10 / selected_baud) * 100;
|
var port_usage = (char_counter * 10 / parseInt($('div#port-picker #baud').val())) * 100;
|
||||||
$('span.port-usage').html(parseInt(port_usage) + '%');
|
$('span.port-usage').html(parseInt(port_usage) + '%');
|
||||||
|
|
||||||
// reset counter
|
// reset counter
|
||||||
|
|
15
main.html
15
main.html
|
@ -68,21 +68,6 @@
|
||||||
<option value="300">300</option>
|
<option value="300">300</option>
|
||||||
</select>
|
</select>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<select id="delay" title="Timeout">
|
|
||||||
<option value="0">0</option>
|
|
||||||
<option value="1">1</option>
|
|
||||||
<option value="2">2</option>
|
|
||||||
<option value="3">3</option>
|
|
||||||
<option value="4">4</option>
|
|
||||||
<option value="5">5</option>
|
|
||||||
<option value="6">6</option>
|
|
||||||
<option value="7">7</option>
|
|
||||||
<option value="8">8</option>
|
|
||||||
<option value="9">9</option>
|
|
||||||
<option value="10">10</option>
|
|
||||||
</select>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<a class="connect" href="#" title="">Connect</a>
|
<a class="connect" href="#" title="">Connect</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue