Adafruit LPD8806 LED Strip Library
LPD8806.h
Go to the documentation of this file.
1 
6 #ifndef LPD8806_H
7 #define LPD8806_H
8 
9 #if (ARDUINO >= 100)
10 #include <Arduino.h>
11 #else
12 #include <WProgram.h>
13 #include <pins_arduino.h>
14 #endif
15 
16 /**************************************************************************/
21 /**************************************************************************/
22 class LPD8806 {
23 
24 public:
25  LPD8806(uint16_t n, uint8_t dpin, uint8_t cpin); // Configurable pins
26  LPD8806(uint16_t n); // Use SPI hardware; specific pins only
27  LPD8806(void); // Empty constructor; init pins & strip length later
28  void begin(void), setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b),
29  setPixelColor(uint16_t n, uint32_t c),
30  setPixelColorRGB(uint16_t n, uint32_t c), show(void),
31  updatePins(uint8_t dpin, uint8_t cpin), // Change pins, configurable
32  updatePins(void), // Change pins, hardware SPI
33  updateLength(uint16_t n); // Change strip length
34  uint16_t numPixels(void);
35  uint32_t Color(byte, byte, byte), getPixelColor(uint16_t n);
36 
37 private:
38  uint16_t numLEDs, // Number of RGB LEDs in strip
39  numBytes; // Size of 'pixels' buffer below
40  uint8_t *pixels; // Holds LED color values (3 bytes each) + latch bytes
41  int8_t clkpin, datapin; // Clock & data pin numbers
42 #ifdef __AVR__
43  uint8_t clkpinmask, datapinmask; // Clock & data PORT bitmasks
44  volatile uint8_t *clkport, *dataport; // Clock & data PORT registers
45 #endif
46  void startBitbang(void), startSPI(void);
47  boolean begun; // If 'true', begin() method was previously invoked
48 };
49 #endif
void updateLength(uint16_t n)
Change strip length, calls malloc and free!
Definition: LPD8806.cpp:237
void show(void)
Writes all the LED data to the strip at once!
Definition: LPD8806.cpp:270
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.
Definition: LPD8806.cpp:328
uint32_t Color(byte, byte, byte)
Convert separate R,G,B into combined 32-bit GRB color.
Definition: LPD8806.cpp:315
void begin(void)
Activate hard/soft SPI as appropriate.
Definition: LPD8806.cpp:170
Class that stores state and functions for interacting with LPD8806 LED strips.
Definition: LPD8806.h:22
void updatePins(void)
Change pin assignments post-constructor, switching to hardware SPI.
Definition: LPD8806.cpp:183
uint32_t getPixelColor(uint16_t n)
Query color from previously-set pixel (returns packed 32-bit GRB value)
Definition: LPD8806.cpp:377
void setPixelColorRGB(uint16_t n, uint32_t c)
Set pixel color from &#39;packed&#39; 32-bit RGB value.
Definition: LPD8806.cpp:360
uint16_t numPixels(void)
Retrieve number of LEDs in strip.
Definition: LPD8806.cpp:263