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

rpi-ws281x-led

v2.0.6

Published

NodeJS based driver for controlling WS281x light strips.

Downloads

59

Readme

rpi-ws281x-led

An extremely easy to use ws281x strip controller for NodeJS. Implements the rpi-ws281x-node wrapper and the rpi_ws281x library.

Installing

You can add this package to your own project using npm.

$ npm install rpi-ws281x-led

Then load it into your own project. This project includes type declarations for Typescript.

import Driver from 'rpi-ws281x-led';

/* OR */

const Driver = require('rpi-ws281x-led').default;

Notes

  • This project is intended to be compiled on a Raspberry Pi device. On unsupported platforms, an unbound interface is provided.

  • Root priveledges are required to acces PWM channels. Start the process as sudo.

Driver

constructor(config: DriverConfiguration): Driver

Creates a new driver with the provided configuration. Stores the array of channels with which to modify the strip.

Params:

  • config - The configurations for the driver.

Driver Configuration

  • dma - The DMA channel to use for the leds.
  • frequency - The frequency of the PWM channel.
  • channels - An array of ChannelConfiguration objects.

A channel will be created for every object with a count in the configuration. The default GPIO pin for the first channel is 18. If the second channel is not provided a GPIO, it will not be used.

Driver -> fini()

Frees the memory associated with the driver. The current object can be garbage collected, and a new driver can be created using the constructor.

Driver -> render()

The leds property of each channel will be read. The buffers are copied at this point so any invalid inputs, such as an invalid length, will throw an error. The length of the buffer must match the count property, and the property must be of type Uint32Array.

Channel

constructor(config: ChannelConfiguration): Channel

Creates a new channel with the provided configuration.

Channel Configuration

  • gpio? - The GPIO pin the driver should use.
  • invert? - Whether to invert the output signal.
  • count - The number of leds to initialize the driver with.
  • type? - The type of the strip.
  • brightness? - The brighness of the strip.

Channel -> get data(): ChannelData

Returns the driver provided data for the channel. This inludes a gamma table and rgbw shifts.

Channel -> fini(): void

Frees the memory associated with the driver. The current driver can be garbage collected, and a new driver can be created using the constructor. This will free the other channel as well.

Channel -> render(): void

The leds property of this channel will be read. The buffer is copied at this point so any invalid input, such as an invalid length, will throw an error. The length of the buffer must match the count property, and the property must be of type UInt32Array.

StripType

An enum containing the various strip types the rpi_ws281x library supports.

Tested Devices

  • Raspberry Pi 3b v1.2

License

This project is licensed under the MIT License - see the LICENSE.md file for details.