Library allowing up to 16 strings of 60 WS2811 or WS2812 LEDs to be driven from a single FRDM-KL25Z board. Uses hardware DMA to do a full 800 KHz rate without much CPU burden.

Dependents:   Multi_WS2811_test

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LedStrip.h Source File

LedStrip.h

00001 // Parent class for all addressable LED strips.
00002 // Partially based on work by and (c) 2011 Jelmer Tiete
00003 // whose library is ported from the Arduino implementation of Adafruit Industries
00004 // found at: http://github.com/adafruit/LPD8806
00005 // and their strips: http://www.adafruit.com/products/306
00006 // Released under the MIT License: http://mbed.org/license/mit
00007 
00008 // This is a pure virtual parent class for all LED strips, so that different types
00009 // of strip may be used in a single array or container.
00010 
00011 #ifndef LEDSTRIP_H
00012 #define LEDSTRIP_H
00013 
00014 #include <stdint.h>
00015 
00016 class LedStrip
00017 {
00018 public:
00019     LedStrip(int n);
00020     ~LedStrip();
00021 
00022     virtual void begin(void)=0;
00023     virtual void show(void)=0;
00024     virtual void blank(void)=0;
00025 
00026     static uint32_t Color(uint8_t r, uint8_t g, uint8_t b);
00027 
00028     uint16_t numPixels(void) { return numLEDs; }
00029     uint16_t numPixelBytes(void) { return numLEDs * 3; }
00030     uint32_t total_luminance(void);
00031 
00032     void setPixelB(uint16_t n, uint8_t b);
00033     void setPixelG(uint16_t n, uint8_t g);
00034     void setPixelR(uint16_t n, uint8_t r);
00035     
00036     void setPixelColor(uint16_t n, uint32_t c);
00037     void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b);
00038     void setPackedPixels(uint8_t * buffer, uint32_t n);
00039 
00040 protected:
00041     uint8_t *pixels;     // Holds LED color values
00042     uint16_t numLEDs;     // Number of RGB LEDs in strand
00043 };
00044 #endif