@yoda/light

Use light module to control your LEDs.

var light = require('@yoda/light');
light
  .fill(20, 20, 20, 0.7)
  .pixel(3, 255, 255, 255)
  .pixel(3, 233, 233, 200)
  .write();

As you can seen, this module provides the following main methods:

  • fill(): fill the color on all the lights, and write immediately.
  • pixel(): fill the color on the given light by index.
  • write(): write the current buffer.

Methods

(inner) write(explictopt)

Render the current buffer

Parameters:
Name Type Attributes Description
explict Buffer <optional>

if present, use the given buffer to write.

(inner) getProfile() → {module:@yoda/light~LightProfile}

Get the hardware profile data

(inner) fill(red, green, blue, alphaopt)

Fill all lights with the same color.

Parameters:
Name Type Attributes Default Description
red number

the red number 0-255.

green number

the green number 0-255.

blue number

the blue number 0-255.

alpha number <optional>
1

the alpha number.

Example
light.fill(255, 255, 233, 0.3); // this will render rgba(255,255,233,0.3)

(inner) pixel(index, red, green, blue, alphaopt, shadingopt)

Render a pixel with the a color

Parameters:
Name Type Attributes Default Description
index number

the index of the light LEDs.

red number

the red number 0-255.

green number

the green number 0-255.

blue number

the blue number 0-255.

alpha number <optional>
1

the alpha number.

shading number <optional>
false

show shadow.

Example
light.pixel(3, 255, 255, 255) // this will light black on 3rd led.

(inner) clear()

Clear the light

Type Definitions

LightProfile

Describe the hardware features for the current light.

Properties:
Name Type Description
leds number

the number of LEDs.

format number

the color format, commonly 3 means rgb.

maximumFps number

the maximum fps.

micAngle number

the mic angle at zero.