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
Declaration
public abstract class TftSpiBase : IPixelDisplay, IDisplay, ISpiPeripheral, IDisposable

Derived:

Expand

Implements:
Meadow.Peripherals.Displays.IPixelDisplay, Meadow.Peripherals.Displays.IDisplay, Meadow.Hardware.ISpiPeripheral, System.IDisposable

Properties

SetAddressBuffer

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

View Source
Declaration
protected byte[] SetAddressBuffer { get; }

ColorMode

The currently set color mode for the display

View Source
Declaration
public ColorMode ColorMode { get; }

SupportedColorModes

The Color mode supported by the display

View Source
Declaration
public abstract ColorMode SupportedColorModes { get; }

Rotation

The current rotation of the display

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

DefaultColorMode

The display default color mode

View Source
Declaration
public abstract ColorMode DefaultColorMode { get; }

Width

Width of the display in pixels

View Source
Declaration
public int Width { get; }

Height

Height of the display in pixels

View Source
Declaration
public int Height { get; }

PixelBuffer

Provide a buffer that matches this display's color depth, height, and width This should be the buffer that is sent to the device when Show is called

View Source
Declaration
public IPixelBuffer PixelBuffer { get; }

DefaultSpiBusSpeed

The default SPI bus speed for the device

View Source
Declaration
public virtual Frequency DefaultSpiBusSpeed { get; }

SpiBusSpeed

The SPI bus speed for the device

View Source
Declaration
public Frequency SpiBusSpeed { get; set; }

DefaultSpiBusMode

The default SPI bus mode for the device

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

SpiBusMode

The SPI bus mode for the device

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

IsDisposed

Is the object disposed

View Source
Declaration
public bool IsDisposed { get; }

Fields

dataCommandPort

The data command port

View Source
Declaration
protected IDigitalOutputPort dataCommandPort

resetPort

The reset port

View Source
Declaration
protected IDigitalOutputPort? resetPort

chipSelectPort

The chip select port

View Source
Declaration
protected IDigitalOutputPort? chipSelectPort

spiDisplay

The spi peripheral for the display

View Source
Declaration
protected ISpiCommunications spiDisplay

imageBuffer

The off-screen image buffer

View Source
Declaration
protected IPixelBuffer imageBuffer

readBuffer

The read buffer

View Source
Declaration
protected Memory<byte> readBuffer

Data

Data convenience bool

View Source
Declaration
protected const bool Data = true

Command

Command convenience bool

View Source
Declaration
protected const bool Command = false

nativeHeight

The display's native height without rotation

View Source
Declaration
protected int nativeHeight

nativeWidth

The display's native width without rotation

View Source
Declaration
protected int nativeWidth

setAddressLastX0

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

View Source
Declaration
protected int setAddressLastX0

setAddressLastX1

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

View Source
Declaration
protected int setAddressLastX1

setAddressLastY0

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

View Source
Declaration
protected int setAddressLastY0

setAddressLastY1

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

View Source
Declaration
protected int setAddressLastY1

Methods

Initialize()

Initialize the display

View Source
Declaration
protected abstract void Initialize()

SetColorMode(ColorMode)

Set color mode for the display

View Source
Declaration
public virtual void SetColorMode(ColorMode colorMode)
Parameters
TypeName
Meadow.Peripherals.Displays.ColorModecolorMode
Exceptions

System.ArgumentException
throw if the color mode isn't supported by the display

IsColorTypeSupported(ColorMode)

Is the color mode supported on this display

View Source
Declaration
public virtual bool IsColorTypeSupported(ColorMode colorType)
Returns

System.Boolean: true if supported

Parameters
TypeNameDescription
Meadow.Peripherals.Displays.ColorModecolorTypeThe color mode

CreateBuffer(ColorMode, int, int)

Create an off-screen buffer for the display

View Source
Declaration
protected void CreateBuffer(ColorMode colorMode, int width, int height)
Parameters
TypeNameDescription
Meadow.Peripherals.Displays.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
Declaration
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
Declaration
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
Declaration
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
Declaration
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.Peripherals.Displays.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
Declaration
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
Declaration
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
Declaration
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
Declaration
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
Declaration
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
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

View Source
Declaration
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
Declaration
protected void Write(byte value)
Parameters
TypeNameDescription
System.BytevalueThe byte to send

Write(byte[])

Write a buffer to the display

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

DelayMs(int)

Delay

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

SendCommand(Register)

Send a command to the display

View Source
Declaration
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
Declaration
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
Declaration
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
Declaration
protected void SendData(int data)
Parameters
TypeNameDescription
System.Int32dataThe data to send

SendData(byte)

Send a single byte to the display

View Source
Declaration
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
Declaration
protected void SendData(byte[] data)
Parameters
TypeNameDescription
System.Byte[]dataThe data

Clear(Color)

Clear the display buffer to a color

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

UpdateBuffer()

Update the display buffer if the dimensions change on rotation

View Source
Declaration
protected void UpdateBuffer()

Dispose()

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

View Source
Declaration
public void Dispose()

Dispose(bool)

Dispose of the object

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

Implements

  • Meadow.Peripherals.Displays.IPixelDisplay
  • Meadow.Peripherals.Displays.IDisplay
  • Meadow.Hardware.ISpiPeripheral
  • System.IDisposable