dioder
A node package that gives your Raspberry Pi control over your Ikea Dioder LED light strip.
Installation
- Connect your Dioder LED light strip to your Raspberry Pi (instructions).
- Install the pi-blaster daemon (instructions).
- Make sure you have
node
andnpm
installed on your Raspberry Pi.
Finally install dioder
:
$ npm install dioder
Usage
Instance
Creates a dioder object. You don't need to provide any options, these are the defaults.
var Dioder = ; var dioder = ;
Color
Color values are expected to be rgb hexadecimal strings or arrays of rgb color components.
// hexadecimalvar color = '#ff0000'; // shorthand hexadecimalvar color = '#f00'; // array of color componentsvar color = 255 0 0;
Easing
Easing values are expected to be a function
or one of the following keys: linear
, easeInQuad
, easeOutQuad
, easeInOutQuad
, easeInCubic
, easeOutCubic
, easeInOutCubic
, easeInQuart
, easeOutQuart
, easeInOutQuart
, easeInQuint
, easeOutQuint
, easeInOutQuint
.
// expressed by a functionvar { return t<5 ? 2*t*t : -1+4-2*t*t} // expressed by a keyvar easing = 'easeInOutQuad';
Methods
getColor
Returns the current color. (e.g. #ff0000
)
dioder;
getColorComponents
Returns the components of the current color. (e.g. [255, 0, 0]
)
dioder;
getLastQueuedColor
Returns the ending color of the animation queue. If loopQueue
is set to true
, this value changes during animation.
dioder;
getLastQueuedColorComponents
Returns the components of the last queued color.
dioder;
changeTo
Changes the color without transition. Calls the callback when completed.
dioder;
animateTo
Animates from the previous color (obtained by getLastQueuedColor
) to a specified one in a given duration and easing. Calls the callback when completed.
dioder;
delay
Delays the next queued animations by a given duration. Calls the callback when completed.
dioder;
stop
Interrupts the current transition and clears the queue. In this case, no callbacks (sent to changeTo
, animateTo
or delay
) are called.
dioder;
setLoopQueue
If set to true
completed animations will be readded to the end of the animation queue resulting in a never-ending animation loop.
dioder;
Examples
Simple Notification
var dioder = color: '#ffffff'; dioder ;
Red Alert
var dioder = color: '#300000'; dioder ;
Easing
var dioder = color: '#ffffff'; var easingFunctions = 'linear' 'easeInQuad' 'easeOutQuad' 'easeInOutQuad' 'easeInCubic' 'easeOutCubic' 'easeInOutCubic' 'easeInQuart' 'easeOutQuart' 'easeInOutQuart' 'easeInQuint' 'easeOutQuint' 'easeInOutQuint'; for var i = 0; i < easingFunctionslength; i ++ var easing = easingFunctionsi; // wait for 1 second and log the easing method used dioder; // animate to the other color using easing dioder;
License
The MIT License (MIT)
Copyright (c) 2013 Fränz Friederes <fraenz@frieder.es>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.