PixelBlaze Output Expander Serial Library
A NodeJS Library for controlling PixelBlaze Expander A.K.A. ElectroMage Serial to 8x WS2812/APA102 Driver boards via serial port.
Installation
npm install pixelblaze-expander --save
Usage
Create a PBX device
with
var device = portName options;
documentation for ExpanderDevice.constructor
/** * Construct a PixelBlaxe Expander Device. * * @param * [serial port](https://serialport.io/docs/api-stream#path) which the PBX board is connected * to (For example, `/dev/tty.XXX` on Mac/Linux, or `COM1` on Windows) * @param * * @typedef * @see <https://serialport.io/docs/api-stream#openoptions> for details. * @param * timing issues (e.g. Raspberry Pi Zero). * @param * @param * @param * @param {Object<uint6,ChannelDef>} [channels={0:{}}] Definition of each channel that has * LEDs connected. Default is a single RGB WS281X device with maximum capacity on channel 0. * Object Keys are the channel number as labeled on the PBX PCB or jumper pad configuration. * Each board has 8 channels, and 8 boards can be chained, giving a maximum channel number of 64 * (uint6). Object values are channel definitions, which have the following structure: * * @typedef * @param * currently supported. "APA102_DATA" and "APA_CLOCK" to be implemented soon. * @param * For APA102, use 4 colors, default is "RGBW". * For WS281X, use 3 or 4 colors, default is "RGB". * Only "RGB" or "RGBW" are currently supported, but it's pretty easy to add more by extending * `PBX_COLOR_ORDERS`. * @param * this is the maximum number of pixels that can be sent, for the channel, which depends on the * number of color channels specified in `order` (`N` where `N ∈ [3, 4]`) and the base size of * `type`. `baseSize` is 4 for WS2812 and 8 for APA102. So max capacity is defined by * `Math.floor(2048 - 6 - baseSize(type) - 4) / N)` */
send colors to channels a and b, then draw the pixels with:
device;device;device;
documentation for ExpanderDevice.send
/** * Send colours to the PBX channel. Optionally draws all colours, or blocks until complete. * * @param * and has been defined in `options.channels` * @param * channel, where the number of pixels does not exceed `options.channels[channel].capacity` * @param * strips * @param * * @typedef * @param * @param * @param * @param * * @returns */
documentation for ExpanderDevice.drawAll
/** * Force the device to draw all channels. * * @param * @returns */
Examples
See examples for more info. You can run each example with:
npx babel-node examples/ws281xAsync.js # Send colours asynchronously npx babel-node examples/ws281xBlocking.js # Block until each colour is sent