Skip to content

Utility functions to make working with node-pixel easier.

Notifications You must be signed in to change notification settings

graysonarts/node-ledutils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Utility functions to make working with node-pixel easier.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published