Skip to main content

Led

A controller for displays of individually controlled RGB LEDs.

For 64 or less LEDs, the service should support the pack the pixels in the pixels register. Beyond this size, the register should return an empty payload as the amount of data exceeds the size of a packet. Typically services that use more than 64 LEDs will run on the same MCU and will maintain the pixels buffer internally.

import { Led } from "@devicescript/core"

const led = new Led()
note

Additional runtime support is provided for Led by importing the @devicescript/runtime package.

Please refer to the LEDs developer documentation.

import { Led } from "@devicescript/core"
import "@devicescript/runtime"

const led = new Led()

Registers

pixels

A buffer of 24bit RGB color entries for each LED, in R, G, B order. When writing, if the buffer is too short, the remaining pixels are set to #000000; If the buffer is too long, the write may be ignored, or the additional pixels may be ignored. If the number of pixels is greater than max_pixels_length, the read should return an empty payload.

  • type: Register<Buffer> (packing format b)

  • track incoming values

import { Led } from "@devicescript/core"

const led = new Led()
// ...
led.pixels.subscribe(async (value) => {
...
})
note

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

intensity

Set the luminosity of the strip. At 0 the power to the strip is completely shut down.

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

  • read and write

import { Led } from "@devicescript/core"

const led = new Led()
// ...
const value = await led.intensity.read()
await led.intensity.write(value)
  • track incoming values
import { Led } from "@devicescript/core"

const led = new Led()
// ...
led.intensity.subscribe(async (value) => {
...
})
note

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

actualBrightness

This is the luminosity actually applied to the strip. May be lower than brightness if power-limited by the max_power register. It will rise slowly (few seconds) back to brightness is limits are no longer required.

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

  • read only

import { Led } from "@devicescript/core"

const led = new Led()
// ...
const value = await led.actualBrightness.read()
  • track incoming values
import { Led } from "@devicescript/core"

const led = new Led()
// ...
led.actualBrightness.subscribe(async (value) => {
...
})
note

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

numPixels

Specifies the number of pixels in the strip.

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

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

  • read only

import { Led } from "@devicescript/core"

const led = new Led()
// ...
const value = await led.numPixels.read()
note

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

numColumns

If the LED pixel strip is a matrix, specifies the number of columns.

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

  • optional: this register may not be implemented

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

  • read only

import { Led } from "@devicescript/core"

const led = new Led()
// ...
const value = await led.numColumns.read()
note

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

maxPower

Limit the power drawn by the light-strip (and controller).

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

  • optional: this register may not be implemented

  • read and write

import { Led } from "@devicescript/core"

const led = new Led()
// ...
const value = await led.maxPower.read()
await led.maxPower.write(value)
  • track incoming values
import { Led } from "@devicescript/core"

const led = new Led()
// ...
led.maxPower.subscribe(async (value) => {
...
})
note

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

ledsPerPixel

If known, specifies the number of LEDs in parallel on this device. The actual number of LEDs is num_pixels * leds_per_pixel.

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

  • optional: this register may not be implemented

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

  • read only

import { Led } from "@devicescript/core"

const led = new Led()
// ...
const value = await led.ledsPerPixel.read()
note

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

waveLength

If monochrome LED, specifies the wave length of the LED. Register is missing for RGB LEDs.

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

  • optional: this register may not be implemented

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

  • read only

import { Led } from "@devicescript/core"

const led = new Led()
// ...
const value = await led.waveLength.read()
note

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

luminousIntensity

The luminous intensity of all the LEDs, at full brightness, in micro candella.

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

  • optional: this register may not be implemented

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

  • read only

import { Led } from "@devicescript/core"

const led = new Led()
// ...
const value = await led.luminousIntensity.read()
note

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

variant

Specifies the shape of the light strip.

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

const led = new Led()
// ...
const value = await led.variant.read()
note

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