Table of Contents

Class LcdInterface

Namespace
Iot.Device.CharacterLcd
Assembly
Iot.Device.CharacterLcd.dll

Abstraction layer for accessing the lcd IC.

public abstract class LcdInterface
Inheritance
LcdInterface

Constructors

LcdInterface()

protected LcdInterface()

Properties

BacklightOn

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

public abstract bool BacklightOn { get; set; }

Property Value

bool

EightBitMode

True if device uses 8-bits for communication, false if device uses 4-bits

public abstract bool EightBitMode { get; }

Property Value

bool

WaitMultiplier

The command wait time multiplier for the LCD.

public double WaitMultiplier { get; set; }

Property Value

double

Remarks

In order to handle controllers that might be running at a much slower clock we're exposing a multiplier for any "hard coded" waits. This can also be used to reduce the wait time when the clock runs faster or other overhead (time spent in other code) allows for more aggressive timing.

There is a busy signal that can be checked that could make this moot, but currently we are unable to check the signal fast enough to make gains (or even equal) going off hard timings. The busy signal also requires having a r/w pin attached.

Methods

CreateFromShiftRegister(int, int, int[], int, ShiftRegister?, bool)

Creates a ShiftRegister based interface for the LCD.

public static LcdInterface CreateFromShiftRegister(int registerSelectPin, int enablePin, int[] dataPins, int backlightPin = -1, ShiftRegister? shiftRegister = null, bool shouldDispose = true)

Parameters

registerSelectPin int

The pin that controls the register select.

enablePin int

The pin that controls the enable switch.

dataPins int[]

Collection of pins holding the data that will be printed on the screen.

backlightPin int

The optional pin that controls the backlight of the display.

shiftRegister ShiftRegister

The shift register that drives the LCD.

shouldDispose bool

True to dispose the shift register.

Returns

LcdInterface

Remarks

Pin parameters should be set according to which output pin of the shift register they are connected to (e.g. 0 to 7 for 8bit shift register).

CreateGpio(int, int, int[], int, float, int, GpioController?, bool)

Creates a GPIO based interface for the LCD.

public static LcdInterface CreateGpio(int registerSelectPin, int enablePin, int[] dataPins, int backlightPin = -1, float backlightBrightness = 1, int readWritePin = -1, GpioController? controller = null, bool shouldDispose = true)

Parameters

registerSelectPin int

The pin that controls the register select.

enablePin int

The pin that controls the enable switch.

dataPins int[]

Collection of pins holding the data that will be printed on the screen.

backlightPin int

The optional pin that controls the backlight of the display.

backlightBrightness float

The brightness of the backlight. 0.0 for off, 1.0 for on.

readWritePin int

The optional pin that controls the read and write switch.

controller GpioController

The controller to use with the LCD. If not specified, uses the platform default.

shouldDispose bool

True to dispose the Gpio Controller

Returns

LcdInterface

CreateI2c(I2cDevice, bool)

Create an integrated I2c based interface for the LCD.

public static LcdInterface CreateI2c(I2cDevice device, bool uses8Bit = true)

Parameters

device I2cDevice

The I2c device for the LCD.

uses8Bit bool

True if the device uses 8 Bit commands, false if it handles only 4 bit commands.

Returns

LcdInterface

Remarks

This is for on-chip I2c support. For connecting via I2c GPIO expanders, use the GPIO interface CreateGpio(int, int, int[], int, float, int, GpioController?, bool).

Dispose()

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

public void Dispose()

Dispose(bool)

Releases unmanaged resources used by LcdInterface and optionally release managed resources

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

SendCommand(byte)

Sends command to the LCD device

public abstract void SendCommand(byte command)

Parameters

command byte

Byte representing the command

SendCommandAndWait(byte)

The initialization sequence and some other complex commands should be sent with delays, or the display may behave unexpectedly. It may show random, blinking characters or display text very faintly only.

public virtual void SendCommandAndWait(byte command)

Parameters

command byte

The command to send

SendCommands(SpanByte)

Send commands to the LCD device

public abstract void SendCommands(SpanByte values)

Parameters

values SpanByte

Each byte represents command to be send

SendData(byte)

Sends byte to LCD device

public abstract void SendData(byte value)

Parameters

value byte

Byte value to be sent to the device

SendData(SpanByte)

Sends data to the LCD device

public abstract void SendData(SpanByte values)

Parameters

values SpanByte

Bytes to be send to the device

SendData(SpanChar)

Sends data to the LCD device

public abstract void SendData(SpanChar values)

Parameters

values SpanChar

Char value to be send to the device

WaitForNotBusy(int)

Wait for the device to not be busy.

public virtual void WaitForNotBusy(int microseconds)

Parameters

microseconds int

Time to wait if checking busy state isn't possible/practical.