epd2in7b
A Node.js package for the 2.7inch e-Paper HAT(B) waveshare display on a Raspberry Pi 2/3/zero. It was forked from williwasser's epd7x5 Node.js package It is rewritten in the Node non-blocking way and implements demo code provided by Waveshare for 2.inch e-Paper HAT(B).
Dependencies
- WiringPi for GPIO access of Raspberry Pi
- libgd2 for text output and drawing
- rpi-gpio-buttons for HAT keys handling
Installation
Enable the SPI interface on Raspberry Pi: sudo raspi-config
WiringPi: follow installation on wiringpi.com
libgd2: sudo apt-get install libgd2-dev # libgd
epd2in7b: npm install epd2in7b
Usage example
const epd = const font = '/home/marco/fonts/Roboto-Regular.ttf';const fontSize = 12 const img = epd;const width = epdheightconst height = epdwidthlet epdp = epd const refreshDisplay = epdp = epdp // init is required since we set it sleeping at the end of this chain // Handle buttonsepdbuttonshandler // Handle exit { let promise = null if optionscleanup promise = img if err && errstack console if optionsexit if promise !== null promise else process } processprocessprocessprocessprocess
The module exports the following functions and constants:
Functions:
epd.init({fastLut: false}))
fastLut
parameter is an attempt to speed up refresh process using LUT alternative table on the Web. It doesn't work work well with red color.
epd.getImageBuffer('landscape')
Use landscape
to get a buffer oriented in landscape mode.
epd.displayImageBuffer(img)
epd.clear()
Equivalent to push a white image
epd.sleep()
Put the display in sleep mode. init
is required to come back to operations.
epd.buttons.handler
The rpi-gpio-buttons
instance
Constants:
epd.buttons.button1
epd.buttons.button2
epd.buttons.button3
epd.buttons.button4
epd.colors.white
epd.colors.black
epd.colors.red
epd.width
epd.height
gd namespace for access of functions on the gd object:
epd.gd
example: epd.gd.createFromFile(path)
to open an image
Documentation of node-gd functions can be found here
License
Apache 2.0
Todos
Handle errors