Class Apa102
Represents APA102/Dotstar Led(s)
Assembly: Apa102.dll
View Source
public class Apa102 : IApa102, ISpiPeripheral, IDisposable, IGraphicsDisplay, IPixelBuffer
Implements:
Meadow.Foundation.Leds.IApa102, Meadow.Hardware.ISpiPeripheral, System.IDisposable, Meadow.Foundation.Graphics.IGraphicsDisplay, Meadow.Foundation.Graphics.Buffers.IPixelBuffer
Properties
DefaultSpiBusSpeed
The default SPI bus speed for the device
View Source
public 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 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; }
NumberOfLeds
Total number of leds
View Source
public int NumberOfLeds { get; }
Brightness
Brightness used for LEDs Default is 0.5
View Source
public float Brightness { get; set; }
ColorMode
Color mode of leds - 24bpp
View Source
public ColorMode ColorMode { get; }
SupportedColorModes
The Color mode supported by the display
View Source
public ColorMode SupportedColorModes { get; }
Width
Width of pixel array
View Source
public int Width { get; }
Height
Height of pixel array
View Source
public int Height { get; }
PixelBuffer
PixelBuffer representation of the Apa102
View Source
public IPixelBuffer PixelBuffer { get; }
BitDepth
The color bit depth of the display
View Source
public int BitDepth { get; }
ByteCount
The size of the display buffer in bytes
View Source
public int ByteCount { get; }
Buffer
The display buffer - not implemented for the Apa102 driver
View Source
public byte[] Buffer { get; }
Fields
spiComms
SPI Communication bus used to communicate with the peripheral
View Source
protected ISpiCommunications spiComms
Methods
SetLed(int, Color)
Set the color of the specified LED using the global brightness value
View Source
public virtual void SetLed(int index, Color color)
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | index | Index of the LED to change |
Meadow.Color | color | The color |
SetLed(int, Color, float)
Set the color of the specified LED
View Source
public virtual void SetLed(int index, Color color, float brightness = 1)
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | index | Index of the LED to change |
Meadow.Color | color | The color |
System.Single | brightness | The brightness 0.0 - 1.0f |
SetLed(int, byte[])
Set the color of the specified LED
View Source
public virtual void SetLed(int index, byte[] rgb)
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | index | Index of the LED to change |
System.Byte[] | rgb | Byte array representing the color RGB values. byte[0] = Red, byte[1] = Green, byte[2] = Blue |
SetLed(int, byte[], float)
Set the color of the specified LED
View Source
public virtual void SetLed(int index, byte[] rgb, float brightness = 1)
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | index | Index of the LED to change |
System.Byte[] | rgb | Byte array representing the color RGB values. byte[0] = Red, byte[1] = Green, byte[2] = Blue |
System.Single | brightness | The brightness 0.0 - 1.0f |
Clear()
Clear the display buffer
View Source
public void Clear()
Clear(bool)
Clear the display buffer
View Source
public void Clear(bool update = false)
Parameters
| Type | Name | Description |
|---|---|---|
System.Boolean | update | Update the leds if true |
Show()
Transmit the buffer to the LEDs
View Source
public void Show()
Show(int, int, int, int)
Update APA102 with data in display buffer
View Source
public void Show(int left, int top, int right, int bottom)
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | left | left |
System.Int32 | top | top |
System.Int32 | right | right |
System.Int32 | bottom | bottom |
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 |
DrawPixel(int, int, Color)
Draw pixel at location
View Source
public void DrawPixel(int x, int y, Color color)
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | x | x position of pixel |
System.Int32 | y | y position of pixel |
Meadow.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
View Source
public void DrawPixel(int x, int y, bool enabled)
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | x | x position of pixel |
System.Int32 | y | y position of pixel |
System.Boolean | enabled | if true draw white, if false draw black |
InvertPixel(int, int)
Invert pixel at location
View Source
public void InvertPixel(int x, int y)
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | x | x position of pixel |
System.Int32 | y | y position of pixel |
Fill(Color, bool)
Fill the entire display buffer with a color
View Source
public void Fill(Color clearColor, bool updateDisplay = false)
Parameters
| Type | Name | Description |
|---|---|---|
Meadow.Color | clearColor | color to fill |
System.Boolean | updateDisplay | update after fill |
Fill(int, int, int, int, Color)
Fill a color in the specified region
View Source
public void Fill(int x, int y, int width, int height, Color fillColor)
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | x | x position |
System.Int32 | y | y position |
System.Int32 | width | width to fill |
System.Int32 | height | height to fill |
Meadow.Color | fillColor | color to fill |
WriteBuffer(int, int, IPixelBuffer)
Draw a buffer at the specified location
View Source
public void WriteBuffer(int x, int y, IPixelBuffer displayBuffer)
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | x | x position |
System.Int32 | y | y position |
| Meadow.Foundation.Graphics.Buffers.IPixelBuffer | displayBuffer | buffer to draw |
Fill(Color)
Fill the display buffer with a color
View Source
public void Fill(Color color)
Parameters
| Type | Name | Description |
|---|---|---|
Meadow.Color | color | The fill color |
GetPixel(int, int)
Get the color of a pixel for a given coordinate
View Source
public Color GetPixel(int x, int y)
Returns
Meadow.Color
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | x | X position in pixels |
System.Int32 | y | Y position in pixels |
SetPixel(int, int, Color)
Set the color of a pixel for a given coordinate
View Source
public void SetPixel(int x, int y, Color color)
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | x | X position in pixels |
System.Int32 | y | Y position in pixels |
Meadow.Color | color | Color of pixel |
Implements
- Meadow.Foundation.Leds.IApa102
Meadow.Hardware.ISpiPeripheralSystem.IDisposable- Meadow.Foundation.Graphics.IGraphicsDisplay
- Meadow.Foundation.Graphics.Buffers.IPixelBuffer