Fix ultrasonic value to use cm instead of 0.1 cm units (#110)

* Fix simulator

* use 250 instead of 255
This commit is contained in:
Sam El-Husseini
2017-12-18 20:30:56 -08:00
committed by Peli de Halleux
parent b07f157181
commit 0529759a80
6 changed files with 19 additions and 11 deletions

View File

@ -25,7 +25,7 @@ namespace sensors {
}
_query(): number {
return this.getNumber(NumberFormat.UInt16LE, 0) & 0x0fff;
return (this.getNumber(NumberFormat.UInt16LE, 0) & 0x0fff) * 0.1; // range is 0..2550, in 0.1 cm increments.
}
_update(prev: number, curr: number) {
@ -86,7 +86,7 @@ namespace sensors {
distance(): number {
// it supposedly also has an inch mode, but we stick to cm
this._setMode(0)
return this.getNumber(NumberFormat.UInt16LE, 0) & 0x0fff; // range is 0..255
return (this.getNumber(NumberFormat.UInt16LE, 0) & 0x0fff) * 0.1; // range is 0..2550, in 0.1 cm increments.
}
}