basic ports view (#115)

* basic ports view

* slight adjustement of rendering
This commit is contained in:
Peli de Halleux
2017-12-19 14:26:57 -08:00
committed by GitHub
parent eac3e183c3
commit d78d9c8686
7 changed files with 43 additions and 6 deletions

View File

@ -25,7 +25,7 @@ namespace sensors {
}
_query(): number {
return (this.getNumber(NumberFormat.UInt16LE, 0) & 0x0fff) * 0.1; // range is 0..2550, in 0.1 cm increments.
return ((this.getNumber(NumberFormat.UInt16LE, 0) & 0x0fff) / 10) >> 0; // range is 0..2550, in 0.1 cm increments.
}
_update(prev: number, curr: number) {
@ -80,7 +80,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) * 0.1; // range is 0..2550, in 0.1 cm increments.
return this._query();
}
}