Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Characteristic Locus
Inheritance object > Apa102
Implements IApa102 ISpiPeripheral IDisposable IGraphicsDisplay IPixelBuffer
Inherited Members object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow.Foundation.Leds
Assembly Apa102.dll

Syntax

public class Apa102 : IApa102, ISpiPeripheral, IDisposable, IGraphicsDisplay, IPixelBuffer

Constructors

Apa102(ISpiBus, IPin?, int, PixelOrder)

Creates a new APA102 object

Declaration
public Apa102(ISpiBus spiBus, IPin? chipSelectPin, int numberOfLeds, Apa102.PixelOrder pixelOrder = PixelOrder.BGR)

Parameters

Type Name Description
ISpiBus spiBus

SPI bus

IPin chipSelectPin

Chip select pin

int numberOfLeds

Number of leds

Apa102.PixelOrder pixelOrder

Pixel color order

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Apa102(ISpiBus, IPin, int, int, PixelOrder)

Creates a new APA102 object

Declaration
public Apa102(ISpiBus spiBus, IPin chipSelectPin, int width, int height, Apa102.PixelOrder pixelOrder = PixelOrder.BGR)

Parameters

Type Name Description
ISpiBus spiBus

SPI bus

IPin chipSelectPin

Chip select pin

int width

Width of led array

int height

Height of led array

Apa102.PixelOrder pixelOrder

Pixel color order

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Apa102(ISpiBus, int, PixelOrder, IDigitalOutputPort?)

Creates a new APA102 object

Declaration
public Apa102(ISpiBus spiBus, int numberOfLeds, Apa102.PixelOrder pixelOrder = PixelOrder.BGR, IDigitalOutputPort? chipSelectPort = null)

Parameters

Type Name Description
ISpiBus spiBus

SPI bus

int numberOfLeds

Number of leds

Apa102.PixelOrder pixelOrder

Pixel color order

IDigitalOutputPort chipSelectPort

SPI chip select port (optional)

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Apa102(ISpiBus, int, int, PixelOrder, IDigitalOutputPort?)

Creates a new APA102 object

Declaration
public Apa102(ISpiBus spiBus, int width, int height, Apa102.PixelOrder pixelOrder = PixelOrder.BGR, IDigitalOutputPort? chipSelectPort = null)

Parameters

Type Name Description
ISpiBus spiBus

SPI bus

int width

Width of led array

int height

Height of led array

Apa102.PixelOrder pixelOrder

Pixel color order

IDigitalOutputPort chipSelectPort

SPI chip select port (optional)

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Fields

spiComms

SPI Communication bus used to communicate with the peripheral

Declaration
protected ISpiCommunications spiComms

Field Value

Type Description
ISpiCommunications

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Properties

BitDepth

The color bit depth of the display

Declaration
public int BitDepth { get; }

Property Value

Type Description
int

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Brightness

Brightness used for LEDs Default is 0.5

Declaration
public float Brightness { get; set; }

Property Value

Type Description
float

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Buffer

The display buffer - not implemented for the Apa102 driver

Declaration
public byte[] Buffer { get; }

Property Value

Type Description
byte[]

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

ByteCount

The size of the display buffer in bytes

Declaration
public int ByteCount { get; }

Property Value

Type Description
int

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

ColorMode

Color mode of leds - 24bpp

Declaration
public ColorMode ColorMode { get; }

Property Value

Type Description
ColorMode

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

DefaultSpiBusMode

The default SPI bus mode for the device

Declaration
public SpiClockConfiguration.Mode DefaultSpiBusMode { get; }

Property Value

Type Description
SpiClockConfiguration.Mode

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

DefaultSpiBusSpeed

The default SPI bus speed for the device

Declaration
public Frequency DefaultSpiBusSpeed { get; }

Property Value

Type Description
Frequency

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Height

Height of pixel array

Declaration
public int Height { get; }

Property Value

Type Description
int

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

IsDisposed

Is the object disposed

Declaration
public bool IsDisposed { get; }

Property Value

Type Description
bool

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

NumberOfLeds

Total number of leds

Declaration
public int NumberOfLeds { get; }

Property Value

Type Description
int

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

PixelBuffer

PixelBuffer representation of the Apa102

Declaration
public IPixelBuffer PixelBuffer { get; }

Property Value

Type Description
IPixelBuffer

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

SpiBusMode

The SPI bus mode for the device

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

Property Value

Type Description
SpiClockConfiguration.Mode

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

SpiBusSpeed

The SPI bus speed for the device

Declaration
public Frequency SpiBusSpeed { get; set; }

Property Value

Type Description
Frequency

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

SupportedColorModes

The Color mode supported by the display

Declaration
public ColorMode SupportedColorModes { get; }

Property Value

Type Description
ColorMode

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Width

Width of pixel array

Declaration
public int Width { get; }

Property Value

Type Description
int

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Methods

Clear()

Clear the display buffer

Declaration
public void Clear()

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Clear(bool)

Clear the display buffer

Declaration
public void Clear(bool update = false)

Parameters

Type Name Description
bool update

