Table of Contents

Class Pcd8544

Namespace
Iot.Device
Assembly
Iot.Device.Pcd8544.dll

PCD8544 - 48 × 84 pixels matrix LCD, famous Nokia 5110 screen.

public class Pcd8544 : ICharacterLcd
Inheritance
Pcd8544
Implements

Constructors

Pcd8544(int, SpiDevice, int, PwmChannel?, GpioController?, bool)

Initializes a new instance of the Pcd8544 class.

public Pcd8544(int dataCommandPin, SpiDevice spiDevice, int resetPin = -1, PwmChannel? pwmBacklight = null, GpioController? gpioController = null, bool shouldDispose = true)

Parameters

dataCommandPin int

The data command pin.

spiDevice SpiDevice

The SPI device.

resetPin int

The reset pin. Use a negative number if you don't want to use it.

pwmBacklight PwmChannel

The PWM channel for the back light.

gpioController GpioController

The GPIO Controller.

shouldDispose bool

True to dispose the GPIO controller.

Exceptions

ArgumentOutOfRangeException

Invalid 'Data Command' pin number. Pin number can not be less than zero.

ArgumentNullException

spiDevice is null.

Pcd8544(int, SpiDevice, int, int, GpioController?, bool)

Initializes a new instance of the Pcd8544 class.

public Pcd8544(int dataCommandPin, SpiDevice spiDevice, int resetPin = -1, int backlightPin = -1, GpioController? gpioController = null, bool shouldDispose = true)

Parameters

dataCommandPin int

The data command pin.

spiDevice SpiDevice

The SPI device.

resetPin int

The reset pin. Use a negative number if you don't want to use it.

backlightPin int

The pin back light.

gpioController GpioController

The GPIO Controller.

shouldDispose bool

True to dispose the GPIO controller.

Exceptions

ArgumentOutOfRangeException

Invalid 'Data Command' pin number. Pin number can not be less than zero.

ArgumentNullException

spiDevice is null.

Fields

ColorBitPerPixel

Number of bit per pixel for the color.

public const int ColorBitPerPixel = 1

Field Value

int

ScreenBufferByteSize

Size of the screen 48 x 84 / 8 in bytes.

public const int ScreenBufferByteSize = 504

Field Value

int

Properties

BacklightBrightness

Gets or sets the brightness level of the LCD backlight. Supported values are ftrom 0.0 to 1.0. If a pin is used, the threshold for full light is more then 0.5.

public float BacklightBrightness { get; set; }

Property Value

float

BacklightOn

Enable/disable the backlight. (Will always return false if no backlight pin was provided.)

public bool BacklightOn { get; set; }

Property Value

bool

Bias

Gets or sets the bias. Supported values are from 0 to 7. Bias represent the voltage applied to the LCD. The highest, the darker the screen will be.

public byte Bias { get; set; }

Property Value

byte

Exceptions

ArgumentOutOfRangeException

Bias value can not be more than 7.

BlinkingCursorVisible

Gets or sets a value indicating whether the blinking cursor is visible. This is not supported on this screen, this function will have no effect.

public bool BlinkingCursorVisible { get; set; }

Property Value

bool

Contrast

Gets or sets the contrast. Accepted values are from 0 to 127.

public byte Contrast { get; set; }

Property Value

byte

Exceptions

ArgumentOutOfRangeException

Contrast value must be between 0 and 127.

DisplayOn

Enable/disable the display.

public bool DisplayOn { get; set; }

Property Value

bool

Enabled

Gets or sets a value indicating whether the screen is enabled.

public bool Enabled { get; set; }

Property Value

bool

InvertedColors

Gets or sets a value indicating whether the screen colors are inverted.

public bool InvertedColors { get; set; }

Property Value

bool

NumberOfCustomCharactersSupported

Returns the number of custom characters for this display. A custom character is one that can be user-defined and assigned to a slot using CreateCustomCharacter(int, SpanByte)

public int NumberOfCustomCharactersSupported { get; }

Property Value

int

PixelScreenSize

The size of the screen in terms of pixels.

public static Size PixelScreenSize { get; }

Property Value

Size

Size

The size of the screen in terms of characters.

public Size Size { get; }

Property Value

Size

Temperature

Gets or sets the temperature coefficient.

public ScreenTemperature Temperature { get; set; }

Property Value

ScreenTemperature

UnderlineCursorVisible

Enable/disable the underline cursor.

public bool UnderlineCursorVisible { get; set; }

Property Value

bool

Methods

Clear()

Clear the screen.

public void Clear()

CreateCustomCharacter(int, byte[])

