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

pixelblaze-expander

v0.1.1

Published

A Library for controlling pixelblaze expander A.K.A. ElectroMage Serial to 8x WS2812/APA102 Driver boards

Downloads

39

Readme

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.

Node.js Build Status Maintainability codecov Known Vulnerabilities Language grade: JavaScript Total alerts

Installation

npm install pixelblaze-expander --save

Usage

Create a PBX device with

var device = new ExpanderDevice(portName, options);

documentation for ExpanderDevice.constructor

/**
 * Construct a PixelBlaxe Expander Device.
 *
 * @param {string} portName the name of the
 * [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 {DeviceOptions} options has the following structure:
 *
 * @typedef {Object} DeviceOptions
 * @see <https://serialport.io/docs/api-stream#openoptions> for details.
 * @param {Integer} [baudRate=2000000] you may wish to change to 2304000 if you're having
 * timing issues (e.g. Raspberry Pi Zero).
 * @param {Integer} [dataBits=8]
 * @param {Integer} [stopBits=1]
 * @param {string} [parity='none']
 * @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 {Object} ChannelDef
 * @param {string} [type='WS281X'] protocol used by PBX to talk to LEDs, only "WS281X" is
 * currently supported. "APA102_DATA" and "APA_CLOCK" to be implemented soon.
 * @param {string} [order=undefined] color order setting.
 * 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 {uint16} [capacity=undefined] number of pixels connected to this channel. By default
 * 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.send(channel_a, colors_a, drawAll, blocking);
device.send(channel_b, colors_a, drawAll, blocking);
device.drawAll();

documentation for ExpanderDevice.send

/**
 * Send colours to the PBX channel. Optionally draws all colours, or blocks until complete.
 *
 * @param {uint6} channel the channel, as marked on the PBX PCB or jumper pad configuration,
 * and has been defined in `options.channels`
 * @param {Array<ColourArray>} colors  an array containing a color array for each pixel on the
 * channel, where the number of pixels does not exceed `options.channels[channel].capacity`
 * @param {boolean} [drawAll=false] whether to send a drawAll command afterwards to refresh all
 * strips
 * @param {boolean} [blocking=false] whether to block until the call is complete
 *
 * @typedef {Array} ColourArray defines the value of each colour channel for a pixel
 * @param {uint8} red
 * @param {uint8} green
 * @param {uint8} blue
 * @param {uint8} [white] only required when `order` has 4 colours
 *
 * @returns {Promise} a promise to be resolved once the operation has finished
 */

documentation for ExpanderDevice.drawAll

/**
 * Force the device to draw all channels.
 *
 * @param {boolean} [blocking=false] whether to block until the call is complete
 * @returns {Promise} a promise to be resolved once the operation has finished
 */

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