Characteristic Locus
Inheritance object > TftSpiBase > Gc9a01 > Hx8357d > Ili9163 > Ili9341 > Ili9481 > Ili9486 > Ili9488 > Rm68140 > S6D02A1 > Ssd1331 > Ssd1351 > St7735 > St7789 > St7796s
Implements IGraphicsDisplay ISpiPeripheral IDisposable
Inherited Members object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow.Foundation.Displays
Assembly TftSpi.dll

Syntax

public abstract class TftSpiBase : IGraphicsDisplay, ISpiPeripheral, IDisposable

Constructors

TftSpiBase(ISpiBus, IDigitalOutputPort?, IDigitalOutputPort, IDigitalOutputPort?, int, int, ColorMode)

Represents an abstract TftSpiBase object

Declaration
public TftSpiBase(ISpiBus spiBus, IDigitalOutputPort? chipSelectPort, IDigitalOutputPort dataCommandPort, IDigitalOutputPort? resetPort, int width, int height, ColorMode colorMode = ColorMode.Format16bppRgb565)

Parameters

Type Name Description
ISpiBus spiBus

SPI bus connected to display

IDigitalOutputPort chipSelectPort

Chip select output port

IDigitalOutputPort dataCommandPort

Data command output port

IDigitalOutputPort resetPort

Reset output port

int width

Width of display in pixels

int height

Height of display in pixels

ColorMode colorMode

The color mode to use for the display buffer

TftSpiBase(ISpiBus, IPin?, IPin, IPin?, int, int, ColorMode)

Represents an abstract TftSpiBase object

Declaration
public TftSpiBase(ISpiBus spiBus, IPin? chipSelectPin, IPin dcPin, IPin? resetPin, int width, int height, ColorMode colorMode = ColorMode.Format16bppRgb565)

Parameters

Type Name Description
ISpiBus spiBus

SPI bus connected to display

IPin chipSelectPin

Chip select pin

IPin dcPin

Data command pin

IPin resetPin

Reset pin

int width

Width of display in pixels

int height

Height of display in pixels

ColorMode colorMode

The color mode to use for the display buffer

Fields

Command

Command convenience bool

Declaration
protected const bool Command = false

Field Value

Type Description
bool

Data

Data convenience bool

Declaration
protected const bool Data = true

Field Value

Type Description
bool

chipSelectPort

The chip select port

Declaration
protected IDigitalOutputPort? chipSelectPort

Field Value

Type Description
IDigitalOutputPort

dataCommandPort

The data command port

Declaration
protected IDigitalOutputPort dataCommandPort

Field Value

Type Description
IDigitalOutputPort

imageBuffer

The off-screen image buffer

Declaration
protected IPixelBuffer imageBuffer

Field Value

Type Description
IPixelBuffer

nativeHeight

The display's native height without rotation

Declaration
protected int nativeHeight

Field Value

Type Description
int

nativeWidth

The display's native width without rotation

Declaration
protected int nativeWidth

Field Value

Type Description
int

readBuffer

The read buffer

Declaration
protected Memory<byte> readBuffer

Field Value

Type Description
Memory<byte>

resetPort

The reset port

Declaration
protected IDigitalOutputPort? resetPort

Field Value

Type Description
IDigitalOutputPort

setAddressLastX0

Previous x0 value passed to SetAddressWindow Used for optimization to avoid unnecessary SPI commands

Declaration
protected int setAddressLastX0

Field Value

Type Description
int

setAddressLastX1

Previous x1 value passed to SetAddressWindow Used for optimization to avoid unnecessary SPI commands

Declaration
protected int setAddressLastX1

Field Value

Type Description
int

setAddressLastY0

Previous y0 value passed to SetAddressWindow Used for optimization to avoid unnecessary SPI commands

Declaration
protected int setAddressLastY0

Field Value

Type Description
int

setAddressLastY1

