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 🙏

© 2026 – Pkg Stats / Ryan Hefner

epd2in13

v1.0.5

Published

Nodejs driver for the Waveshare 2.13inch (B) e-Paper Hat

Downloads

9

Readme

epd2in13

This is a port of the epd2in13bc Python driver from Waveshare.
Key features of this library:

  • Fast, uses native GPIO and SPI libraries
  • Supports Red Color
  • Remappable Pins
  • Promises based
  • Can render from a Canvas or an Image

Since this device is only capble of single tone (black or white, or red), it uses a frame buffer of 1 bit per pixel.
Although this device natively uses a portrait layout per the diagram below, it is mapped to a landscape layout instead for practical rendering of images or canvas.
Hence, Width > Height for prepareImageFile or prepareCanvas function calls.
Layout

In-Action Shot

Action Shot

Dependencies

  1. GPIO
  2. SPI-Devicve
  3. ImageJS for buffer rendering

Getting Started

npm install epd2in13

Example Code

    const epd2in13 = require('epd2in13');
    const { createCanvas, registerFont } = require('canvas');

    const display = new epd2in13(); // Or potentially call new epd2in13({ RST_PIN: 10, BUSY_PIN: 11 }) if the pins are remapped for any reason

    // Setup the canvases and context here
    registerFont('./fonts/Montserrat-Medium.ttf', { family: 'Montserrat' });
    const black = createCanvas(display.width, display.height);
    const bctx = black.getContext('2d');
    const red = createCanvas(display.width, display.height);
    const rctx = red.getContext('2d');

    // Black context here
    bctx.fillStyle = 'white';
    bctx.fillRect(0, 0, display.width, display.height);
    bctx.font = '20px Montserrat';
    bctx.textBaseline = 'top';
    bctx.fillStyle = 'black';
    bctx.fillText('epd2in13 Driver', 5, 5);

    // Red context here
    rctx.fillStyle = 'white';
    rctx.fillRect(0, 0, display.width, display.height);
    rctx.fillStyle = 'black';
    rctx.fillRect(0, 35, 80, 16);
    rctx.font = '10px Montserrat';
    rctx.fillStyle = 'white';
    rctx.fillText('By gaweee', 5, 45);


    display.init()
        .then(() => display.clear())
        .then(() => Promise.all([display.prepareCanvas(black), display.prepareCanvas(red)]))
        .then(([blackBuffer, redBuffer]) => display.display(blackBuffer, redBuffer))
        .then((buffer) => display.wait())
        .then(() => display.clear())
        .then(() => display.prepareImageFile('./test.png'))
        .then((buffer) => display.display(buffer))
        .then((buffer) => display.wait())
        .then(() => display.clear())
        .then(() => display.sleep())

Functions Calls

epd2in13.init()
Runs the initialization sequence (Required).

epd2in13.reset()
Resets the display, runs already as part of the initialization sequence.

epd2in13.display(black=[], red=[])
Renders a combination of black and red optional buffers that follows a portrait layout.
Refer to layout diagram above.

epd2in13.prepareCanvas
Translates the canvas into an image and sends to prepareImageBuffer call below.

epd2in13.prepareImageFile
Loads an image by fileaname and sends to prepareImageBuffer call below.

epd2in13.prepareImageBuffer
Takes in the image buffer and prepares it (pixel by pixel) for display, in the process maps the output from landscape to portrait layout.

epd2in13.clear(0xFF)
Flushes the screen to white, optionally send 0x00 for black.

epd2in13.wait()
GPIO delay before the next event.

epd2in13.sleep()
Power down (retains ink on screen) the hat and stop listening to events.

TODO

  • Abstract the driver to support multiple other displays in the future
  • Optional rotation