Add a specific character to the font. It will replace existing embedded font character if it does already exist.

public void CreateCustomCharacter(int location, byte[] characterMap)

Parameters

location int

Should be between 0 and NumberOfCustomCharactersSupported.

characterMap byte[]

Provide an array of 8 bytes containing the pattern.

Remarks

Normal font character is a 5 bytes array aligned vertically. If the array is 8 bytes long, it will assume the font encoding is then on the lower 5 bits of each bytes.

CreateCustomCharacter(int, SpanByte)

Add a specific character to the font. It will replace existing embedded font character if it does already exist.

public void CreateCustomCharacter(int location, SpanByte characterMap)

Parameters

location int

Should be between 0 and NumberOfCustomCharactersSupported.

characterMap SpanByte

Provide an array of 8 bytes containing the pattern.

Remarks

Normal font character is a 5 bytes array aligned vertically. If the array is 8 bytes long, it will assume the font encoding is then on the lower 5 bits of each bytes.

Exceptions

ArgumentOutOfRangeException

location must be smaller than NumberOfCustomCharactersSupported

ArgumentOutOfRangeException

characterMap must be either a 5-byte or an 8-byte array.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Draw()

Draw what's in memory to the the screen.

public void Draw()

DrawLine(int, int, int, int, bool)

Draw a line.

public void DrawLine(int x1, int y1, int x2, int y2, bool isOn)

Parameters

x1 int

The first point X coordinate.

y1 int

The first point Y coordinate.

x2 int

The second point X coordinate.

y2 int

The second point Y coordinate.

isOn bool

True if the line has pixels on, false for off.

DrawLine(Point, Point, bool)

Draw a line.

public void DrawLine(Point p1, Point p2, bool isOn)

Parameters

p1 Point

First point coordinate.

p2 Point

Second point coordinate.

isOn bool

True if the line has pixels on, false for off.

DrawPoint(int, int, bool)

Draw a point.

public bool DrawPoint(int x, int y, bool isOn)

Parameters

x int

The X coordinate.

y int

The Y coordinate.

isOn bool

True if the point has pixels on, false for off.

Returns

bool

True if success.

DrawPoint(Point, bool)

Draw a point.

public bool DrawPoint(Point point, bool isOn)

Parameters

point Point

The point to draw.

isOn bool

True if the point has pixels on, false for off.

Returns

bool

True if success.

DrawRectangle(Rectangle, bool, bool)

Draw a rectangle.

public void DrawRectangle(Rectangle rectangle, bool isOn, bool isFilled)

Parameters

rectangle Rectangle

The rectangle.

isOn bool

True if the rectangle has pixels on, false for off.

isFilled bool

If it's filled or not.

DrawRectangle(int, int, int, int, bool, bool)

Draw a rectangle.

public void DrawRectangle(int x, int y, int width, int height, bool isOn, bool isFilled)

Parameters

x int

The X coordinate.

y int

The Y coordinate.

width int

The width of the rectangle.

height int

The height of the rectangle.

isOn bool

True if the rectangle has pixels on, false for off.

isFilled bool

If it's filled or not.

DrawRectangle(Point, Size, bool, bool)

Draw a rectangle.

public void DrawRectangle(Point p, Size size, bool isOn, bool isFilled)

Parameters

p Point

The coordinate of the point.

size Size

The size of the rectangle.

isOn bool

True if the rectangle has pixels on, false for off.

isFilled bool

If it's filled or not.

SetByteMap(SpanByte)

Set the byte map.

public void SetByteMap(SpanByte byteMap)

Parameters

byteMap SpanByte

A 504 sized byte representing the full image.

Exceptions

ArgumentOutOfRangeException

byteMap length must be equal to ScreenBufferByteSize

SetCursorPosition(int, int)

Moves the cursor to an explicit column and row position.

public void SetCursorPosition(int left, int top)

Parameters

left int

The column position from left to right starting with 0 to 14.

top int

The row position from the top starting with 0 to 5.

Exceptions

ArgumentOutOfRangeException

The given position is not inside the display.

Write(char[])

Write a raw byte stream to the display. Used if character translation already took place.

public void Write(char[] text)

Parameters

text char[]

Text to print.

Write(SpanChar)

Write a raw byte stream to the display. Used if character translation already took place.

public void Write(SpanChar text)

Parameters

text SpanChar

Text to print.

Write(string)

Write text.

public void Write(string text)

Parameters

text string

The text to write.

WriteLine(string)

Write text and set cursor position to next line.

public void WriteLine(string text)

Parameters

text string

The text to write.