node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »


piglow-animations Build Status



node-piglow-animations is a library on top of node-piglow that allows for piglow animations.

An animation consists of a bunch of interface configurations that will be subsequently invoked. Between the different configurations transitions can be defined as well als transformation and invocation times. A chaining interface makes the configuration of animations super simple.

Check the examples folder for animation examples.


var piglow = require('piglow-animations');
var animation = piglow.animation;
var pi = piglow.piGlowInterface;
animation({interval:10, debug: true})
    .start(function() {
        console.log('i looped 3 times, now Im done.');


Constructor([options, [backend]])

Creates a new animation object.

Optional options object:

  • interval: defines in which interval LED updates should be made, default: 100
  • debug: activates debugging

The optional backend object can be used to inject a mocking backend (unit tests, non raspi environment etc). See the Adressing section of node-piglow for details.


Opens up a new fade transition context.


Opens up a new set transition context.


This directive relates to a certain context, openend by set or fade. It defines to which LED configuration a transition should morph.


Defines how often or how long a animation should be run. Possible parameters:

    animation().repeat(1);          //runs exactly once
    animation().repeat('1time');    //runs exactly once
    animation().repeat('2times');   //runs exactly two times
    animation().repeat('10s');      //runs for 10seconds (animation loops will always be completed)
    animation().repeat('0.1s');     //runs for 100ms (animation loops will always be completed)
    animation().repeat('100ms');    //runs for 100ms (animation loops will always be completed)

If no repeat directive has been set the animation will run forever.


This directive relates to a certain context, opened by set or fade. Defines how much time should pass until the transition gets started. Check Repeat for possible values.


This directive relates to a certain context, opened fade. Defines how much time the fade transition should run. Check Repeat for possible values.


Starts the animation. Accepts an optional callback that will be called when the animation has been finished.


Stops the animation, if present the callback from the start command will be fired. If the parameter noCallback has been set, the callback will not be invoked.

Variations of interface configurations

For your convenience there are some additional ways of predefining LED values:

var pi = require('piglow').piGlowInterface;
//create and set 
var a = pi();
a.ring_0 = 100;
//initialize with predefined values 
var b = pi({'ring_0': 100, 'l_1_1': 10});
//initialize with maximum brightness 
var c = pi(['ring_5']);