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

adafruit-i2c-lcd

v2.0.0

Published

Node Library for using adafruit i2c rgb lcd pi plate

Readme

Adafruit I2C LCD Plate

Node.js implementation for the Adafruit RGB 16x2 LCD+Keypad Kit for Raspberry Pi http://www.adafruit.com/products/1110

Note: This readme is for the current version 1.x.x/2.x.x. If you are using older versions please read the version 0.0.x readme or version 0.1.x readme.

Note: Since version 1.0.0 this module is based on i2c-bus. For compatibility with your node.js version read the i2c-bus documentation. Older versions of this module were based on i2c. adafruit-i2c-lcd version 0.1.x only works with node.js 0.12.x and adafruit-i2c-lcd version 0.0.x only works with node.js 0.10.x.

Note: Version 2.0.0 and greater drops support for node v4, v5, and v7 as well as npm < v4 (update npm by running the command npm i npm -g)

Note: This module is compatible with Sainsmart 1602 I2C, see Compatibility

Usage

  1. read the i2c-bus documentation how to setup your raspberry pi.
  2. add dependency using npm install adafruit-i2c-lcd --save
  3. Copy and run one of the examples from the examples directory. Maybe you have to run them as root.

simple example

var LCDPLATE, lcd;
LCDPLATE = require('adafruit-i2c-lcd').plate;
lcd = new LCDPLATE(1, 0x20);

lcd.backlight(lcd.colors.RED);
lcd.message('Hello World!');

lcd.on('button_change', function(button) {
  lcd.clear();
  lcd.message('Button changed:\n' + lcd.buttonName(button));
});

API

LCDPLATE(device:String,address:Number,[pollInterval:Number])

Setting up a new LCDPLATE.

  • device: Device name, e.g. '/dev/i2c-1'
  • address: Address of the i2c panel, e.g. 0x20
  • pollInterval: optional. Set the poll interval for the buttons to x ms. Use pollInterval=-1 to disable polling. (Buttons will not work)

LCDPLATE.clear()

Clear the LCD, remove all text.

LCDPLATE.close()

Close the LCD plate. Use this to stop the polling.

LCDPLATE.backlight(color:Number)

Set the backlight of the LCD to the given color. You can use predefined colors from the LCDPLATE class:

LCDPLATE.colors = [OFF, RED, GREEN, BLUE, YELLOW, TEAL, VIOLET, WHITE, ON]

LCDPLATE.message(text:String, [boolean:clear])

Add the text on the LCD. Use \n as line feed. Only the first two lines will be sent to the display. If parameter clear is given and true only the text is shown, previous content on the lcd will be cleared.

LCDPLATE.createChar(index:Number, pattern:byte[])

Defines custom characters. Index must be between 0 and 7. Pattern is the pattern of your character, must contain exactly 8 bytes. E.g. you can easyly design your custom character at http://www.quinapalus.com/hd44780udg.html to show your custom character use eg. lcd.message('\x01').

Example:

lcd.createChar(1, [0,0,10,31,31,14,4,0]);
lcd.createChar(2, [0,4,10,17,17,10,4,0]);

lcd.clear();
lcd.backlight(lcd.colors.RED);
lcd.message('I\x01 n\x02de.js', true);

LCDPLATE.buttonState():Number

Returns the pressed buttons as a number. Use bitmasks to mask out the state of the desired button. See LCDPLATE.buttons for button values.

LCDPLATE.buttonName(val:Number):String

Returns the name, e.g. 'SELECT' to a button number. See LCDPLATE.buttons for button values.

Events

button_change

Fires if a button is pressed or released.

Parameters:

  • button: the button, See LCDPLATE.buttons for button values.

Example

lcd.on('button_change', function(button) {
  lcd.clear();
  lcd.message('Button changed:\n' + lcd.buttonName(button));
});

button_up

Fires if a button is released.

Parameters:

  • button: the button, See LCDPLATE.buttons for button values.

button_down

Fires if a button is pressed.

Parameters:

  • button: the button, See LCDPLATE.buttons for button values.

Compatibility

This library is compatible with the Sainsmart 1602 I2C (SKU: 20-011-221) with some notable exceptions. This clone has a blue backlight and an RGB LED on-board.

  • The LCDPLATE.backlight() function changes the RGB LED rather than the backlight.
  • The backlight on the LCD is connected to GPA5, which is the sixth (6th) bit of port A. It can be set on or off directly in your client code.
    lcd.sendBytes(0, 0x1F); // Sainsmart 1602 I2C backlight on
    lcd.sendBytes(0, 0x3F); // Sainsmart 1602 I2C backlight off

Licence

Based on the Adafruit's Raspberry-Pi Python Code Library

Here is a growing collection of libraries and example python scripts for controlling a variety of Adafruit electronics with a Raspberry Pi

In progress!

Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

Written by Limor Fried, Kevin Townsend and Mikey Sklar for Adafruit Industries. BSD license, all text above must be included in any redistribution

To download, we suggest logging into your Pi with Internet accessibility and typing: git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git