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 : IPixelDisplay, IDisplay, ISpiPeripheral, IDisposable
Derived:
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
protected byte[] SetAddressBuffer { get; }
ColorMode
The currently set color mode for the display
View Source
public ColorMode ColorMode { get; }
SupportedColorModes
The Color mode 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 the display in pixels
View Source
public int Width { get; }
Height
Height of the display in pixels
View Source
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
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()
SetColorMode(ColorMode)
Set color mode for the display
View Source
public virtual void SetColorMode(ColorMode colorMode)
Parameters
Type | Name |
---|---|
Meadow.Peripherals.Displays.ColorMode | colorMode |
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
public virtual bool IsColorTypeSupported(ColorMode colorType)
Returns
System.Boolean
: true if supported
Parameters
Type | Name | Description |
---|---|---|
Meadow.Peripherals.Displays.ColorMode | colorType | The 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
Type | Name | Description |
---|---|---|
Meadow.Peripherals.Displays.ColorMode | colorMode | The color mode |
System.Int32 | width | The width in pixels |
System.Int32 | height | The 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
Type | Name | Description |
---|---|---|
System.Int32 | x0 | X start in pixels |
System.Int32 | y0 | Y start in pixels |
System.Int32 | x1 | X end in pixels |
System.Int32 | y1 | Y end in pixels |
Clear(bool)
Clear the display.
View Source
public void Clear(bool updateDisplay = false)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | updateDisplay | Update 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
Type | Name | Description |
---|---|---|
Meadow.Color | color | The fill color |
System.Boolean | updateDisplay | If 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
Type | Name | Description |
---|---|---|
System.Int32 | x | The x position in pixels to write the buffer |
System.Int32 | y | The y position in pixels to write the buffer |
Meadow.Peripherals.Displays.IPixelBuffer | buffer | The 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
Type | Name | Description |
---|---|---|
System.Int32 | x | x location in pixels |
System.Int32 | y | y location in pixels |
System.Boolean | enabled | Turn 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
Type | Name | Description |
---|---|---|
System.Int32 | x | x location in pixels |
System.Int32 | y | y location in pixels |
Meadow.Color | color | Color 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
Type | Name | Description |
---|---|---|
System.Int32 | x | x location in pixels |
System.Int32 | y | y location in pixels |
System.Byte | r | 8 bit red value |
System.Byte | g | 8 bit green value |
System.Byte | b | 8 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
Type | Name | Description |
---|---|---|
System.Int32 | x | x location in pixels |
System.Int32 | y | y 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
Type | Name | Description |
---|---|---|
System.Int32 | x | X start position in pixels |
System.Int32 | y | Y start position in pixels |
System.Int32 | width | Width in pixels |
System.Int32 | height | Height in pixels |
Meadow.Color | color | The 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
View Source
public void Show(int left, int top, int right, int bottom)
Parameters
Type | Name |
---|---|
System.Int32 | left |
System.Int32 | top |
System.Int32 | right |
System.Int32 | bottom |
Write(byte)
Write a byte to the display
View Source
protected void Write(byte value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | value | The byte to send |
Write(byte[])
Write a buffer to the display
View Source
protected void Write(byte[] data)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | data | The data to send |
DelayMs(int)
Delay
View Source
protected void DelayMs(int millseconds)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | millseconds | Milliseconds to delay |
SendCommand(Register)
Send a command to the display
View Source
protected void SendCommand(TftSpiBase.Register command)
Parameters
Type | Name | Description |
---|---|---|
Meadow.Foundation.Displays.TftSpiBase.Register | command | The command to send |
SendCommand(LcdCommand)
Send a command to the display
View Source
protected void SendCommand(TftSpiBase.LcdCommand command)
Parameters
Type | Name | Description |
---|---|---|
Meadow.Foundation.Displays.TftSpiBase.LcdCommand | command | The command to send as an LcdCommand |
SendCommand(byte)
Send a command to the display
View Source
protected void SendCommand(byte command)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | command | The 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
Type | Name | Description |
---|---|---|
System.Int32 | data | The data to send |
SendData(byte)
Send a single byte to the display
View Source
protected void SendData(byte data)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | data | The byte to send |
SendData(byte[])
Send a byte array of data to the display
View Source
protected void SendData(byte[] data)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | data | The data |
Clear(Color)
Clear the display buffer to a color
View Source
public void Clear(Color color)
Parameters
Type | Name | Description |
---|---|---|
Meadow.Color | color | The 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
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Is disposing |
Implements
Meadow.Peripherals.Displays.IPixelDisplay
Meadow.Peripherals.Displays.IDisplay
Meadow.Hardware.ISpiPeripheral
System.IDisposable