Compass
caution
This service is rc and may change in the future.
A sensor that measures the heading.
import { Compass } from "@devicescript/core"
const compass = new Compass()
Commands
calibrate
Starts a calibration sequence for the compass.
compass.calibrate(): Promise<void>
Registers
reading
The heading with respect to the magnetic north.
type:
Register<number>
(packing formatu16.16
)read only
import { Compass } from "@devicescript/core"
const compass = new Compass()
// ...
const value = await compass.reading.read()
- track incoming values
import { Compass } from "@devicescript/core"
const compass = new Compass()
// ...
compass.reading.subscribe(async (value) => {
...
})
note
write
and read
will block until a server is bound to the client.
enabled
Turn on or off the sensor. Turning on the sensor may start a calibration sequence.
type:
Register<boolean>
(packing formatu8
)read and write
import { Compass } from "@devicescript/core"
const compass = new Compass()
// ...
const value = await compass.enabled.read()
await compass.enabled.write(value)
- track incoming values
import { Compass } from "@devicescript/core"
const compass = new Compass()
// ...
compass.enabled.subscribe(async (value) => {
...
})
note
write
and read
will block until a server is bound to the client.
readingError
Error on the heading reading
type:
Register<number>
(packing formatu16.16
)optional: this register may not be implemented
read only
import { Compass } from "@devicescript/core"
const compass = new Compass()
// ...
const value = await compass.readingError.read()
- track incoming values
import { Compass } from "@devicescript/core"
const compass = new Compass()
// ...
compass.readingError.subscribe(async (value) => {
...
})
note
write
and read
will block until a server is bound to the client.