Update the leds if true

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Dispose()

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

Declaration
public void Dispose()

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Dispose(bool)

Dispose of the object

Declaration
protected virtual void Dispose(bool disposing)

Parameters

Type Name Description
bool disposing

Is disposing

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

DrawPixel(int, int, Color)

Draw pixel at location

Declaration
public void DrawPixel(int x, int y, Color color)

Parameters

Type Name Description
int x

x position of pixel

int y

y position of pixel

Color color

color of pixel

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

DrawPixel(int, int, bool)

Draw pixel at a location Primarily used for monochrome displays, prefer overload that accepts a Color

Declaration
public void DrawPixel(int x, int y, bool enabled)

Parameters

Type Name Description
int x

x position of pixel

int y

y position of pixel

bool enabled

if true draw white, if false draw black

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Fill(Color)

Fill the display buffer with a color

Declaration
public void Fill(Color color)

Parameters

Type Name Description
Color color

The fill color

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Fill(Color, bool)

Fill the entire display buffer with a color

Declaration
public void Fill(Color clearColor, bool updateDisplay = false)

Parameters

Type Name Description
Color clearColor

color to fill

bool updateDisplay

update after fill

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Fill(int, int, int, int, Color)

Fill a color in the specified region

Declaration
public void Fill(int x, int y, int width, int height, Color fillColor)

Parameters

Type Name Description
int x

x position

int y

y position

int width

width to fill

int height

height to fill

Color fillColor

color to fill

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

GetPixel(int, int)

Get the color of a pixel for a given coordinate

Declaration
public Color GetPixel(int x, int y)

Parameters

Type Name Description
int x

X position in pixels

int y

Y position in pixels

Returns

Type Description
Color

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

InvertPixel(int, int)

Invert pixel at location

Declaration
public void InvertPixel(int x, int y)

Parameters

Type Name Description
int x

x position of pixel

int y

y position of pixel

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

SetLed(int, Color)

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

Declaration
public virtual void SetLed(int index, Color color)

Parameters

Type Name Description
int index

Index of the LED to change

Color color

The color

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

SetLed(int, Color, float)

Set the color of the specified LED

Declaration
public virtual void SetLed(int index, Color color, float brightness = 1)

Parameters

Type Name Description
int index

Index of the LED to change

Color color

The color

float brightness

The brightness 0.0 - 1.0f

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

SetLed(int, byte[])

Set the color of the specified LED

Declaration
public virtual void SetLed(int index, byte[] rgb)

Parameters

Type Name Description
int index

Index of the LED to change

byte[] rgb

Byte array representing the color RGB values. byte[0] = Red, byte[1] = Green, byte[2] = Blue

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

SetLed(int, byte[], float)

Set the color of the specified LED

Declaration
public virtual void SetLed(int index, byte[] rgb, float brightness = 1)

Parameters

Type Name Description
int index

Index of the LED to change

byte[] rgb

Byte array representing the color RGB values. byte[0] = Red, byte[1] = Green, byte[2] = Blue

float brightness

The brightness 0.0 - 1.0f

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

SetPixel(int, int, Color)

Set the color of a pixel for a given coordinate

Declaration
public void SetPixel(int x, int y, Color color)

Parameters

Type Name Description
int x

X position in pixels

int y

Y position in pixels

Color color

Color of pixel

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Show()

Transmit the buffer to the LEDs

Declaration
public void Show()

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

Show(int, int, int, int)

Update APA102 with data in display buffer

Declaration
public void Show(int left, int top, int right, int bottom)

Parameters

Type Name Description
int left

left

int top

top

int right

right

int bottom

bottom

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7

WriteBuffer(int, int, IPixelBuffer)

Draw a buffer at the specified location

Declaration
public void WriteBuffer(int x, int y, IPixelBuffer displayBuffer)

Parameters

Type Name Description
int x

x position

int y

y position

IPixelBuffer displayBuffer

buffer to draw

Remarks

Apa102
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Leds.Apa102

Code Example

Apa102 apa102;
readonly int numberOfLeds = 256;
readonly float maxBrightness = 0.25f;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");
    apa102 = new Apa102(Device.CreateSpiBus(), numberOfLeds, Apa102.PixelOrder.BGR);

    return base.Initialize();
}

public override Task Run()
{
    apa102.Clear();

    apa102.SetLed(index: 0, color: Color.Red, brightness: 0.5f);
    apa102.SetLed(index: 1, color: Color.Purple, brightness: 0.6f);
    apa102.SetLed(index: 2, color: Color.Blue, brightness: 0.7f);
    apa102.SetLed(index: 3, color: Color.Green, brightness: 0.8f);
    apa102.SetLed(index: 4, color: Color.Yellow, brightness: 0.9f);
    apa102.SetLed(index: 5, color: Color.Orange, brightness: 1.0f);

    apa102.Show();

    Apa102Tests();

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Apa102 to your Meadow board, connect the following:

Apa102 Meadow Pin
GND GND
CI SCK
DI MOSI
VCC 5V

It should look like the following diagram:

Wiring an Apa102 to a Meadow F7