piglow-animations
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.
Usage
var piglow = ; var animation = piglowanimation;var pi = piglowpiGlowInterface; start { console; };
Api
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.
fade()
Opens up a new fade
transition context.
set()
Opens up a new set
transition context.
to(piGlowInterface)
This directive relates to a certain context, openend by set
or fade
.
It defines to which LED configuration a transition should morph.
repeat(timeRange)
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.
after(timeRange)
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.
in(timeRange)
This directive relates to a certain context, opened fade
.
Defines how much time the fade transition should run.
Check Repeat for possible values.
start([callback])
Starts the animation. Accepts an optional callback that will be called when the animation has been finished.
stop([noCallback])
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 = piGlowInterface; //create and setvar a = ;aring_0 = 100; //initialize with predefined valuesvar b = ; //initialize with maximum brightnessvar c = ;