Remarks

SerialLcd
Status Not Working
Source code GitHub
NuGet package Not Published

Serial LCD backpacks provide a convenient way to display data on a 16x2 or 20x4 LCD display. (this driver not currently working)

Purchasing

This driver supports the Sparkfun Serial Backpack. This can also be purchased as a kit with both the serial backpack and the LCD.

Code Example

The application below outputs Hello, world on the LCD:

public class DisplayApp : App<F7Micro, DisplayApp>
{
    public MeadowApp()
    {
        var display = new SerialLcd();
        //
        //  Clear the display ready for the test.
        //
        display.Clear();
        display.SetCursorStyle(SerialLcd.CursorStyle.BlinkingBoxOff);
        display.SetCursorStyle(SerialLcd.CursorStyle.UnderlineOff);
        //
        //  Display some text on the bottom row of a 16x2 LCD.
        //
        display.SetCursorPosition(2, 1);
        display.DisplayText("Hello, world");
    }
}

Wiring Example

The Serial LCD requires only three connections; power, ground and serial data. The Tx pin on Meadow should be connected to the Rx pin on the serial backpack:

Characteristic Locus
Inheritance System.Object > SerialLcd
Namespace Meadow.Foundation.Displays
Assembly SerialLcd.dll

Syntax

public class SerialLcd : ITextDisplay

Constructors

SerialLcd(IIODevice, SerialPortName, TextDisplayConfig, Int32, Parity, Int32, StopBits)

Create a new SerialLcd object.

Declaration
public SerialLcd(IIODevice device, SerialPortName port, TextDisplayConfig config = null, int baudRate = 9600, Parity parity = null, int dataBits = 8, StopBits stopBits = null)

Parameters

Type Name Description
IIODevice device
SerialPortName port
TextDisplayConfig config

TextDisplayConfig object defining the Lcd dimension (null will default to 16x2).

System.Int32 baudRate

Baud rate to use (default = 9600).

Parity parity

Parity to use (default is None).

System.Int32 dataBits

Number of data bits (default is 8 data bits).

StopBits stopBits

Number of stop bits (default is one stop bit).

Fields

_lock

object for using lock() to do thread synch

Declaration
protected object _lock

Field Value

Type Description
System.Object

Properties

DisplayConfig

Display configuration (width and height).

Declaration
public TextDisplayConfig DisplayConfig { get; }

Property Value

Type Description
TextDisplayConfig

Methods

ClearLine(Byte)

Clears the specified line by writing a string of empty characters to it.

Declaration
public void ClearLine(byte lineNumber)

Parameters

Type Name Description
System.Byte lineNumber

Line to clear (0-3)

ClearLines()

Clear the display.

Declaration
public void ClearLines()

DisplayText(String)

Display the text at the current cursor position.

Declaration
[Obsolete("Use .Write methods instead.")]
public void DisplayText(string text)

Parameters

Type Name Description
System.String text

Text to display.

MoveCursor(SerialLcd.Direction)

Move the cursor either right or left on the display.

Declaration
public void MoveCursor(SerialLcd.Direction direction)

Parameters

Type Name Description
SerialLcd.Direction direction

Direction to move the cursor, left or right.

SaveCustomCharacter(Byte[], Byte)

Saves a custom character to one of 8 slots in the CGRAM. Custom characters are defined as charater maps and can be created using online graphical tools such as the one found at: http://maxpromer.github.io/Lcd-Character-Creator/

Note: due to .Net's underlying string implementation, slot 0 is unusable unless you decode the string yourself and use the Write(byte[] chars) method. Otherwise, when the string is created, .Net treats the 0 character as a string terminator.

Declaration
public void SaveCustomCharacter(byte[] characterMap, byte address)

Parameters

Type Name Description
System.Byte[] characterMap

Character map defining the 5x8 character.

System.Byte address

0-7

ScrollDisplay(SerialLcd.Direction)

Scroll the contents of the display one character in the specified direction.

Declaration
public void ScrollDisplay(SerialLcd.Direction direction)

Parameters

Type Name Description
SerialLcd.Direction direction

Direction to scroll the display, left or right.

SetBaudRate(SerialLcd.LcdBaudRate)

Change the baud rate of the display using the command interface.

Declaration
public void SetBaudRate(SerialLcd.LcdBaudRate baudRate)

Parameters

Type Name Description
SerialLcd.LcdBaudRate baudRate

SetBrightness(Single)

Sets the backlight brightness of the Lcd. Valid values are 0 through 1. Sleeps for 125milliseconds after setting to let the display settle.

0 = Off 0.5 = 50% 1 = 100%

Declaration
public void SetBrightness(float brightness = 0.75F)

Parameters

Type Name Description
System.Single brightness

SetCursorPosition(Byte, Byte)

Set the cursor position on the display to the specified column and line.

Declaration
public void SetCursorPosition(byte column, byte line)

Parameters

Type Name Description
System.Byte column

Column on the display to move the cursor to (0-15 or 0-19).

System.Byte line

Line on the display to move the cursor to (0-3).

SetCursorStyle(SerialLcd.CursorStyle)

Set the cursor style to underline or block. The cursor can also be blinking or solid.

Declaration
public void SetCursorStyle(SerialLcd.CursorStyle style)

Parameters

Type Name Description
SerialLcd.CursorStyle style

New cursor style (Block/Underline, Blinking/Solid).

SetDisplayVisualState(SerialLcd.DisplayPowerState)

Turn the display on or off.

Declaration
public void SetDisplayVisualState(SerialLcd.DisplayPowerState state)

Parameters

Type Name Description
SerialLcd.DisplayPowerState state

New power state for the display.

SetSplashScreen(String, String)

Set up the splash screen.

Declaration
public void SetSplashScreen(string line1, string line2)

Parameters

Type Name Description
System.String line1
System.String line2

ToggleSplashScreen()

Toggle the splash screen.

Declaration
public void ToggleSplashScreen()

Write(Byte[])

Displays the characters at the current cursor position. Unlike the string text overload, this assumes the text has already been encoded to characters. Can be useful in sending pre-encoded characters, or accessing custom a custom character saved in the 0 slot.

Declaration
public void Write(byte[] chars)

Parameters

Type Name Description
System.Byte[] chars

Write(String)

Display the text at the current cursor position.

Declaration
public void Write(string text)

Parameters

Type Name Description
System.String text

Text to display.

WriteLine(String, Byte)

Writes the specified text to the specified line.

Declaration
public void WriteLine(string text, byte lineNumber)

Parameters

Type Name Description
System.String text

Text to display.

System.Byte lineNumber

Line to write the text on (0-3).