mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-23 00:05:22 +03:00
initial implementation of request delay balancer
This commit is contained in:
parent
d18d5657a4
commit
b14d26d530
3 changed files with 25 additions and 0 deletions
18
js/request_balancer.js
Normal file
18
js/request_balancer.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
function request_delay_balancer(refresh_period) {
|
||||
this.balance_to = refresh_period;
|
||||
this.request_t = 0;
|
||||
this.finished_t = 0;
|
||||
}
|
||||
|
||||
request_delay_balancer.prototype.requested = function() {
|
||||
this.request_t = millitime();
|
||||
};
|
||||
|
||||
request_delay_balancer.prototype.finished = function() {
|
||||
this.finished_t = millitime();
|
||||
};
|
||||
|
||||
request_delay_balancer.prototype.estimate = function() {
|
||||
var estimate = this.balance_to - (this.finished_t - this.request_t);
|
||||
return (estimate > 0) ? estimate : 0;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue