mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-19 14:25:14 +03:00
Move src files
This commit is contained in:
parent
aab2a993c8
commit
24c81375a4
371 changed files with 120 additions and 120 deletions
34
src/js/port_usage.js
Normal file
34
src/js/port_usage.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
'use strict';
|
||||
|
||||
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.bytesReceived - this.previous_received) * 10 / serial.bitrate) * 100);
|
||||
var port_usage_up = parseInt(((serial.bytesSent - this.previous_sent) * 10 / serial.bitrate) * 100);
|
||||
|
||||
this.previous_received = serial.bytesReceived;
|
||||
this.previous_sent = serial.bytesSent;
|
||||
|
||||
// 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]));
|
||||
} else {
|
||||
$('span.port_usage_down').text(chrome.i18n.getMessage('statusbar_usage_download', [0]));
|
||||
$('span.port_usage_up').text(chrome.i18n.getMessage('statusbar_usage_upload', [0]));
|
||||
}
|
||||
},
|
||||
reset: function() {
|
||||
this.previous_received = 0;
|
||||
this.previous_sent = 0;
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue