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

neopixel

v1.1.0

Published

This library enables the **Adafruit NeoPixel** control from a **Node.js** script through a **TCP connection**.

Downloads

5

Readme

NeoPixel

This library enables the Adafruit NeoPixel control from a Node.js script through a TCP connection.

The server side has to be installed on an ESP8266/Arduino (or compatible) board.
The client side can work on any machine that runs Node.js.

Requirements

  • ESP8266 or compatible board, available here https://amzn.to/2Vpm3C8#esp8266
  • A NeoPixel strip led, available here https://amzn.to/2AuuZNQ#neopixel-strip-led
  • A power supply that supports 5V and 18watt (depends on number of pixels), available here https://amzn.to/2SFMTo1#power-supply-5v-18w
  • A jack for DC connections, available here https://amzn.to/2RaNGQT#jack-dc

Setup

  • Upload the firmware on the ESP8266.
    Upload the file firmware/neopixel/neopixel.ino into your ESP8266.
    To do this you can use the Board Manager available in the Arduino software.
    Follow this instructions https://arduino-esp8266.readthedocs.io/en/latest/installing.html

  • Wire the strip with the ESP8266.
    Connect the Strip Led and the ESP8266 to a power supply and the DATAIN pin with the D1 pin.
    More details are available here https://learn.adafruit.com/adafruit-neopixel-uberguide/basic-connections

  • Connect your ESP8266 on your local network.
    Turn on your ESP8266. You should see an Access Point that has neopixel as SSID name.
    Connect on it, then you should see a captive portal that asks your Wi-Fi credentials.
    Provide it and then try to ping on your local network neopixel.local. You should be able to see this device connected and announced through Bonjour.
    More details about the Wi-Fi configuration are available here https://github.com/tzapu/WiFiManager#how-it-works.
    More details about the service discovery are available here https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266mDNS#requirements.

Example

const NeoPixel = require('neopixel');

const SERVER = process.env['SERVER'] || 'tcp://neopixel.local:800'
const PAUSE = parseInt(process.env['PAUSE']) || 1000

const neopixel = new NeoPixel()

;(async () => {
  try {
    let { pixels } = await neopixel.connect(SERVER)
    console.log('PIXELS ' + pixels)

    let pixel = 0
    while (1) {
      pixel = ++pixel % neopixel.pixels
      const { latency } = await neopixel.setPixels([{ pixel, r: 255, g: 0, b: 0 }], true)
      console.info(`latency=${latency}ms`)
      await NeoPixel.wait(PAUSE - latency)
    }
  } catch (e) {
    console.error(`Error occurred: [${e.code}] ${e.message}`)
    process.exit(1)
  }
})()

Reference

new NeoPixel()

const NeoPixel = require('neopixel')
const neopixel = new NeoPixel()

connect(tcpUri)

Connects client with the board and returns number of configured pixels.

const {latency, pixels} = await neopixel.connect('tcp://neopixel.local:800')

setPixels(arrayOfColors, reset=false)

Sets pixel colors. If reset, any other pixel is turned off.

const {latency} = await neopixel.setPixels([
    {pixel: 10, red: 255, green: 0, blue: 0},
    {pixel: 20, red: 0, green: 255, blue: 0},
], true)

// shorthand version
const {latency} = await neopixel.setPixels([
    {p: 10, r: 255, g: 0, b: 0},
    {p: 20, r: 0, g: 255, b: 0},
], true)

fill(color)

Sets every pixel with the same color.

const {latency} = await neopixel.fill({red: 255, green: 0, blue: 0})

// shorthand version
const {latency} = await neopixel.fill({r: 255, g: 0, b: 0})

off()

Turn of every pixel.

const {latency} = await neopixel.off()

Changelog

  • 0.x - Beta version
  • 1.0 - First official version
  • 1.1 - Migrates to gh-workflows; Upgrades deps; Deprecated Node 8

Contributors