The DotStar Class is designed to work with Adafruit DotStar addressible digital RGB LEDs This page documents the public API of the DotStar Class.

Part of a coiled LED strip glowing purple LEDs.
Move over NeoPixels, there's a new LED strip in town! These fancy new DotStar LED strips are a great upgrade for people who have loved and used NeoPixel strips for a few years but...
$119.80
In Stock

Constructors

The DotStar class uses SPI to communicate wit the dotstars. The class has two constructors, one for Hardware SPI mode, and one for Software SPI modeHardware SPI uses the built-in SPI support of the Raspberry Pi, and so must operate from the SCLK and MOSI GPIO pins.

Software SPI mode can operate on any two GPIO pins, but is much slower than hardware SPI mode.

The hardware SPI constructore takes two arguments: the number of pixels and the color order of the pixels.  Color order determines the sequence of RGB color values within the data streem to the Dot Stars. The color order argument is optional, and defaults to Blue,Red,Green.

public DotStar(uint numPixels, UInt32 colorOrder = DOTSTAR_BRG)

The software SPI constructor takes four arguments: The number of pixels, the GPIO number of the data pin, athe GPIO number of the clock pin, and the color order.  Again, the color order argument is optional and defaults to Blue,Red,Green.

public DotStar(uint numPixels, int dataPin, int clockPin, UInt32 colorOrder = DOTSTAR_BRG)

Methods

BeginAsync

The Begin method is an asynchronous method which initializes the SPI interface. It takes no arguments.  Call Begin before attempting to write to the DotStars.

public async Task BeginAsync()

End

The End method shuts down the SPI interface. It takes no arguments.

public void End()

SetPixelColor

The SetPixelColor method assigns an RGB color to a specific pixel.

There are two overloads of SetPixelColor. The first takes an integer pixel number, and individual R, G, and B values as arguments, where R, G, and B are unsigned byte values in the range 0..255.

The second overload takes a pixel number and a 32-bit unsigned integer containing packed R, G, and B values..  Use the Color method to generate a packed value from individual R, G, B values.

Note that SetPixelColor does not update the displayed colors. It only set internal program storage. You must call the Show method to display the updated colors.

public void SetPixelColor(int pixel, byte r, byte g, byte b)
public void SetPixelColor(int pixel, UInt32 c)

GetPixelColor

The GetPixelColor method returns a 32-bit unsigned integer containing the packed R, G, B values for an indiviual pixel. It takes a single integer argument, which is the pixel number.

public UInt32 GetPixelColor(int pixel)

Clear

The Clear method turns off all pixels Ii.e., sets the color values to 0). It takes no arguments.

public void Clear()

Color

The color method converts individual R, G, Bvalues to a packed 32-bit unsigned integer. It takes integer R, G, B values as arguemnts.  R,G, B values must be in the range 0..255.

public UInt32 Color(uint r, uint g, uint b)

UpdateLength

The UpdateLength method changes the number of pixels in the DotStar strip. It takes a single integer argument; the number of pixels in the strip.

As a side-effect, all previous pixel values are lost.

public void UpdateLength(uint numPixels)

Show

the Show method draws all stroed pixel values to the strip.  The SetPixelColor methods only update internal program storage - they do not display the updated colors.  You must call Show to display the updated colors.

Show takes no arguments.

public void Show()

This guide was first published on Nov 22, 2016. It was last updated on Dec 04, 2016.

This page (DotStar Class) was last updated on Sep 13, 2016.

Text editor powered by tinymce.