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.
npm install adafruit-mcp23008-ssd1306-node-driver
Try this to run a quick demo. It echos button presses to the display.
const adafruit =adafruit
Here's how to do it yourself:
const adafruit =const ButtonDriver = adafruitButtonDriverconst DisplayDriver = adafruitDisplayDriverconst busNumber = 1const displayAddress = 0x3cconst displayDriver = busNumber displayAddressconst buttonsAddress = 0x20const buttonDriver = busNumber buttonsAddressbuttonDriverdisplayDriverconsole
You can also watch just one button:
You can also display QR codes:
Note that the display driver runs a background loop to keep the display refreshed. So your process won't exit until you call:
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(...).
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.
If you are in a development environment with no access to the actual screen, you can use the fakes.
const adafruit =consoleconst fakeDisplayDriver =const fakeButtonDriver =
The button stuff is a node port of this code:
For display stuff is a wrapper around: