Class Pcd8544
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
intThe data command pin.
spiDevice
SpiDeviceThe SPI device.
resetPin
intThe reset pin. Use a negative number if you don't want to use it.
pwmBacklight
PwmChannelThe PWM channel for the back light.
gpioController
GpioControllerThe GPIO Controller.
shouldDispose
boolTrue 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
intThe data command pin.
spiDevice
SpiDeviceThe SPI device.
resetPin
intThe reset pin. Use a negative number if you don't want to use it.
backlightPin
intThe pin back light.
gpioController
GpioControllerThe GPIO Controller.
shouldDispose
boolTrue 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
ScreenBufferByteSize
Size of the screen 48 x 84 / 8 in bytes.
public const int ScreenBufferByteSize = 504
Field Value
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
BacklightOn
Enable/disable the backlight. (Will always return false if no backlight pin was provided.)
public bool BacklightOn { get; set; }
Property Value
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
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
Contrast
Gets or sets the contrast. Accepted values are from 0 to 127.
public byte Contrast { get; set; }
Property Value
Exceptions
- ArgumentOutOfRangeException
Contrast value must be between 0 and 127.
DisplayOn
Enable/disable the display.
public bool DisplayOn { get; set; }
Property Value
Enabled
Gets or sets a value indicating whether the screen is enabled.
public bool Enabled { get; set; }
Property Value
InvertedColors
Gets or sets a value indicating whether the screen colors are inverted.
public bool InvertedColors { get; set; }
Property Value
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
PixelScreenSize
The size of the screen in terms of pixels.
public static Size PixelScreenSize { get; }
Property Value
Size
The size of the screen in terms of characters.
public Size Size { get; }
Property Value
Temperature
Gets or sets the temperature coefficient.
public ScreenTemperature Temperature { get; set; }
Property Value
UnderlineCursorVisible
Enable/disable the underline cursor.
public bool UnderlineCursorVisible { get; set; }
Property Value
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
intShould 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
intShould be between 0 and NumberOfCustomCharactersSupported.
characterMap
SpanByteProvide 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
intThe first point X coordinate.
y1
intThe first point Y coordinate.
x2
intThe second point X coordinate.
y2
intThe second point Y coordinate.
isOn
boolTrue 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
PointFirst point coordinate.
p2
PointSecond point coordinate.
isOn
boolTrue 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
intThe X coordinate.
y
intThe Y coordinate.
isOn
boolTrue 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
Returns
- bool
True if success.
DrawRectangle(Rectangle, bool, bool)
Draw a rectangle.
public void DrawRectangle(Rectangle rectangle, bool isOn, bool isFilled)
Parameters
rectangle
RectangleThe rectangle.
isOn
boolTrue if the rectangle has pixels on, false for off.
isFilled
boolIf 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
intThe X coordinate.
y
intThe Y coordinate.
width
intThe width of the rectangle.
height
intThe height of the rectangle.
isOn
boolTrue if the rectangle has pixels on, false for off.
isFilled
boolIf 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
PointThe coordinate of the point.
size
SizeThe size of the rectangle.
isOn
boolTrue if the rectangle has pixels on, false for off.
isFilled
boolIf it's filled or not.
SetByteMap(SpanByte)
Set the byte map.
public void SetByteMap(SpanByte byteMap)
Parameters
byteMap
SpanByteA 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
intThe column position from left to right starting with 0 to 14.
top
intThe 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
SpanCharText to print.
Write(string)
Write text.
public void Write(string text)
Parameters
text
stringThe text to write.
WriteLine(string)
Write text and set cursor position to next line.
public void WriteLine(string text)
Parameters
text
stringThe text to write.