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:
committed by
Peli de Halleux
parent
b07f157181
commit
0529759a80
@ -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.
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user