Previous y1 value passed to SetAddressWindow Used for optimization to avoid unnecessary SPI commands

Declaration
protected int setAddressLastY1

Field Value

Type Description
int

spiDisplay

The spi peripheral for the display

Declaration
protected ISpiCommunications spiDisplay

Field Value

Type Description
ISpiCommunications

Properties

ColorMode

The current display color mode

Declaration
public ColorMode ColorMode { get; }

Property Value

Type Description
ColorMode

DefaultColorMode

The display default color mode

Declaration
public abstract ColorMode DefaultColorMode { get; }

Property Value

Type Description
ColorMode

DefaultSpiBusMode

The default SPI bus mode for the device

Declaration
public virtual SpiClockConfiguration.Mode DefaultSpiBusMode { get; }

Property Value

Type Description
SpiClockConfiguration.Mode

DefaultSpiBusSpeed

The default SPI bus speed for the device

Declaration
public virtual Frequency DefaultSpiBusSpeed { get; }

Property Value

Type Description
Frequency

Height

Height of display in pixels

Declaration
public int Height { get; }

Property Value

Type Description
int

IsDisposed

Is the object disposed

Declaration
public bool IsDisposed { get; }

Property Value

Type Description
bool

PixelBuffer

The buffer used to store the pixel data for the display

Declaration
public IPixelBuffer PixelBuffer { get; }

Property Value

Type Description
IPixelBuffer

Rotation

The current rotation of the display

Declaration
public RotationType Rotation { get; protected set; }

Property Value

Type Description
RotationType

SetAddressBuffer

Temporary buffer that can be used to batch set address window buffer commands

Declaration
protected byte[] SetAddressBuffer { get; }

Property Value

Type Description
byte[]

SpiBusMode

The SPI bus mode for the device

Declaration
public SpiClockConfiguration.Mode SpiBusMode { get; set; }

Property Value

Type Description
SpiClockConfiguration.Mode

SpiBusSpeed

The SPI bus speed for the device

Declaration
public Frequency SpiBusSpeed { get; set; }

Property Value

Type Description
Frequency

SupportedColorModes

The color modes supported by the display

Declaration
public abstract ColorMode SupportedColorModes { get; }

Property Value

Type Description
ColorMode

Width

Width of display in pixels

Declaration
public int Width { get; }

Property Value

Type Description
int

Methods

Clear(Color)

Clear the display buffer to a color

Declaration
public void Clear(Color color)

Parameters

Type Name Description
Color color

The clear color

Clear(bool)

Clear the display.

Declaration
public void Clear(bool updateDisplay = false)

Parameters

Type Name Description
bool updateDisplay

Update the display once the buffer has been cleared when true.

CreateBuffer(ColorMode, int, int)

Create an off-screen buffer for the display

Declaration
protected void CreateBuffer(ColorMode colorMode, int width, int height)

Parameters

Type Name Description
ColorMode colorMode

The color mode

int width

The width in pixels

int height

The height in pixels

Exceptions

Type Condition
ArgumentException

Throws an exception if the color mode isn't supported

DelayMs(int)

Delay

Declaration
protected void DelayMs(int millseconds)

Parameters

Type Name Description
int millseconds

Milliseconds to delay

Dispose()

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

Declaration
public void Dispose()

Dispose(bool)

Dispose of the object

Declaration
protected virtual void Dispose(bool disposing)

Parameters

Type Name Description
bool disposing

Is disposing

DrawPixel(int, int, Color)

Draw a single pixel

Declaration
public void DrawPixel(int x, int y, Color color)

Parameters

Type Name Description
int x

x location in pixels

int y

y location in pixels

Color color

Color of pixel.

DrawPixel(int, int, bool)

Draw pixel at a location Primarily used for monochrome displays, prefer overload that accepts a Color

Declaration
public void DrawPixel(int x, int y, bool enabled)

Parameters

Type Name Description
int x

x location in pixels

int y

y location in pixels

