range

Create a new, smaller pixel strip from part of the current pixel strip.

light.createStrip().range(0, 4)

The new pixel strip is a smaller, virtual, strip with some or all of the pixels from the current, or original, strip. You can use range to make new mini strips from one larger strip for use in more complex light effects.

If you have a pixel strip with 10 pixels, you can make 2 new virtual strips by giving the new strips 5 pixels each. An example of this is something like:

let strip0 = light.createStrip()
let strip1 = strip0.range(0, 5)
let strip2 = strip0.range(5, 5)

You can use these new pixels strips by themselves with their own light actions:

let strip0 = light.createStrip()
let strip1 = strip0.range(0, 5)
let strip2 = strip0.range(5, 5)
strip1.setAll(0xffff00)
strip2.setPixelColor(0, 0xff0000)

The original strip has a red pixel at pixel spot 5 but it’s at pixel spot 0 for the new virtual strip called strip2.

Parameters

  • start: the pixel position where the new pixel strip starts at, such as 5
  • length: the amount of pixels the new pixel strip will have, like: 10

Returns

  • A new pixel strip created from the current pixel strip, with some or all of pixels.

Example

Make a smaller strip from the current pixel strip. Shift an orange pixel from the beginning of the new pixel strip to its end.

let smallStrip = light.createStrip().range(0, 4)
smallStrip.setPixelColor(0, 0xff0000)
for (let i = 0; i < smallStrip.length() - 1; i++) {
    pause(500)
    smallStrip.move(LightMove.Shift, 1)
}

See also

||create strip||

light