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

pi-display

v0.2.0

Published

2 Digit, 7 Segment LED Display Controller Software for the Raspberry Pi. A module for Node.js.

Downloads

6

Readme

piDisplay

2 Digit, 7 Segment LED Display Controller Software for the Raspberry Pi. A module for Node.js.

This is a beta version of piDisplay. Everything works correctly as is, but I plan on updating it with a lot more features in the coming weeks and months. This module can display numbers and some letters on a 7 segment, 2 digit LED display that is connected to a Raspberry Pi.

Sample Images

Scrolling Text Across Display

Scrolling Text Across Display

Counting Up on the Display

Counting Up on the Display

Counting Down on the Display

Counting Down on the Display

Pin Layout/Configuration

The model of LED display I am using is a Kingbright DA03-11GWA, and the pinout is shown in the image below. For the full tech sheet, see here. LED Display Pin Layout

As you can see the display uses two pins for common cathodes, seven pins for the LEDs themselves, and pin 2 is not connected. If you do not have the same display, that's fine, just be sure it's common cathode and not common anode, and that it has two common cathode pins and seven pins for the LED segments of the digits. You'll also need to remap the pins manually if your different display does not match the pinout of the display above.

This is how the display's pins are mapped out on the R-Pi's GPIO pins. There wasn't much rhyme or reason to this, and you can feel free to change the defaults if you would like, which I will detail below. All pins are listed by their physical pin number.

| LED Pin | R-Pi Pin | | ------- | -------- | | 5 | 13 | | 10 | 15 | | 9 | 18 | | 7 | 19 | | 1 | 21 | | 8 | 22 | | 3 | 23 | | 6 | 24 | | 4 | 26 |

Installation

npm install pi-display

Need help with installation? See here.

Usage

// Don't forget the extra parentheses to call the constructor function!
var piDisplay = require("pi-display")();

// Displays E7 on the LED display.
piDisplay.displayChars("E7");

// Displays 85.
piDisplay.displayChars(85);

// Scrolls the given string across the display. It looks more natural to scroll
// if you have spaces at either end of the string, but they are not mandatory.
// The second argument is the milliseconds to display each character.
piDisplay.scrollChars(" HI HELLO 1234567890 ", 400);

API

Methods

| Method | Argument(s) | Description | | ------ | --------- | ----------- | | constructor() | object ledPins, object cathodePins | Used to construct the piDisplay object. Pass in two objects as described in the properties section. Both arguments are optional. See properties for more information. | | displayChars() | string|number chars | Displays one to two static characters on the display. Accepts a string or number (0 to 99). Can be updated very rapidly (without needing to use the clearDisplay() method) in a loop or through some other means. | | scrollChars() | string sentence, number speed | Displays the given sentence in a scrolling style across the LED display, moving one character at a time. The scrolling speed is specified in milliseconds. If no speed is specified, the default 400 is used. | | count() | string upOrDown, number speed | Counts one-by-one either up or down on the display from 0 to 99. Use the string 'up' or 'down' to specify if the method should count up or down. The speed at which each new number is displayed is specified in milliseconds. If no speed is specified, the default 200 is used. | | clearDisplay() | none | Completely clears the display (turns off all the LEDs) and stops any method that is currently executing. |

Properties

These properties can only be reassigned at startup. See constructor method for more information.

| Property | Default Value | Description | | -------- | ------------- | ----------- | | ledPins | object {"top": 23, "topLeft": 26, "topRight": 18, "middle": 21, "bottomLeft": 19, "bottomRight": 22, "bottom": 24} | Which physical pin number is matched to which segment of the LED. | | cathodePins | object {"digitOne": 15, "digitTwo": 13} | The physical pin that controls which digit is turned off when set to HIGH. |

Credits

I'd like to give a huge thanks to drogon for his excellent Wiring Pi library, Soarez for making the original Node.js bindings for Wiring Pi, and eugeneware for enhancing Soarez's work on the newer Node.js bindings.