Skip to main content

Class Apa102

Represents APA102/Dotstar Led(s)

Assembly: Apa102.dll
View Source
Declaration
public class Apa102 : IApa102, ISpiPeripheral, IDisposable, IPixelDisplay, IDisplay, IPixelBuffer

Implements:
Meadow.Foundation.Leds.IApa102, Meadow.Hardware.ISpiPeripheral, System.IDisposable, Meadow.Peripherals.Displays.IPixelDisplay, Meadow.Peripherals.Displays.IDisplay, Meadow.Peripherals.Displays.IPixelBuffer

Properties

DefaultSpiBusSpeed

The default SPI bus speed for the device

View Source
Declaration
public 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 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; }

NumberOfLeds

Total number of leds

View Source
Declaration
public int NumberOfLeds { get; }

Brightness

Brightness used for LEDs Default is 0.5

View Source
Declaration
public float Brightness { get; set; }

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 ColorMode SupportedColorModes { 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; }

BitDepth

The color bit depth of the display

View Source
Declaration
public int BitDepth { get; }

ByteCount

The size of the display buffer in bytes

View Source
Declaration
public int ByteCount { get; }

Buffer

The display buffer - not implemented for the Apa102 driver

View Source
Declaration
public byte[] Buffer { get; }

Fields

spiComms

SPI Communication bus used to communicate with the peripheral

View Source
Declaration
protected ISpiCommunications spiComms

Methods

SetLed(int, Color)

Set the color of the specified LED using the global brightness value

View Source
Declaration
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
Declaration
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
Declaration
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
Declaration
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
Declaration
public void Clear()

Clear(bool)

Clear the display buffer

View Source
Declaration
public void Clear(bool update = false)
Parameters
TypeNameDescription
System.BooleanupdateUpdate the leds if true

Show()

Transmit the buffer to the LEDs

View Source
Declaration
public void Show()

Show(int, int, int, int)

Update APA102 with data in display buffer

View Source
Declaration
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
Declaration
public void Dispose()

Dispose(bool)

Dispose of the object

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

DrawPixel(int, int, Color)

Draw pixel at location

View Source
Declaration
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
Declaration
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
Declaration
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
Declaration
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
Declaration
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
Declaration
public void WriteBuffer(int x, int y, IPixelBuffer displayBuffer)
Parameters
TypeNameDescription
System.Int32xx position
System.Int32yy position
Meadow.Peripherals.Displays.IPixelBufferdisplayBufferbuffer to draw

Fill(Color)

Fill the display buffer with a color

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

  • Meadow.Foundation.Leds.IApa102
  • Meadow.Hardware.ISpiPeripheral
  • System.IDisposable
  • Meadow.Peripherals.Displays.IPixelDisplay
  • Meadow.Peripherals.Displays.IDisplay
  • Meadow.Peripherals.Displays.IPixelBuffer