Skip to main content

PlanarPosition

caution

This service is experimental and may change in the future.

A sensor that repors 2D position, typically an optical mouse tracking sensor.

The sensor starts at an arbitrary origin (0,0) and reports the distance from that origin.

The streaming_interval is respected when the position is changing. When the position is not changing, the streaming interval may be throttled to 500ms.

import { PlanarPosition } from "@devicescript/core"

const planarPosition = new PlanarPosition()

Registers

reading

The current position of the sensor.

  • type: Register<any[]> (packing format i22.10 i22.10)

  • track incoming values

import { PlanarPosition } from "@devicescript/core"

const planarPosition = new PlanarPosition()
// ...
planarPosition.reading.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

variant

Specifies the type of physical sensor.

  • type: Register<number> (packing format u8)

  • optional: this register may not be implemented

  • constant: the register value will not change (until the next reset)

  • read only

import { PlanarPosition } from "@devicescript/core"

const planarPosition = new PlanarPosition()
// ...
const value = await planarPosition.variant.read()
note

write and read will block until a server is bound to the client.