nanoFramework.Iot.Device.Apa102 1.0.243

Install-Package nanoFramework.Iot.Device.Apa102 -Version 1.0.243
dotnet add package nanoFramework.Iot.Device.Apa102 --version 1.0.243
<PackageReference Include="nanoFramework.Iot.Device.Apa102" Version="1.0.243" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add nanoFramework.Iot.Device.Apa102 --version 1.0.243
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: nanoFramework.Iot.Device.Apa102, 1.0.243"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install nanoFramework.Iot.Device.Apa102 as a Cake Addin
#addin nuget:?package=nanoFramework.Iot.Device.Apa102&version=1.0.243

// Install nanoFramework.Iot.Device.Apa102 as a Cake Tool
#tool nuget:?package=nanoFramework.Iot.Device.Apa102&version=1.0.243
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

APA102 - Double line transmission integrated control LED

APA102 is a intelligent control LED light source that the control circuit and RGB chip are integrated in a package of 5050/2020 components. It internal include 3 groups shift register and Selfdetection sign decoder circuit.

It's different from WS2812. In addition to the data line, it has a clock line. So APA102 has no strict requirements for timing. It's more friendly to devices such as Raspberry Pi that can't precisely control the timing of data lines.

There are other models like APA107, HD107s, SK9822, etc. The controls are exactly the same.

Model SCLK PWM
APA102 20 MHz 20 kHz
APA107 30 MHz 9 kHz
HD107s 40 MHz 27 kHz
SK9822 15 MHz 4.7 kHz

Documentation

Usage

Important: make sure you properly setup the SPI pins especially for ESP32 before creating the SpiDevice, make sure you install the nanoFramework.Hardware.ESP32 nuget:

//////////////////////////////////////////////////////////////////////
// when connecting to an ESP32 device, need to configure the SPI GPIOs
// used for the bus
Configuration.SetPinFunction(21, DeviceFunction.SPI1_MOSI);
Configuration.SetPinFunction(22, DeviceFunction.SPI1_MISO);
Configuration.SetPinFunction(23, DeviceFunction.SPI1_CLOCK);
// Make sure as well you are using the right chip select

For other devices like STM32, please make sure you're using the pre-set pins for the SPI bus you want to use. The chip select can as well be pre setup.

Here is an example how to use the APA102:

using System;
using System.Device.Spi;
using System.Drawing;
using System.Threading;
using Iot.Device.Apa102;

var random = new Random();

using SpiDevice spiDevice = SpiDevice.Create(new SpiConnectionSettings(1, 42)
{
    ClockFrequency = 20_000_000,
    DataFlow = DataFlow.MsbFirst,
    Mode = SpiMode.Mode0 // ensure data is ready at clock rising edge
});
using Apa102 apa102 = new Apa102(spiDevice, 16);

while (true)
{
    for (var i = 0; i < apa102.Pixels.Length; i++)
    {
        apa102.Pixels[i] = Color.FromArgb(255, random.Next(256), random.Next(256), random.Next(256));
    }

    apa102.Flush();
    Thread.Sleep(1000);
}

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.243 1,450 11/23/2021
1.0.242 1,514 11/23/2021
1.0.221 37 10/19/2021
1.0.219 55 10/19/2021
1.0.218 81 10/18/2021
1.0.157 78 9/4/2021
1.0.155 74 8/31/2021
1.0.153 37 8/14/2021
1.0.151 52 8/6/2021
1.0.146 42 7/22/2021
1.0.136 113 7/17/2021
1.0.135 42 7/16/2021
1.0.134 54 7/15/2021
1.0.133 38 7/14/2021
1.0.129 48 7/6/2021
1.0.127 57 7/5/2021
1.0.125 80 7/5/2021
1.0.122 68 6/30/2021
1.0.121 59 6/29/2021
1.0.119 92 6/28/2021
1.0.111 61 6/14/2021
1.0.105 138 5/29/2021
1.0.104 118 5/29/2021
1.0.97 59 5/28/2021
1.0.63 58 5/26/2021
1.0.23 101 5/21/2021