Skip to main content

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
TypeNameDescription
System.Int32indexIndex of the LED to change
Meadow.ColorcolorThe 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
TypeNameDescription
System.Int32indexIndex of the LED to change
Meadow.ColorcolorThe color
System.SinglebrightnessThe 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
TypeNameDescription
System.Int32indexIndex of the LED to change
System.Byte[]rgbByte 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
TypeNameDescription
System.Int32indexIndex of the LED to change
System.Byte[]rgbByte array representing the color RGB values. byte[0] = Red, byte[1] = Green, byte[2] = Blue
System.SinglebrightnessThe 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
TypeNameDescription
System.BooleanupdateUpdate 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
TypeNameDescription
System.Int32leftleft
System.Int32toptop
System.Int32rightright
System.Int32bottombottom

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

DrawPixel(int, int, Color)

Draw pixel at location

View Source
public void DrawPixel(int x, int y, Color color)
Parameters
TypeNameDescription
System.Int32xx position of pixel
System.Int32yy position of pixel
Meadow.Colorcolorcolor 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
TypeNameDescription
System.Int32xx position of pixel
System.Int32yy position of pixel
System.Booleanenabledif true draw white, if false draw black

InvertPixel(int, int)

Invert pixel at location

View Source
public void InvertPixel(int x, int y)
Parameters
TypeNameDescription
System.Int32xx position of pixel
System.Int32yy 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
TypeNameDescription
Meadow.ColorclearColorcolor to fill
System.BooleanupdateDisplayupdate 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
TypeNameDescription
System.Int32xx position
System.Int32yy position
System.Int32widthwidth to fill
System.Int32heightheight to fill
Meadow.ColorfillColorcolor 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
TypeNameDescription
System.Int32xx position
System.Int32yy position
Meadow.Foundation.Graphics.Buffers.IPixelBufferdisplayBufferbuffer to draw

Fill(Color)

Fill the display buffer with a color

View Source
public void Fill(Color color)
Parameters
TypeNameDescription
Meadow.ColorcolorThe 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
TypeNameDescription
System.Int32xX position in pixels
System.Int32yY 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
TypeNameDescription
System.Int32xX position in pixels
System.Int32yY position in pixels
Meadow.ColorcolorColor of pixel

Implements