mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-14 20:10:11 +03:00
removal of char_counter, new port_usage, i18n
added bitrate to serial object, removed last bits of 'port_handler' interval code forgotten in the kill routines, new port_usage is now saved in a separate file
This commit is contained in:
parent
241b44e893
commit
58d43c381b
11 changed files with 73 additions and 27 deletions
|
@ -4,5 +4,24 @@
|
|||
},
|
||||
"notifications_click_here_to_start_app": {
|
||||
"message": "Click here to start the application"
|
||||
},
|
||||
|
||||
"statusbar_port_utilization": {
|
||||
"message": "Port utilization:"
|
||||
},
|
||||
"statusbar_usage_download": {
|
||||
"message": "D: $1%"
|
||||
},
|
||||
"statusbar_usage_upload": {
|
||||
"message": "U: $1%"
|
||||
},
|
||||
"statusbar_packet_error": {
|
||||
"message": "Packet error:"
|
||||
},
|
||||
"statusbar_firmware_version": {
|
||||
"message": "Firmware Version:"
|
||||
},
|
||||
"statusbar_cycle_time": {
|
||||
"message": "Cycle Time:"
|
||||
}
|
||||
}
|
|
@ -254,7 +254,7 @@ GUI_control.prototype.tab_switch_cleanup = function(callback) {
|
|||
}
|
||||
break;
|
||||
case 'sensors':
|
||||
GUI.interval_kill_all(['port_usage']);
|
||||
GUI.interval_kill_all();
|
||||
serial.empty_output_buffer();
|
||||
|
||||
// sensor data tab uses scrollbars, emptying the content before loading another tab
|
||||
|
|
|
@ -51,9 +51,6 @@ var MSP_codes = {
|
|||
MSP_GPSSVINFO: 164 // get Signal Strength (only U-Blox)
|
||||
};
|
||||
|
||||
|
||||
var char_counter = 0; // this need to be redone or removed
|
||||
|
||||
var MSP = {
|
||||
state: 0,
|
||||
message_status: 1,
|
||||
|
@ -155,8 +152,6 @@ MSP.read = function(readInfo) {
|
|||
this.state = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
char_counter++;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
32
js/port_usage.js
Normal file
32
js/port_usage.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
var PortUsage = {
|
||||
previous_received: 0,
|
||||
previous_sent: 0,
|
||||
|
||||
initialize: function() {
|
||||
var self = this;
|
||||
|
||||
self.main_timer_reference = setInterval(function() {
|
||||
self.update();
|
||||
}, 1000);
|
||||
},
|
||||
update: function() {
|
||||
if (serial.bitrate) {
|
||||
var port_usage_down = parseInt(((serial.bytes_received - this.previous_received) * 10 / serial.bitrate) * 100);
|
||||
var port_usage_up = parseInt(((serial.bytes_sent - this.previous_sent) * 10 / serial.bitrate) * 100);
|
||||
|
||||
this.previous_received = serial.bytes_received;
|
||||
this.previous_sent = serial.bytes_sent;
|
||||
|
||||
// update UI
|
||||
$('span.port_usage_down').text(chrome.i18n.getMessage('statusbar_usage_download', [port_usage_down]));
|
||||
$('span.port_usage_up').text(chrome.i18n.getMessage('statusbar_usage_upload', [port_usage_up]));
|
||||
}
|
||||
},
|
||||
reset: function() {
|
||||
this.previous_received = 0;
|
||||
this.previous_sent = 0;
|
||||
|
||||
$('span.port_usage_down').text(chrome.i18n.getMessage('statusbar_usage_download', [0]));
|
||||
$('span.port_usage_up').text(chrome.i18n.getMessage('statusbar_usage_upload', [0]));
|
||||
}
|
||||
};
|
|
@ -1,5 +1,6 @@
|
|||
var serial = {
|
||||
connectionId: -1,
|
||||
bitrate: 0,
|
||||
bytes_received: 0,
|
||||
bytes_sent: 0,
|
||||
|
||||
|
@ -12,6 +13,7 @@ var serial = {
|
|||
chrome.serial.connect(path, options, function(connectionInfo) {
|
||||
if (connectionInfo !== undefined) {
|
||||
self.connectionId = connectionInfo.connectionId;
|
||||
self.bitrate = connectionInfo.bitrate;
|
||||
self.bytes_received = 0;
|
||||
self.bytes_sent = 0;
|
||||
|
||||
|
@ -48,6 +50,7 @@ var serial = {
|
|||
console.log('SERIAL: Statistics - Sent: ' + self.bytes_sent + ' bytes, Received: ' + self.bytes_received + ' bytes');
|
||||
|
||||
self.connectionId = -1;
|
||||
self.bitrate = 0;
|
||||
|
||||
callback(result);
|
||||
});
|
||||
|
|
|
@ -32,11 +32,11 @@ $(document).ready(function() {
|
|||
GUI.connected_to = false;
|
||||
|
||||
// Reset various UI elements
|
||||
$('span.port-usage').html('0%');
|
||||
$('.software-version').html('0.0');
|
||||
$('span.cycle-time').html('0');
|
||||
|
||||
MSP.disconnect_cleanup();
|
||||
PortUsage.reset();
|
||||
configuration_received = false; // reset valid config received variable (used to block tabs while not connected properly)
|
||||
|
||||
// unlock port select & baud
|
||||
|
@ -109,7 +109,9 @@ $(document).ready(function() {
|
|||
chrome.storage.local.set({'auto_connect': GUI.auto_connect});
|
||||
});
|
||||
});
|
||||
|
||||
PortHandler.initialize();
|
||||
PortUsage.initialize();
|
||||
});
|
||||
|
||||
function onOpen(openInfo) {
|
||||
|
@ -142,7 +144,6 @@ function onOpen(openInfo) {
|
|||
});
|
||||
|
||||
serial.onReceive.addListener(read_serial);
|
||||
GUI.interval_add('port_usage', port_usage, 1000, true);
|
||||
|
||||
// disconnect after 10 seconds with error if we don't get IDENT data
|
||||
GUI.timeout_add('connecting', function() {
|
||||
|
@ -203,14 +204,6 @@ function read_serial(info) {
|
|||
}
|
||||
}
|
||||
|
||||
function port_usage() {
|
||||
var port_usage = (char_counter * 10 / parseInt($('div#port-picker #baud').val())) * 100;
|
||||
$('span.port-usage').html(parseInt(port_usage) + '%');
|
||||
|
||||
// reset counter
|
||||
char_counter = 0;
|
||||
}
|
||||
|
||||
function sensor_status(sensors_detected) {
|
||||
// initialize variable (if it wasn't)
|
||||
if (typeof sensor_status.previous_sensors_detected == 'undefined') {
|
||||
|
|
|
@ -616,6 +616,8 @@ STM32_protocol.prototype.upload_procedure = function(step) {
|
|||
} else { // Something went wrong
|
||||
}
|
||||
|
||||
PortUsage.reset();
|
||||
|
||||
// unlocking connect button
|
||||
GUI.connect_lock = false;
|
||||
});
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<script type="text/javascript" src="./js/libraries/flotr2.min.js"></script>
|
||||
<script type="text/javascript" src="./js/libraries/jquery-2.1.0.min.js"></script>
|
||||
<script type="text/javascript" src="./js/port_handler.js"></script>
|
||||
<script type="text/javascript" src="./js/port_usage.js"></script>
|
||||
<script type="text/javascript" src="./js/serial.js"></script>
|
||||
<script type="text/javascript" src="./js/gui.js"></script>
|
||||
<script type="text/javascript" src="./js/serial_backend.js"></script>
|
||||
|
@ -117,10 +118,10 @@
|
|||
<div id="content">
|
||||
</div>
|
||||
<div id="status-bar">
|
||||
Port utilization: <span class="port-usage">0%</span> |
|
||||
Packet error: <span class="packet-error">0</span> |
|
||||
Firmware Version: <span class="software-version">0.0</span> |
|
||||
Cycle Time: <span class="cycle-time">0</span>
|
||||
<span i18n="statusbar_port_utilization"></span> <span class="port_usage_down">D: 0%</span> <span class="port_usage_up">U: 0%</span> |
|
||||
<span i18n="statusbar_packet_error"></span><span class="packet-error">0</span> |
|
||||
<span i18n="statusbar_firmware_version"></span><span class="software-version">0.0</span> |
|
||||
<span i18n="statusbar_cycle_time"></span><span class="cycle-time">0</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
3
main.js
3
main.js
|
@ -15,6 +15,9 @@ ga_tracker.sendAppView('Application Started');
|
|||
// Google Analytics stuff end
|
||||
|
||||
$(document).ready(function() {
|
||||
// translate to user-selected language
|
||||
localize();
|
||||
|
||||
// bind controls
|
||||
$('#frame .minimize').click(function() {
|
||||
chrome.app.window.current().minimize();
|
||||
|
|
|
@ -154,8 +154,6 @@ function handle_CLI(readInfo) {
|
|||
// try to catch part of valid CLI enter message
|
||||
CLI_validate_text += String.fromCharCode(data[i]);
|
||||
}
|
||||
|
||||
char_counter++;
|
||||
}
|
||||
|
||||
if (!CLI_valid && CLI_validate_text.indexOf('CLI') != -1) {
|
||||
|
|
|
@ -216,7 +216,7 @@ function tab_initialize_sensors() {
|
|||
chrome.storage.local.set({'sensor_refresh_rates': rates});
|
||||
|
||||
// timer initialization
|
||||
GUI.interval_kill_all(['port_handler', 'port_usage']);
|
||||
GUI.interval_kill_all();
|
||||
|
||||
// data pulling timers
|
||||
GUI.interval_add('status_pull', function status_data_pull() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue