Skip to main content

Class TftSpiBase

Base class for TFT SPI displays These displays typically support 16 and 18 bit, some also include 8, 9, 12 and/or 24 bit color

Assembly: TftSpi.dll
View Source
public abstract class TftSpiBase : IGraphicsDisplay, ISpiPeripheral, IDisposable

Derived:

Expand

Meadow.Foundation.Displays.Gc9a01, Meadow.Foundation.Displays.Hx8357d, Meadow.Foundation.Displays.Ili9163, Meadow.Foundation.Displays.Ili9341, Meadow.Foundation.Displays.Ili9481, Meadow.Foundation.Displays.Ili9486, Meadow.Foundation.Displays.Ili9488, Meadow.Foundation.Displays.Rm68140, Meadow.Foundation.Displays.S6D02A1, Meadow.Foundation.Displays.Ssd1331, Meadow.Foundation.Displays.Ssd1351, Meadow.Foundation.Displays.St7735, Meadow.Foundation.Displays.St7789, Meadow.Foundation.Displays.St7796s

Implements:
Meadow.Foundation.Graphics.IGraphicsDisplay, Meadow.Hardware.ISpiPeripheral, System.IDisposable

Properties

SetAddressBuffer

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

View Source
protected byte[] SetAddressBuffer { get; }

ColorMode

The current display color mode

View Source
public ColorMode ColorMode { get; }

SupportedColorModes

The color modes supported by the display

View Source
public abstract ColorMode SupportedColorModes { get; }

Rotation

The current rotation of the display

View Source
public RotationType Rotation { get; protected set; }

DefaultColorMode

The display default color mode

View Source
public abstract ColorMode DefaultColorMode { get; }

Width

Width of display in pixels

View Source
public int Width { get; }

Height

Height of display in pixels

View Source
public int Height { get; }

PixelBuffer

The buffer used to store the pixel data for the display

View Source
public IPixelBuffer PixelBuffer { get; }

DefaultSpiBusSpeed

The default SPI bus speed for the device

View Source
public virtual Frequency DefaultSpiBusSpeed { get; }

SpiBusSpeed

The SPI bus speed for the device

View Source
public Frequency SpiBusSpeed { get; set; }

DefaultSpiBusMode

The default SPI bus mode for the device

View Source
public virtual SpiClockConfiguration.Mode DefaultSpiBusMode { get; }

SpiBusMode

The SPI bus mode for the device

View Source
public SpiClockConfiguration.Mode SpiBusMode { get; set; }

IsDisposed

Is the object disposed

View Source
public bool IsDisposed { get; }

Fields

dataCommandPort

The data command port

View Source
protected IDigitalOutputPort dataCommandPort

resetPort

The reset port

View Source
protected IDigitalOutputPort? resetPort

chipSelectPort

The chip select port

View Source
protected IDigitalOutputPort? chipSelectPort

spiDisplay

The spi peripheral for the display

View Source
protected ISpiCommunications spiDisplay

imageBuffer

The off-screen image buffer

View Source
protected IPixelBuffer imageBuffer

readBuffer

The read buffer

View Source
protected Memory<byte> readBuffer

Data

Data convenience bool

View Source
protected const bool Data = true

Command

Command convenience bool

View Source
protected const bool Command = false

nativeHeight

The display's native height without rotation

View Source
protected int nativeHeight

nativeWidth

The display's native width without rotation

View Source
protected int nativeWidth

setAddressLastX0

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

View Source
protected int setAddressLastX0

setAddressLastX1

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

View Source
protected int setAddressLastX1

setAddressLastY0

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

View Source
protected int setAddressLastY0

setAddressLastY1

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

View Source
protected int setAddressLastY1

Methods

Initialize()

Initialize the display

View Source
protected abstract void Initialize()

IsColorTypeSupported(ColorMode)

Is the color mode supported on this display

View Source
public virtual bool IsColorTypeSupported(ColorMode colorType)
Returns

System.Boolean: true if supported

Parameters
TypeNameDescription
Meadow.Foundation.Graphics.ColorModecolorTypeThe color mode

CreateBuffer(ColorMode, int, int)

Create an off-screen buffer for the display

View Source
protected void CreateBuffer(ColorMode colorMode, int width, int height)
Parameters
TypeNameDescription
Meadow.Foundation.Graphics.ColorModecolorModeThe color mode
System.Int32widthThe width in pixels
System.Int32heightThe height in pixels
Exceptions

System.ArgumentException
Throws an exception if the color mode isn't supported

SetAddressWindow(int, int, int, int)

Set address window for display updates

View Source
protected virtual void SetAddressWindow(int x0, int y0, int x1, int y1)
Parameters
TypeNameDescription
System.Int32x0X start in pixels
System.Int32y0Y start in pixels
System.Int32x1X end in pixels
System.Int32y1Y end in pixels

Clear(bool)

Clear the display.

View Source
public void Clear(bool updateDisplay = false)
Parameters
TypeNameDescription
System.BooleanupdateDisplayUpdate the display once the buffer has been cleared when true.

Fill(Color, bool)

Fill the display buffer with a color

View Source
public void Fill(Color color, bool updateDisplay = false)
Parameters
TypeNameDescription
Meadow.ColorcolorThe fill color
System.BooleanupdateDisplayIf true, update the display after filling the buffer

WriteBuffer(int, int, IPixelBuffer)

Write a buffer to the display off-screen buffer

View Source
public void WriteBuffer(int x, int y, IPixelBuffer buffer)
Parameters
TypeNameDescription
System.Int32xThe x position in pixels to write the buffer
System.Int32yThe y position in pixels to write the buffer
Meadow.Foundation.Graphics.Buffers.IPixelBufferbufferThe buffer to write

DrawPixel(int, int, bool)

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

View Source
public void DrawPixel(int x, int y, bool enabled)
Parameters
TypeNameDescription
System.Int32xx location in pixels
System.Int32yy location in pixels
System.BooleanenabledTurn the pixel on (true) or off (false).

DrawPixel(int, int, Color)

Draw a single pixel

View Source
public void DrawPixel(int x, int y, Color color)
Parameters
TypeNameDescription
System.Int32xx location in pixels
System.Int32yy location in pixels
Meadow.ColorcolorColor of pixel.

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

Draw a single pixel

View Source
public void DrawPixel(int x, int y, byte r, byte g, byte b)
Parameters
TypeNameDescription
System.Int32xx location in pixels
System.Int32yy location in pixels
System.Byter8 bit red value
System.Byteg8 bit green value
System.Byteb8 bit blue value

InvertPixel(int, int)

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

View Source
public void InvertPixel(int x, int y)
Parameters
TypeNameDescription
System.Int32xx location in pixels
System.Int32yy location in pixels

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

Fill with a color

View Source
public void Fill(int x, int y, int width, int height, Color color)
Parameters
TypeNameDescription
System.Int32xX start position in pixels
System.Int32yY start position in pixels
System.Int32widthWidth in pixels
System.Int32heightHeight in pixels
Meadow.ColorcolorThe fill color

Show()

Draw the display buffer to screen

View Source
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

View Source
public void Show(int left, int top, int right, int bottom)
Parameters
TypeName
System.Int32left
System.Int32top
System.Int32right
System.Int32bottom

Write(byte)

Write a byte to the display

View Source
protected void Write(byte value)
Parameters
TypeNameDescription
System.BytevalueThe byte to send

Write(byte[])

Write a buffer to the display

View Source
protected void Write(byte[] data)
Parameters
TypeNameDescription
System.Byte[]dataThe data to send

DelayMs(int)

Delay

View Source
protected void DelayMs(int millseconds)
Parameters
TypeNameDescription
System.Int32millsecondsMilliseconds to delay

SendCommand(Register)

Send a command to the display

View Source
protected void SendCommand(TftSpiBase.Register command)
Parameters
TypeNameDescription
Meadow.Foundation.Displays.TftSpiBase.RegistercommandThe command to send

SendCommand(LcdCommand)

Send a command to the display

View Source
protected void SendCommand(TftSpiBase.LcdCommand command)
Parameters
TypeNameDescription
Meadow.Foundation.Displays.TftSpiBase.LcdCommandcommandThe command to send as an LcdCommand

SendCommand(byte)

Send a command to the display

View Source
protected void SendCommand(byte command)
Parameters
TypeNameDescription
System.BytecommandThe command to send as a byte

SendData(int)

Send a single byte to the display (convenience method)

View Source
protected void SendData(int data)
Parameters
TypeNameDescription
System.Int32dataThe data to send

SendData(byte)

Send a single byte to the display

View Source
protected void SendData(byte data)
Parameters
TypeNameDescription
System.BytedataThe byte to send

SendData(byte[])

Send a byte array of data to the display

View Source
protected void SendData(byte[] data)
Parameters
TypeNameDescription
System.Byte[]dataThe data

Clear(Color)

Clear the display buffer to a color

View Source
public void Clear(Color color)
Parameters
TypeNameDescription
Meadow.ColorcolorThe clear color

UpdateBuffer()

Update the display buffer if the dimensions change on rotation

View Source
protected void UpdateBuffer()

Dispose()

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

View Source
public void Dispose()

Dispose(bool)

Dispose of the object

View Source
protected virtual void Dispose(bool disposing)
Parameters
TypeNameDescription
System.BooleandisposingIs disposing

Implements