Keywords
pcd8544nokia5110lcddisplay

Version

Updated
3 months ago

Created
8 months ago
pcd8544
PCD8544 driver for Nokia 5110 LCD display
example

Overview

PCD8544 is a monochrome LCD driver (a.k.a Nokia 5110 LCD).

1582692437901.jpg

You can get Nokia 5110 LCD displays from belows:

#Wiring

Here is a wiring example for SPI0 of Kameleon Core.

PCD8544 (Nokia 5110)Kameleon Core
VCC3V3
GNDGND
DIN12 (SPI0-MOSI)
CLK10 (SPI0 CLK)
DC8
RST9
CE (CS)17
BL (LED)19

1582692491276.png

Usage

You can initialize PCD8544 driver using SPI interface as below:

var PCD8544 = require('@niklauslee/pcd8544').PCD8544;
var SPI = require('spi').SPI;
var spi0 = new SPI(0);
var pcd8544 = new PCD8544();
var options = {
  dcPin: 8,
  csPin: 17,
  rstPin: 9,
  blPin: 19
};
pcd8544.setup(spi0, options, () => {
  var gc = pcd8544.getContext();
  // Use Graphics APIs
  // gc.drawRect(0, 0, width, height);
  // gc.display();
});

API

Class: PCD8544

A class for PCD8544 driver communicating with SPI interface.

new PCD8544()

Create an instance of PCD8544 driver.

pcd8544.setup(spi[, options, callback])

  • spi <SPI> An instance of SPI to communicate.
  • options <object> Options for initialization.
    • dcPin <number> Pin number for DC. Default -1.
    • csPin <number> Pin number for CS. Default -1.
    • rstPin <number> Pin number for RST. Default -1.
    • blPin <number> Pin number for BL (Backlight). Default -1.
    • bias <number> Bias value. Default 0x04.
    • contrast <number> Contrast value. Default 0x3F.
    • rotation <number> Rotation of screen. One of 0 (0 degree), 1 (90 degree in clockwise), 2 (180 degree in clockwise), and 3 (270 degree in clockwise). Default: 0.
  • callback <Function> A function called when setup is complete.

Setup PCD8544 driver for a given SPI bus and options.

pcd8544.getContext()

  • Returns: <BufferedGraphicsContext> An instance of buffered graphic context for PCD8544.

Get a graphic context so that you can use Graphics APIs.

pcd8544.setBias(bias)

  • bias <number> Bias value.

Set bias of the display.

pcd8544.setContrast(contrast)

  • contrast <number> Contrast value.

Set contrast of the display.

pcd8544.setBacklight(value)

  • value <number> HIGH or LOW.

Turn on/off the backlight.

Examples

  • example.js (84x48 resolution)