sh1106
v1.1.0
Published
Node.js library to interact with a SH1106 display controller
Downloads
4
Readme
node-sh1106
Node.js library to interact with a SH1106 display controller, written in TypeScript. This library is designed to be used with a Raspberry Pi, but may be supported by other devices.
This library is largely based on the Python libraries luma.core and luma.oled.
Currently only SPI is supported. This means that you need to run it with sudo
for it to work. I²C support may be added in the future.
Installation
yarn add sh1106
Usage
import { SH1106 } from 'sh1106';
const pad = (input: number): string => {
return ('0' + input).slice(-2);
};
const getDate = () => {
const date = new Date();
return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
};
const device = new SH1106();
setInterval(() => {
// Clear the canvas
device.canvas.clear();
// Draw the current time at [1, 1] with a size of 2
device.canvas.text(1, 1, getDate(), 2);
// Update the display
device.refresh();
}, 1000);
See Mrtenz/binary-pixel-map for documentation on the canvas.
API
new SH1106(width: number = 128, height: number = 64);