cherry-pick Cooperate (#985)

* cooperate pause

* fix math

* update lastPause before pausing

* faster cooperation

Co-authored-by: Peli de Halleux <peli@DESKTOP-5B7QRAM.corp.microsoft.com>
This commit is contained in:
Peli de Halleux
2020-08-21 06:06:59 +02:00
committed by Peli de Halleux
parent 1db61720fc
commit f0821f8d6c
5 changed files with 19 additions and 10 deletions

View File

@ -21,8 +21,7 @@ namespace sensors.internal {
const now = control.millis();
if (now - this.lastQuery >= this.interval * 2)
this.queryAndUpdate(); // sensor poller is not allowed to run
if (now - this.lastPause >= this.interval * 5)
pause(1); // allow events to trigger
control.cooperate(); // allow events to trigger
}
private queryAndUpdate() {