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-mcp23008-ssd1306-node-driver

v2.1.0

Published

NodeJS wrapper for Adafruit mcp23008 and SSD1306. Lets you detect button clicks and draw on the display.

Readme

Node driver for Adafruit MCP23008 and SSD1306

This package is designed to let us talk to this thing using node on a Rasberry Pi running Raspbian.

That is, we can detect button presses and write stuff to the display.

How to install

npm install adafruit-mcp23008-ssd1306-node-driver

How to use it

Try this to run a quick demo. It echos button presses to the display.

const adafruit = require("adafruit-mcp23008-ssd1306-node-driver")
adafruit.demo()

Here's how to do it yourself:

const adafruit = require("adafruit-mcp23008-ssd1306-node-driver")
const ButtonDriver = adafruit.ButtonDriver
const DisplayDriver = adafruit.DisplayDriver

const busNumber = 1

const displayAddress = 0x3c
const displayDriver = new DisplayDriver(busNumber, displayAddress)

const buttonsAddress = 0x20
const buttonDriver = new ButtonDriver(busNumber, buttonsAddress)

buttonDriver.watchAllButtons(function(buttonPin) {
  displayDriver.writeText("Clicked button #" + buttonPin)
})

displayDriver.writeText("OK, click some buttons")
console.log("Check the display...")

You can also watch just one button:

buttonDriver.watchButton(1, function(buttonPin) {
  console.log("Clicked button #" + buttonPin)
})

You can also display QR codes:

displayDriver.setQrCode("http://www.google.com")

Note that the display driver runs a background loop to keep the display refreshed. So your process won't exit until you call:

displayDriver.stop()

Using tabs

This driver has a "tab" mechanism, using the metaphor of tabs in a web browser. Send the tab name as the last parameter of any method. If you don't specify a tab, it will use "default". Switch the current using displayDriver.showTab(...).

Example:

displayDriver.writeText("First tab", 0, 0, false, "tab1")
displayDriver.writeText("Second tab", 0, 0, false, "tab2")
displayDriver.showTab("tab2")

If you write stuff on a tab that isn't the current tab, then nothing changes on the display until you show that tab. Just like with real tabs.

Testing

If you are in a development environment with no access to the actual screen, you can use the fakes.

const adafruit = require("adafruit-mcp23008-ssd1306-node-driver")

console.log("Has driver: ", adafruit.hasDriver())
const fakeDisplayDriver = new adafruit.FakeDisplayDriver()
const fakeButtonDriver = new adafruit.FakeButtonDriver()
  • FakeDisplayDriver: has all the same methods as DisplayDriver, but displays on the terminal instead of the SSD1306 display.
  • FakeButtonDriver: has all the same methods as ButtonDriver, but you simulate button presses using your keyboard (press 0, 1, or 2).

How it works internally

The button stuff is a node port of this code:

  • https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/blob/legacy/Adafruit_MCP230xx/Adafruit_MCP230xx.py
  • https://github.com/HWHardsoft/Display_Shield_RPI/blob/master/standard_test.py

For display stuff is a wrapper around:

  • https://www.npmjs.com/package/oled-i2c-bus