Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
Characteristic | Locus |
---|---|
Inheritance | object > Apa102 |
Implements | IApa102 ISpiPeripheral 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, 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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
Fields
spiComms
SPI Communication bus used to communicate with the peripheral
Declaration
protected ISpiCommunications spiComms
Field Value
Type | Description |
---|---|
ISpiCommunications |
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
Properties
BitDepth
The color bit depth of the display
Declaration
public int BitDepth { get; }
Property Value
Type | Description |
---|---|
int |
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
Brightness
Brightness used for LEDs Default is 0.5
Declaration
public float Brightness { get; set; }
Property Value
Type | Description |
---|---|
float |
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
Buffer
The display buffer - not implemented for the Apa102 driver
Declaration
public byte[] Buffer { get; }
Property Value
Type | Description |
---|---|
byte[] |
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
ByteCount
The size of the display buffer in bytes
Declaration
public int ByteCount { get; }
Property Value
Type | Description |
---|---|
int |
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
ColorMode
Color mode of leds - 24bpp
Declaration
public ColorMode ColorMode { get; }
Property Value
Type | Description |
---|---|
ColorMode |
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
DefaultSpiBusMode
The default SPI bus mode for the device
Declaration
public SpiClockConfiguration.Mode DefaultSpiBusMode { get; }
Property Value
Type | Description |
---|---|
SpiClockConfiguration.Mode |
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
DefaultSpiBusSpeed
The default SPI bus speed for the device
Declaration
public Frequency DefaultSpiBusSpeed { get; }
Property Value
Type | Description |
---|---|
Frequency |
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
Height
Height of pixel array
Declaration
public int Height { get; }
Property Value
Type | Description |
---|---|
int |
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
NumberOfLeds
Total number of leds
Declaration
public int NumberOfLeds { get; }
Property Value
Type | Description |
---|---|
int |
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
PixelBuffer
PixelBuffer representation of the Apa102
Declaration
public IPixelBuffer PixelBuffer { get; }
Property Value
Type | Description |
---|---|
IPixelBuffer |
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
SpiBusMode
The SPI bus mode for the device
Declaration
public SpiClockConfiguration.Mode SpiBusMode { get; set; }
Property Value
Type | Description |
---|---|
SpiClockConfiguration.Mode |
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
SpiBusSpeed
The SPI bus speed for the device
Declaration
public Frequency SpiBusSpeed { get; set; }
Property Value
Type | Description |
---|---|
Frequency |
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
SupportedColorModes
The Color mode supported by the display
Declaration
public ColorMode SupportedColorModes { get; }
Property Value
Type | Description |
---|---|
ColorMode |
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
Width
Width of pixel array
Declaration
public int Width { get; }
Property Value
Type | Description |
---|---|
int |
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
Methods
Clear()
Clear the display buffer
Declaration
public void Clear()
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
GetPixel(int, int)
Get the color of pixel at at 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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
SetLed(int, Color)
Set the color of the specified LED using the global brightness balue
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
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 brighrness 0.0 - 1.0f |
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
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 brighrness 0.0 - 1.0f |
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
SetPixel(int, int, Color)
Set the pixel for a given coordindate
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
Show()
Transmit the buffer to the LEDs
Declaration
public void Show()
Remarks
Apa102 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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:
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Apa102 apa102;
int numberOfLeds = 256;
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: