New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

openpixelcontrol-stream

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openpixelcontrol-stream

provides a stream-implementation for interfacing with the openpixelcontrol-protocol

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

openpixelcontrol-stream build-status

stream-based implementation of the openpixelcontrol-protocol. Provides a protocol-parser and a client-implementation.

installation

npm install openpixelcontrol-stream

usage example

openpixelcontrol server

This will run an openpixelcontrol server on the default port (7890) and send received data to the rpi-ws281x-native module for output to a strip of ws2812-leds.

var ParseStream = require('openpixelcontrol-stream').OpcParseStream,
    net = require('net'),
    ws281x = require('rpi-ws281x-native');


var server = net.createServer(function(conn) {
    var parser = new ParseStream({
        channel: 1,
        dataFormat: ParseStream.DataFormat.UINT32_ARRAY
    });

    parser.on('setpixelcolors', function(data) {
        ws281x.render(data);
    });

    conn.pipe(parser);
});

ws281x.init(100);
server.listen(7890);

openpixelcontrol client

A basic client connecting to an openpixelcontrol-server and running an animation there.

var ClientStream = require('openpixelcontrol-stream').OpcClientStream,
    net = require('net');

var NUM_LEDS = 100,
    OPC_CHANNEL = 0;

var client = new ClientStream();

// connect to openpixelcontrol-server at `192.168.1.42:7890`
var socket = net.createConnection(7890, '192.168.1.42', function() {
    client.pipe(socket);

    run();
});

function run() {
    // create a typed-array for color-data
    var data = new Uint32Array(NUM_LEDS);

    // setup an animation-loop at 10FPS
    setInterval(function () {
        // ... update colors in `data` ...

        client.setPixelColors(OPC_CHANNEL, data);
    }, 100);
}

Keywords

opc

FAQs

Package last updated on 18 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts