Adafruit LPD8806 LED Strip Library
Public Member Functions | List of all members
LPD8806 Class Reference

Class that stores state and functions for interacting with LPD8806 LED strips. More...

#include <LPD8806.h>

Public Member Functions

 LPD8806 (uint16_t n, uint8_t dpin, uint8_t cpin)
 Instantiates a new LPD8806 class using Software SPI. More...
 
 LPD8806 (uint16_t n)
 Instantiates a new LPD8806 class using Hardware SPI. Can also be used to create an object where we define the number of LEDs and pins later. More...
 
void begin (void)
 Activate hard/soft SPI as appropriate.
 
void setPixelColor (uint16_t n, uint8_t r, uint8_t g, uint8_t b)
 Set pixel color from separate 7-bit R, G, B components. More...
 
void setPixelColor (uint16_t n, uint32_t c)
 Set pixel color from 'packed' 32-bit GRB (not RGB) value. More...
 
void setPixelColorRGB (uint16_t n, uint32_t c)
 Set pixel color from 'packed' 32-bit RGB value. More...
 
void show (void)
 Writes all the LED data to the strip at once!
 
void updatePins (uint8_t dpin, uint8_t cpin)
 Change pin assignments post-constructor, switching to software SPI. More...
 
void updatePins (void)
 Change pin assignments post-constructor, switching to hardware SPI.
 
void updateLength (uint16_t n)
 Change strip length, calls malloc and free! More...
 
uint16_t numPixels (void)
 Retrieve number of LEDs in strip. More...
 
uint32_t Color (byte, byte, byte)
 Convert separate R,G,B into combined 32-bit GRB color. More...
 
uint32_t getPixelColor (uint16_t n)
 Query color from previously-set pixel (returns packed 32-bit GRB value) More...
 

Detailed Description

Class that stores state and functions for interacting with LPD8806 LED strips.

Constructor & Destructor Documentation

◆ LPD8806() [1/2]

LPD8806::LPD8806 ( uint16_t  n,
uint8_t  dpin,
uint8_t  cpin 
)

Instantiates a new LPD8806 class using Software SPI.

Parameters
nNumber of pixels we will be addressing
dpinOur bit-bang data pin
cpinOur bit-bag clock pin

◆ LPD8806() [2/2]

LPD8806::LPD8806 ( uint16_t  n)

Instantiates a new LPD8806 class using Hardware SPI. Can also be used to create an object where we define the number of LEDs and pins later.

Parameters
nNumber of pixels we will be addressing. If not passed in make sure to call updateLength() later!

Member Function Documentation

◆ setPixelColor() [1/2]

void LPD8806::setPixelColor ( uint16_t  n,
uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Set pixel color from separate 7-bit R, G, B components.

Parameters
nPixel # to change (0 is first pixel)
rRed value, 0-127
gGreen value, 0-127
bBlue value, 0-127

◆ setPixelColor() [2/2]

void LPD8806::setPixelColor ( uint16_t  n,
uint32_t  c 
)

Set pixel color from 'packed' 32-bit GRB (not RGB) value.

Parameters
nPixel # to change (0 is first pixel)
cPacked color word

◆ setPixelColorRGB()

void LPD8806::setPixelColorRGB ( uint16_t  n,
uint32_t  c 
)

Set pixel color from 'packed' 32-bit RGB value.

Parameters
nPixel # to change (0 is first pixel)
cPacked color word

◆ updatePins()

void LPD8806::updatePins ( uint8_t  dpin,
uint8_t  cpin 
)

Change pin assignments post-constructor, switching to software SPI.

Parameters
dpinOur bit-bang data pin
cpinOur bit-bag clock pin

◆ updateLength()

void LPD8806::updateLength ( uint16_t  n)

Change strip length, calls malloc and free!

Parameters
nNew number of LEDs in strip

◆ numPixels()

uint16_t LPD8806::numPixels ( void  )

Retrieve number of LEDs in strip.

Returns
Number of LEDs in strip

◆ Color()

uint32_t LPD8806::Color ( byte  r,
byte  g,
byte  b 
)

Convert separate R,G,B into combined 32-bit GRB color.

Parameters
rRed value, 0-127
gGreen value, 0-127
bBlue value, 0-127
Returns
21-bit color value in uint32_t with red, green and blue packed

◆ getPixelColor()

uint32_t LPD8806::getPixelColor ( uint16_t  n)

Query color from previously-set pixel (returns packed 32-bit GRB value)

Parameters
nPixel # to change (0 is first pixel)
Returns
Packed color word

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