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

wolkd

v0.5.2

Published

Server and user interface to control WS2801 RGB LED strips via SPI

Downloads

8

Readme

wolkd

Node.js server and user interface to control WS2801 RGB LED strips via SPI. Built to control wolk.bike, a bike skelter sound system cloud commisioned by Welcome to the Village 2015.

wolkd can display mathematical functions, frame-by-frame animations (and even animated GIFs!) on RGB LED strips, and can be controlled via a web interface — with your laptop, smartphone or tablet. wolkd lets you write animations in terms of either a pixel's LED strip index or x and y coordinates using a mapping file. And wolkd has a 256 color ANSI terminal debug mode!

wolkd works well in conjunction with LED Strip Mapper.

See http://wolk.bike for more photos!

Installation

git clone https://github.com/bertspaan/wolkd.git
cd wolkd
npm install

If your device has an SPI interface (Raspberry Pis have one!), you can install node-spi:

npm install spi

Please note: without node-spi, wolkd will run in console mode!

wolkd expects the environment variable WOLKD_CONFIG to point to the path of the wolkd configuration JSON file.

cp wolkd.example.config.json ~/wolkd.config.json
export WOLKD_CONFIG=/home/wolk/wolkd.config.json

wolkd's configuration and command line arguments are described in detail below.

To run wolkd, type:

node index.js

When running wolkd on your laptop and/or in console mode, the RGB LED output is mapped to the terminal:

User interface

After starting wolkd, a web interface to control wolkd and mix patterns is available on http://localhost:3000:

Patterns

wolkd supports two kinds of patterns:

  1. Functions: functions are executed every frame for each active pattern
  2. Frames: frames are hard-coded arrays of pixel colors.

Function:

module.exports =  {
  title: 'Function',
  getPixel: function(beat, t, i, x, y) {
    // beat: beat number
    // t: frame number
    // i: pixel index
    // x: x coordinate of pixel, according to mapping
    // y: y coordinate of pixel, according to mapping
    return [r, g, b];
  }
};

Frames:

module.exports = {
  title: 'Frames',
  frames: [
    [
      [0, 0, 0],     // Frame 1, pixel 1
      [255, 0, 0],   // Frame 1, pixel 2
      ...
    ],
    [
      [0, 255, 0],   // Frame 2, pixel 1
      [255, 255, 0], // Frame 2, pixel 2
      ...
    ],
  ]
};

TODO: animated GIFs!

Screens

Each frame, wolkd outputs its pixel data to a screen. Currently, wolkd has two screens available: spi and console.

It's easy to add your own screens, by creating a JavaScript file in the screens directory.

exports.setPixel = function(pixel, r, g, b) {
  // Set RGB color of individual indexed pixel in buffer
}

exports.update = function update() {
  // Send buffer to screen, called each frame
}

Mappings

wolkd uses a JSON mapping file to convert a pixel's LED strip index to its x and y coordinates (between 0 and 1). You can use LED Strip Mapper to generate such patterns from an SVG file.

You can find wolkd's mappings in the mappings directory

Autopilot

Autopilot is very smart and can create beautiful random patterns!

Configuration

{
  "pixels": 100,                // Number of pixels on LED strip
  "framerate": 30,              // Framerate wolkd tries to achieve
  "bpm": 120,                   // Default BPM
  "framesPerBeat": 16,          // Frames per beat - constant if BPM changes
  "spi": {
    "device": "/dev/spidev0.0"  // SPI device
  },
  "autopilot": {
    "enabled": true,            // Enable/disable [autopilot](#autopilot)
    "inputTimeout": 120000,     // Time in milliseconds before autopilot starts
                                //   after user input
    "patternTimeout": 60000     // Time after which autopilot changes patterns
  },
  "mapping": "st-bree",         // Default [mapping file](#mappings)
  "screen": "spi",              // Default [screen](#screens)
  "hostname": "wolkd.local",    // Used by web interface
  "websocket": {
    "port": 8080                // Used by web interface
  },
  "http": {
    "port": 3000                // Used by web interface
  }
}

Command line arguments

You can override some of the options set in the configuration file with the following command line arguments:

| Argument | Example | Description |:---------------------------|:--------------------|:------------- | --screen <screen> | --screen console | Choose screen | --mapping <mapping> | --mapping wolk | Choose mapping file | --autopilot <true|false> | --autopilot false | Enable or disable autopilot

Raspberry Pi

Instructions for installing wolkd on a Raspberry Pi:

server {
    listen 80;
    server_name wolk.local;
    location / {
        proxy_pass http://localhost:3000/;
    }
}
  • sudo ln -s /etc/nginx/sites-available/veldnamen /etc/nginx/sites-enabled && sudo service nginx restart
  • Create wolkd daemon: http://www.slidequest.com/Taboca/70ang:
    1. sudo npm install -g forever
    2. sudo cp ./daemon/wolkd /etc/init.d/wolkd
    3. sudo chmod 755 /etc/init.d/wolkd
    4. sudo update-rc.d wolkd defaults

TODO

  • Language files/config for user interface
  • In UI, sliders should change when wolkd changes patterns/modifiers
  • Frame animations with configurable speed
  • Patterns either continuous (each frame) or per beat
  • Create programs, combinations of patterns that work well together
  • Add colors or images to buttons in user interface
  • Add modifiers which change hue/color through time
  • FFT audio analysis and beat detection using microphone
  • Add Open Pixel Control support
  • Send output to Fadecandy Controller board
  • Add websocket screen and HTML Canvas viewer

See also