redoid
A Node.js package that provides an API to control your IKEA Dioder LED light strip from your Raspberry Pi. Read redoid the other way round to understand where its name came from.
Installation
Connect Dioder to Raspberry Pi
Please notice that you need to apply physical changes to the circuit board of your Dioder control unit in order to connect it to the Raspberry Pi. After that you will no longer be able to use the buttons on the control unit to change the behavior of the LEDs.
Open the IKEA Dioder control unit carefully with a screwdriver. We are aware of following two versions of the circuit board inside it. Both are compatible with this modification.
Following modifications are necessary:
- Remove the micro controller
1
from the circuit board. - Solder 4 wires to
2
,R
,G
andB
. - Connect
2
to aGND
pin on the Raspberry Pi. - Connect
R
,G
andB
to GPIO pins (preferablyGPIO4
,GPIO17
andGPIO18
) on the Raspberry Pi.
Install Dependencies
Install the pi-blaster daemon (instructions) and Node.js with npm.
Finally install redoid
using npm:
npm install redoid
Examples
Simple Alert
var Redoid = ;var redoid = ; redoid;redoid;
Red Alert
var Redoid = ;var redoid = ; redoid;redoid;
Easing
var Redoid = ;var redoid = ; var i = 0; for var easing in RedoideasingFunctions // trigger method logging the used easing function redoid; redoid; redoid;
Usage
Instance
You can create one or more Redoid
instances by calling its constructor. The constructor takes one optional associative array with following keys to configure the instance:
- color – Initial color to apply when an instance gets created.
- colorComponentPins – Array holding 3 integer values of the RGB GPIO pins dioder is connected to.
- applyColorCallback – Custom function that replaces the default mechanism for applying colors. This feature is disabled if set to
null
. - loopInterval – Duration between transitioning ticks.
- defaultEasing – Default easing
- idleTimeout – Delay between the queue being idle and the idle event getting triggered.
- idleCallback – Function that gets called when the idle event gets triggered.
- idleColor – Idle color to transition to when the idle event gets triggered. This feature is disabled if set to
null
. - idleColorTransitionDuration – Idle color transition duration
- loopTransition – If set to
true
completed transition steps will be added to the end of the queue resulting in a never-ending transition loop.
The following instance gets configured with the default values:
var Redoid = ; var redoid = ;
Color
Color values are expected to be rgb hexadecimal strings or arrays having 3 integer values representing the rgb color components.
// hexadecimalvar color = '#ff0000'; // shorthand hexadecimalvar color = '#f00'; // 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
.
// known easing function by namevar easing = 'easeInOutQuad'; // easing functionvar { return t<5 ? 2*t*t : -1+4-2*t*t;}
API
transition
Queue transition from the last queued color (obtained by getLastQueuedColor
) to the color provided.
redoid;
change
Queue color change to color provided.
redoid;
turnOff
Queue turning off the lights.
redoid;
delay
Delay next queue entry by given duration.
redoid;
trigger
Trigger callback when transition reaches this transition step.
redoid;
stop
Interrupt the current transition and clear the queue. When firing this method, no callbacks set by trigger
get called.
redoid;
getColor
Return the current color. (e.g. [255, 0, 0]
)
var color = redoid;
getColorHexValue
Return hex value of current color. (e.g. #ff0000
)
var color = redoid;
getLastQueuedColor
Return the last queued color. If loopTransition
is set to true
, this value changes during transiton.
var color = redoid;
getLastQueuedColorHexValue
Return hex value of last queued color.
var color = redoid;
isColorValid
Check if color is valid.
var colorValid = redoid
isColorEqual
Check if colors are equal.
var colorEqual = redoid
isTransitioning
Returns true
when currently inside transition.
var transitioning = redoid;
setLoopTransition
Set the loopTransition
option.
redoid;
setIdleColor
Set the idleColor
option.
redoid;