Kaluma library for PCD8544, a.k.a Nokia 5110 (Monochrome LCD Display)
You can get Nokia 5110 LCD displays from belows:
Here is a wiring example for SPI0
.
Raspberry Pi Pico | PCD8544 (Nokia 5110) |
---|---|
3V3 | VCC |
GND | GND |
GP19 (SPI0 TX) | DIN |
GP18 (SPI0 CLK) | CLK |
GP20 | DC |
GP21 | RST |
GP17 | CE (CS) |
GP22 | BL (LED) |
npm i https://github.com/niklauslee/pcd8544
You can initialize PCD8544 driver using SPI interface as below:
const {PCD8544} = require('pcd8544');
const pcd8544 = new PCD8544();
pcd8544.setup(board.spi(0), {dc: 20, cs: 17, rst: 21, bl: 22});
const gc = pcd8544.getContext();
// Use Graphics APIs
// gc.drawRect(0, 0, width, height);
// gc.display();
A class for PCD8544 driver communicating with SPI interface.
Create an instance of PCD8544 driver.
spi
<SPI>
An instance ofSPI
to communicate.options
<object>
Options for initialization.dc
<number>
Pin number for DC. Default-1
.cs
<number>
Pin number for CS. Default-1
.rst
<number>
Pin number for RST. Default-1
.bl
<number>
Pin number for BL (Backlight). Default-1
.bias
<number>
Bias value. Default0x04
.contrast
<number>
Contrast value. Default0x3F
.rotation
<number>
Rotation of screen. One of0
(0 degree),1
(90 degree in clockwise),2
(180 degree in clockwise), and3
(270 degree in clockwise). Default:0
.
Setup PCD8544 driver for a given SPI bus and options.
- Returns:
<BufferedGraphicsContext>
An instance of buffered graphic context for PCD8544.
bias
<number>
Bias value.
Set bias of the display.
contrast
<number>
Contrast value.
Set contrast of the display.
value
<number>
HIGH
orLOW
.
Turn on/off the backlight.
example.js
(84x48 resolution)