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

rpi-rgb

v1.1.10

Published

Implements PWM control of RGB lighting via Raspberry Pi GPIO

Downloads

16

Readme

rpi-rgb

Implements PWM control of RGB leds for use with Raspberry Pi GPIO in Node.js

How to use

Setup

var RgbChannel = require('rpi-rgb').Channel;
var Colour = require('rpi-rgb').Colour;

var channel1 = new RgbChannel(<red_pin>,<green_pin>,<blue_pin>);

This creates an RGB channel. The pin numbers refer to wiring-pi pin numbers, see http://wiringpi.com/pins for details.

The Colour class

var myColour = new Colour(<red%>, <green%>, <blue%>);

Colours in rpi-rgb are defined as objects with red, green and blue properties between 0 (off) and 100 (full-on).

Methods

.setRgb (myColour, callback)

Immediately sets desired colour, with optional callback function.

.fadeRgb (myColour, time, callback)

Fades to desired colour linearly, over time ms. Optional callback.

.pulseRgb (startColour, endColour, fadeTime, pulseTime)

First, fades to startColour over fadeTime ms as with .fadeRgb, but then fades back and forth between this initial colour and endColour. In this case, pulseTime is the time in ms fading from one colour to the next, e.g. the total period is 2*pulseTime.

.endPulse()

Stops the pulse effect.

.strobeRgb(colour, pulselength, duration, callback)

Creates a stroboscope effect where the output is either switched off, or set to colour. This switch happens every pulselengthms, for a total duration of durationms. Optional callback.

.close()

Shuts down the PWM channel.

Example

This example will start by fading in to blue, then strobing for approximately a second. Then it fades to yellow and starts to pulse red.

var RgbChannel = require('rpi-rgb').Channel;
var Colour = require('rpi-rgb').Colour;

var channel1 = new RgbChannel(23,21,22);

var red = new Colour(100,0,0);
var softRed = new Colour(10,0,0);
var blue = new Colour(0,100,0);
var white = new Colour(100,100,100);
var yellow = new Colour(100,100,0);

// Start by fading to blue.
channel1.fadeRgb(blue, 2000, function() {
  // When that's done, strobe.
  channel1.strobeRgb(white, 18, 1000, function() {
    // After strobing, fade to yellow.
    channel1.fadeRgb(yellow, 700);
  });
});

// After the timeout, all the above is likely done, so start pulsing red.
setTimeout(function(thisobj) { thisobj.pulseRgb(softRed, red, 800, 1500); }, 7000, channel1);