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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ht1632

v1.0.0

Published

Simple Node.js library to communicate with a HT1632 LED controller chip using SPI.

Readme

node-ht1632

Simple Node.js library to communicate with a HT1632 LED controller chip using SPI. Uses the pi-spi asyncronous node.js SPI library for Raspberry Pi (and likely other embedded Linux platforms that provide /dev/spidevN.N).

It is intentionally low level (directly exposes the HT1632 RAM addresses to writing) to make it more compatible to the various implementations of LED displays that use this chip. For example, my hack of the WoodStation weather alarm clock uses such a LED controller, but not in the usual "Led Matrix" way, and uses leds in a "7 segment" layout.

Example

npm install ht1632

var HT1632 = require('ht1632');

var display = HT1632.initialize("/dev/spidev0.0", HT1632.mode.MODE_8NMOS);

// write led D1 at address 0x02
display.writeAddress(0x02, false, true, false, false);

// Sets the LED index 1 at address 0x02. Led index range is 0-3 as described in the datasheet.
display.writeLed(0x02, 1, true);

// Enable blinking
display.blink(true);

// Set PWM to 8 (range 0-15)
display.pwm(8);

// clear ht1632 ram 
display.clear();

// Enable prompt mode where all leds will consecutively be turned on.
// Useful to hack an existing display implementation.
display.findLeds();

Probably requires running node under sudo for SPI permissions, unless you've used Wiring Pi's gpio utility or otherwise adjusted device permissions.

API

display = HT1632.initialize(device, [mode])

device will usually be "/dev/spidev0.0" or "/dev/spidev0.0". You will first need to enable the spi-bcm2708 kernel module e.g. these instructions or similar for your platform. As mentioned above, by default this device requires root permissions and so you'll either need to change this or run your script with according privilege.

mode, optional, is either HT1632.mode.8NMOS, HT1632.mode.16NMOS, HT1632.mode.8PMOS or HT1632.mode.8NMOSdepending on the LED layout (see HT1632 datasheet and/or the display one). Defaults to HT1632.mode.8PMOS.

display.writeAddress(offset, d0, d1, d2, d3))

Sets the d0, d1, d2 and d3 LED bits at the offset address. LED bits values are boolean, and offset value is integer between 0 and 64 (8NMOS or 8PMOS mode) or 96 (16NMOS or 16PMOS mode) as per the HT1632 datasheet.

display.writeLed(offset, ledIndex, value))

Sets the led of ledIndex at the offset address (led index range is 0-3 as described in the HT1632 datasheet). Value is boolean, and offset value is integer between 0 and 64 (8NMOS or 8PMOS mode) or 96 (16NMOS or 16PMOS mode) as per the HT1632 datasheet. Other led values at the same offset will stay the same.

display.blink([enableBlinking])

Sets (or gets, if no argument provided) the hardware based blinking of the HT1632 display. Value is boolean.

display.pwm([intensity])

Sets (or gets, if no argument provided) the hardware based PWM level of the HT1632 display. Value is number between 0 and 15 included.

display.clear()

Clears all ram of the HT1632 controller. Effectively switches off all leds.

display.findLeds()

Launches a loop that will cycle through all leds at all addresses of the HT1632 ram, turns it on and waits for user input at every step (exit or quit to stop). Useful if diagnosing an existing display, to find which led is at what address.

License

Copyright © 2015, Arnaud Mondit. Licenced under MIT license.