mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-19 14:25:14 +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
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]));
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue