ledutils

0.1.2 • Public • Published

ledutils

A small collection of utilities to make it easier to work with node-pixel, including mapping an array of onecolor objects to the strip, color range generation, gradient generation (soon).

Many of these functions are javascript ports of the functions that exist in FastLED.

examples

See the examples directory.

Example Rainbow wipe with ledutils

usage

fill_solid

fill_solid fills the entire array with a specific color

fill_rainbow

fill_rainbow generates a rainbow of color by manipulating the hue with a delta degree between them.

 
var leds = require('ledutils');
var colors = new Array(5);
leds.fill_rainbow({
  arr: colors,
  initialHue: 0,
  hueDelta: 45
});

The previous code will generate the following colors in the array:

color ff0000 color ffbf00 color 80ff00 color 00ff40 color 00ffff

fill_gradient

fill_gradient fills the entire array with a gradient [startColor,endColor)

var leds = require('ledutils');
var colors = new Array(5);
leds.fill_gradient({
  arr: colors,
  startColor: 'blue',
  endColor: 'orange'
});

The previous code will generate the following colors in the array:

color 0000ff color 3321cc color 664299 color 996366 color cc8433

led_map

led_map takes an array of colors and maps it into a node-pixel strip. It can be offset so that the strip can be represented by multiple arrays that you then map into the strip.

 
// Assume a node-pixel strip exists
var leds = require('ledutils');
var colors = new Array(5);
leds.fill_rainbow({arr: colors, initialHue: 0, hueDelta: 45);
leds.led_map({arr: colors, strip: strip, offset: 3});

The above example will display the rainbow in colors starting on led 3 of the strip. If the strip is less then 8 leds, the rainbow will not be complete.

Readme

Keywords

Package Sidebar

Install

npm i ledutils

Weekly Downloads

1

Version

0.1.2

License

MIT

Last publish

Collaborators

  • rhay