open-pixel-control

0.1.2 • Public • Published

open-pixel-control

This library allows you to interface with an open pixel control (OPC) service

It's pretty unstable, and the API is NOT final.

The module returns a constructor for a client:

var opc_client = require('../open-pixel-control');

var client = new opc_client({
  address: '127.0.0.1',
  port: 7890
});

Which fires a 'connected' event when, well, it's connected!

You can then add strips. The client (will soon) handle appending strips for you.

Adding a strip returns its id - you'll need this to identify what strip you want to pass pixels to.

Pixels are represented as an array of array with 3 int values between 0 and 255 (RGB).

client.on('connected', function(){
  var strip = client.add_strip({
    length: 26
  });

client.put_pixel(strip_id, pixel_index, color_data) sets the pixel addressed to the color given (Added 0.0.2 :))

  client.put_pixel(strip.id, 0, [255, 255, 255]);

client.put_pixels(strip_id, pixels); sends the data to the OPC server. You send a full array of pixels with this one.

  var pixels = [
      [255, 255, 255],
      [0, 0, 0],
      [255, 0, 0],
      [0, 255, 0],
      [0, 0, 255],
      [255, 255, 255],
      [0, 0, 0],
      [255, 0, 0],
      [0, 255, 0],
      [0, 0, 255],
      [255, 255, 255],
      [0, 0, 0],
      [255, 0, 0],
      [0, 255, 0],
      [0, 0, 255],
      [255, 255, 255],
      [0, 0, 0],
      [255, 0, 0],
      [0, 255, 0],
      [0, 0, 255],
      [255, 255, 255],
      [0, 0, 0],
      [255, 0, 0],
      [0, 255, 0],
      [0, 0, 255],
      [255, 255, 255]
  ],
  new_pixel;
  setTimeout(function(){
    client.put_pixels(strip.id, pixels);
    new_pixel = pixels[0];
    pixels = pixels.slice(1);
    pixels.push(new_pixel);
  }, 200);
});

TODO:

  • Add tutorial for LEDscape on BeagleBone Black
  • Add tests
  • These docs need some serious <3!

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i open-pixel-control

      Weekly Downloads

      16

      Version

      0.1.2

      License

      MIT

      Last publish

      Collaborators

      • nodebotanist