bool enabled

Turn the pixel on (true) or off (false).

DrawPixel(int, int, byte, byte, byte)

Draw a single pixel

Declaration
public void DrawPixel(int x, int y, byte r, byte g, byte b)

Parameters

Type Name Description
int x

x location in pixels

int y

y location in pixels

byte r

8 bit red value

byte g

8 bit green value

byte b

8 bit blue value

Fill(Color, bool)

Fill the display buffer with a color

Declaration
public void Fill(Color color, bool updateDisplay = false)

Parameters

Type Name Description
Color color

The fill color

bool updateDisplay

If true, update the display after filling the buffer

Fill(int, int, int, int, Color)

Fill with a color

Declaration
public void Fill(int x, int y, int width, int height, Color color)

Parameters

Type Name Description
int x

X start position in pixels

int y

Y start position in pixels

int width

Width in pixels

int height

Height in pixels

Color color

The fill color

Initialize()

Initialize the display

Declaration
protected abstract void Initialize()

InvertPixel(int, int)

Invert the color of a single pixel as represented in the display buffer

Declaration
public void InvertPixel(int x, int y)

Parameters

Type Name Description
int x

x location in pixels

int y

y location in pixels

IsColorTypeSupported(ColorMode)

Is the color mode supported on this display

Declaration
public virtual bool IsColorTypeSupported(ColorMode colorType)

Parameters

Type Name Description
ColorMode colorType

The color mode

Returns

Type Description
bool

true if supported

SendCommand(LcdCommand)

Send a command to the display

Declaration
protected void SendCommand(TftSpiBase.LcdCommand command)

Parameters

Type Name Description
TftSpiBase.LcdCommand command

The command to send as an LcdCommand

SendCommand(Register)

Send a command to the display

Declaration
protected void SendCommand(TftSpiBase.Register command)

Parameters

Type Name Description
TftSpiBase.Register command

The command to send

SendCommand(byte)

Send a command to the display

Declaration
protected void SendCommand(byte command)

Parameters

Type Name Description
byte command

The command to send as a byte

SendData(byte)

Send a single byte to the display

Declaration
protected void SendData(byte data)

Parameters

Type Name Description
byte data

The byte to send

SendData(byte[])

Send a byte array of data to the display

Declaration
protected void SendData(byte[] data)

Parameters

Type Name Description
byte[] data

The data

SendData(int)

Send a single byte to the display (convenience method)

Declaration
protected void SendData(int data)

Parameters

Type Name Description
int data

The data to send

SetAddressWindow(int, int, int, int)

Set address window for display updates

Declaration
protected virtual void SetAddressWindow(int x0, int y0, int x1, int y1)

Parameters

Type Name Description
int x0

X start in pixels

int y0

Y start in pixels

int x1

X end in pixels

int y1

Y end in pixels

Show()

Draw the display buffer to screen

Declaration
public void Show()

Show(int, int, int, int)

Transfer part of the contents of the buffer to the display bounded by left, top, right and bottom Only supported in 16Bpp565 mode

Declaration
public void Show(int left, int top, int right, int bottom)

Parameters

Type Name Description
int left
int top
int right
int bottom

UpdateBuffer()

Update the display buffer if the dimensions change on rotation

Declaration
protected void UpdateBuffer()

Write(byte)

Write a byte to the display

Declaration
protected void Write(byte value)

Parameters

Type Name Description
byte value

The byte to send

Write(byte[])

Write a buffer to the display

Declaration
protected void Write(byte[] data)

Parameters

Type Name Description
byte[] data

The data to send

WriteBuffer(int, int, IPixelBuffer)

Write a buffer to the display off-screen buffer

Declaration
public void WriteBuffer(int x, int y, IPixelBuffer buffer)

Parameters

Type Name Description
int x

The x position in pixels to write the buffer

int y

The y position in pixels to write the buffer

IPixelBuffer buffer

The buffer to write