Skip to main content

LightLevel

A sensor that measures luminosity level.

import { LightLevel } from "@devicescript/core"

const lightLevel = new LightLevel()

Registers

reading

Detect light level

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

  • read only

import { LightLevel } from "@devicescript/core"

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

const lightLevel = new LightLevel()
// ...
lightLevel.reading.subscribe(async (value) => {
...
})
note

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

readingError

Absolute estimated error of the reading value

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

  • optional: this register may not be implemented

  • read only

import { LightLevel } from "@devicescript/core"

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

const lightLevel = new LightLevel()
// ...
lightLevel.readingError.subscribe(async (value) => {
...
})
note

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

variant

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

const lightLevel = new LightLevel()
// ...
const value = await lightLevel.variant.read()
note

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