upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions
APA102 Class Reference

API for controlling APA102/DotStar RGB LED Strips. More...

Detailed Description

APA102 LED Strips provide individually controllable LEDs through a SPI interface. For each LED, brightness (0-31) and RGB (0-255) values can be set.

apa102.jpg
// Instantiate a strip of 30 LEDs on SPI bus 0
upm::APA102 ledStrip(800, 0);
// Set all LEDs to Red
ledStrip.setAllLeds(31, 255, 0, 0);
// Set a section (10 to 20) to blue
ledStrip.setLeds(10, 20, 31, 0, 0, 255);
// Set a single LED to green
ledStrip.setLed(15, 31, 0, 255, 0);

Public Member Functions

 APA102 (uint16_t ledCount, uint8_t spiBus, bool batchMode=false, int8_t csn=-1)
 
 ~APA102 ()
 
void setLed (uint16_t ledIdx, uint8_t brightness, uint8_t r, uint8_t g, uint8_t b)
 
void setLedBrightness (uint16_t ledIdx, uint8_t brightness)
 
void setAllLeds (uint8_t brightness, uint8_t r, uint8_t g, uint8_t b)
 
void setLeds (uint16_t startIdx, uint16_t endIdx, uint8_t brightness, uint8_t r, uint8_t g, uint8_t b)
 
void setLedsBrightness (uint16_t startIdx, uint16_t endIdx, uint8_t brightness)
 
void setLeds (uint16_t startIdx, uint16_t endIdx, uint8_t *colors)
 
void setBusSpeed (int hz)
 
void pushState ()
 

Constructor & Destructor Documentation

APA102 ( uint16_t  ledCount,
uint8_t  spiBus,
bool  batchMode = false,
int8_t  csn = -1 
)

Instantiates a new APA102 LED Strip

Parameters
ledCountNumber of APA102 leds in the strip
spiBusSPI Bus number
batchMode(optional) Immediately write to SPI (false, default) or wait for a pushState call (true)
csn(optional) Chip Select Pin
~APA102 ( )

APA102 destructor

Member Function Documentation

void setLed ( uint16_t  ledIdx,
uint8_t  brightness,
uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Change the color and brightness for a single led

Parameters
ledIdxIndex of the LED in the strip (0 based)
brightnessBrightness value (0-31)
rRed component (0-255)
gGreen component (0-255)
bBlue component (0-255)

Here is the call graph for this function:

void setLedBrightness ( uint16_t  ledIdx,
uint8_t  brightness 
)

Change the brightness for a single led

Parameters
ledIdxIndex of the LED in the strip (0 based)
brightnessBrightness value (0-31)

Here is the call graph for this function:

void setAllLeds ( uint8_t  brightness,
uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Change the color and brightness for all leds

Parameters
brightnessBrightness value (0-31)
rRed component (0-255)
gGreen component (0-255)
bBlue component (0-255)

Here is the call graph for this function:

void setLeds ( uint16_t  startIdx,
uint16_t  endIdx,
uint8_t  brightness,
uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Change the color and brightness for a range of leds

Parameters
startIdxStart index of the range of LEDs in the strip (0 based)
endIdxEnd index of the range of LEDs in the strip (0 based)
brightnessBrightness value (0-31)
rRed component (0-255)
gGreen component (0-255)
bBlue component (0-255)

Here is the call graph for this function:

Here is the caller graph for this function:

void setLedsBrightness ( uint16_t  startIdx,
uint16_t  endIdx,
uint8_t  brightness 
)

Change the brightness for a range of leds

Parameters
startIdxStart index of the range of LEDs in the strip (0 based)
endIdxEnd index of the range of LEDs in the strip (0 based)
brightnessBrightness value (0-31)

Here is the call graph for this function:

Here is the caller graph for this function:

void setLeds ( uint16_t  startIdx,
uint16_t  endIdx,
uint8_t *  colors 
)

(Advanced) Manually control the colors and brightness of a range of LEDS Best used to maximize performance

Parameters
startIdxStart index of the range of LEDs to update (0 based)
endIdxEnd index of the range of LEDs to update (0 based)
colorsPointer to an array of bytes. Each color is described as the following: B1: Brightness (224-255) B2: Blue (0-255) B3: Green (0-255) B4: Red (0-255) No check done on the boundaries

Here is the call graph for this function:

void setBusSpeed ( int  hz)

Change the speed/frequency of the SPI bus Note: Slower speeds will allow driving longer strips without having to condition the clock signal with extra hardware

Parameters
hzDesired bus speed in Hz
void pushState ( void  )

Outputs the current LED data to the SPI bus Note: Only required if batch mode is set to TRUE

Here is the caller graph for this function:


The documentation for this class was generated from the following files: