Skip to main content

Distance

A sensor that determines the distance of an object without any physical contact involved.

import { Distance } from "@devicescript/core"

const distance = new Distance()

Registers

reading

Current distance from the object

  • type: Register<number> (packing format u16.16)

  • read only

import { Distance } from "@devicescript/core"

const distance = new Distance()
// ...
const value = await distance.reading.read()
  • track incoming values
import { Distance } from "@devicescript/core"

const distance = new Distance()
// ...
distance.reading.subscribe(async (value) => {
...
})
note

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

readingError

Absolute error on the reading value.

  • type: Register<number> (packing format u16.16)

  • optional: this register may not be implemented

  • read only

import { Distance } from "@devicescript/core"

const distance = new Distance()
// ...
const value = await distance.readingError.read()
  • track incoming values
import { Distance } from "@devicescript/core"

const distance = new Distance()
// ...
distance.readingError.subscribe(async (value) => {
...
})
note

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

minReading

Minimum measurable distance

  • type: Register<number> (packing format u16.16)

  • optional: this register may not be implemented

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

  • read only

import { Distance } from "@devicescript/core"

const distance = new Distance()
// ...
const value = await distance.minReading.read()
note

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

maxReading

Maximum measurable distance

  • type: Register<number> (packing format u16.16)

  • optional: this register may not be implemented

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

  • read only

import { Distance } from "@devicescript/core"

const distance = new Distance()
// ...
const value = await distance.maxReading.read()
note

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

variant

Determines the type of sensor used.

  • 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 { Distance } from "@devicescript/core"

const distance = new Distance()
// ...
const value = await distance.variant.read()
note

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