Motion
This service is experimental and may change in the future.
A sensor, typically PIR, that detects object motion within a certain range
import { Motion } from "@devicescript/core"
const motion = new Motion()
Registers
reading
Reports is movement is currently detected by the sensor.
type:
Register<boolean>
(packing formatu8
)read only
import { Motion } from "@devicescript/core"
const motion = new Motion()
// ...
const value = await motion.reading.read()
- track incoming values
import { Motion } from "@devicescript/core"
const motion = new Motion()
// ...
motion.reading.subscribe(async (value) => {
...
})
write
and read
will block until a server is bound to the client.
maxDistance
Maximum distance where objects can be detected.
type:
Register<number>
(packing formatu16.16
)optional: this register may not be implemented
constant: the register value will not change (until the next reset)
read only
import { Motion } from "@devicescript/core"
const motion = new Motion()
// ...
const value = await motion.maxDistance.read()
write
and read
will block until a server is bound to the client.
angle
Opening of the field of view
type:
Register<number>
(packing formatu16
)optional: this register may not be implemented
constant: the register value will not change (until the next reset)
read only
import { Motion } from "@devicescript/core"
const motion = new Motion()
// ...
const value = await motion.angle.read()
write
and read
will block until a server is bound to the client.
variant
Type of physical sensor
type:
Register<number>
(packing formatu8
)optional: this register may not be implemented
constant: the register value will not change (until the next reset)
read only
import { Motion } from "@devicescript/core"
const motion = new Motion()
// ...
const value = await motion.variant.read()
write
and read
will block until a server is bound to the client.
Events
movement
A movement was detected.
motion.movement.subscribe(() => {
})