npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

redoid

v0.1.4

Published

A Node.js package that provides an API to control your IKEA Dioder LED light strip on your Raspberry Pi.

Downloads

3

Readme

redoid

npm npm MIT license

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.

Dioder control unit circuit board

Following modifications are necessary:

  • Remove the micro controller 1 from the circuit board.
  • Solder 4 wires to 2, R, G and B.
  • Connect 2 to a GND pin on the Raspberry Pi.
  • Connect R, G and B to GPIO pins (preferably GPIO4, GPIO17 and GPIO18) 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 = require('redoid');
var redoid = Redoid({
    color: '#ffffff'
});

redoid.transition('#249db3', 250);
redoid.transition('#ffffff', 4000);

Red Alert

var Redoid = require('redoid');
var redoid = Redoid({
    color: '#300000',
    loopTransition: true
});

redoid.transition('#ff0000', 1500);
redoid.transition('#300000', 1500);

Easing

var Redoid = require('redoid');
var redoid = Redoid({
    color: '#ffffff'
});

var i = 0;

for (var easing in Redoid.easingFunctions)
{
    // trigger method logging the used easing function
    redoid.trigger(function() {
        console.log('' + this);
    }.bind(easing));

    redoid.delay(1000);
    redoid.transition(i ++ % 2 === 0 ? '#ff0000' : '#ffffff', 2000, easing);
}

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 = require('redoid');

var redoid = Redoid({
    color: '#ffffff',
    colorComponentPins: [4, 17, 18],
    applyColorCallback: null,
    loopInterval: 25,
    defaultEasing: 'easeInOutQuad',
    idleTimeout: 0,
    idleCallback: null,
    idleColor: null,
    idleColorTransitionDuration: 4000,
    loopTransition: false
});

Color

Color values are expected to be rgb hexadecimal strings or arrays having 3 integer values representing the rgb color components.

// hexadecimal
var color = '#ff0000';

// shorthand hexadecimal
var color = '#f00';

// color components
var 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 name
var easing = 'easeInOutQuad';

// easing function
var easing = function(t) {
    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.transition(color, [duration], [easing]);

change

Queue color change to color provided.

redoid.change(color);

turnOff

Queue turning off the lights.

redoid.turnOff([duration]);

delay

Delay next queue entry by given duration.

redoid.delay(duration);

trigger

Trigger callback when transition reaches this transition step.

redoid.trigger(callback);

stop

Interrupt the current transition and clear the queue. When firing this method, no callbacks set by trigger get called.

redoid.stop();

getColor

Return the current color. (e.g. [255, 0, 0])

var color = redoid.getColor();

getColorHexValue

Return hex value of current color. (e.g. #ff0000)

var color = redoid.getColorHexValue();

getLastQueuedColor

Return the last queued color. If loopTransition is set to true, this value changes during transiton.

var color = redoid.getLastQueuedColor();

getLastQueuedColorHexValue

Return hex value of last queued color.

var color = redoid.getLastQueuedColorHexValue();

isColorValid

Check if color is valid.

var colorValid = redoid.isColorValid(color)

isColorEqual

Check if colors are equal.

var colorEqual = redoid.isColorEqual(a, b)

isTransitioning

Returns true when currently inside transition.

var transitioning = redoid.isTransitioning();

setLoopTransition

Set the loopTransition option.

redoid.setLoopTransition(loopTransition);

setIdleColor

Set the idleColor option.

redoid.setIdleColor(idleColor);