Better distance calculation
This commit is contained in:
parent
6bfa704a6a
commit
f732e580af
18
boosthub.js
18
boosthub.js
@ -203,20 +203,14 @@ class BoostHub extends Hub {
|
|||||||
|
|
||||||
this.emit("color", port.id, data[4]);
|
this.emit("color", port.id, data[4]);
|
||||||
|
|
||||||
let distance;
|
let distance = data[5],
|
||||||
if (data[7] > 0 && data[5] < 2) {
|
partial = data[7];
|
||||||
distance = Math.floor(20 - (data[7] * 2.85));
|
|
||||||
} else if (data[5] > 9) {
|
if (partial > 0) {
|
||||||
distance = 10;
|
distance += 1 / partial;
|
||||||
} else {
|
|
||||||
distance = Math.floor((20 + (data[5] * 18)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (distance > 130) {
|
this.emit("distance", port.id, distance * 25.4);
|
||||||
distance = 130;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.emit("distance", port.id, distance);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Consts.Devices.WEDO2_TILT:
|
case Consts.Devices.WEDO2_TILT:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user