A Raspberry Pi display driver for LCDs running the ILI9341 chip, like the Waveshare 2.4inch LCD Module.
Please make sure that you have rpio installed and set-up according to its system requirements.
npm install rpio
npm install rpi-ili9341-lcd
You need to pass the bitmap of the image you want to display to the showImage()
method.
Here's a simple example that fills the entire display with a single color.
See the Examples section for more advanced usages.
const rpio = require("rpio");
const { ILI9341_LCD } = require('rpi-ili9341-lcd');
const color = [0xff, 0x00, 0xff]; //magenta #FF00FF
rpio.init({ mapping: "gpio", gpiomem: false });
const disp = new ILI9341_LCD(rpio, { width: 240, height: 320 });
disp.Init();
disp.clear();
disp.showImage({
width: 240,
height: 320,
data: Buffer.alloc(240 * 320 * 3, Buffer.from(color))
});
disp.moduleExit();
- Fill the screen with a single color
- Using
pngjs
to display an image from a .png file - Using
node-canvas
to draw different elements - Using
sharp
to resize and rotate a .jpg file before displaying it
It was only tested on the Waveshare 2.4inch LCD Module because it's the only ILI9341-based display that I own.
Please open an issue if you need support for a different model.
See the "Raspberry Pi Guides" section here to learn how to connect your LCD to the Raspberry Pi, but as listed in the FAQ section there, do not connect the BL pin.
This code was ported from the Python version here
I'm getting a Cannot find module 'rpio'
error when trying to run the example code. What should I do?
This library depends on rpio as a peerDependency
. Make sure that you have it installed and set-up according to its system requirements.
To run tests, run the following command
npm run test