change max number of LEDs to 200.
Fork of Multi_WS2811 by
LedStrip.h@8:d9b7240e873e, 2014-12-11 (annotated)
- Committer:
- robertbui
- Date:
- Thu Dec 11 13:31:53 2014 +0000
- Revision:
- 8:d9b7240e873e
- Parent:
- 7:58623ad7f310
set max led to 200
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bikeNomad | 0:a8535703f23b | 1 | // Parent class for all addressable LED strips. |
bikeNomad | 0:a8535703f23b | 2 | // Partially based on work by and (c) 2011 Jelmer Tiete |
bikeNomad | 0:a8535703f23b | 3 | // whose library is ported from the Arduino implementation of Adafruit Industries |
bikeNomad | 0:a8535703f23b | 4 | // found at: http://github.com/adafruit/LPD8806 |
bikeNomad | 0:a8535703f23b | 5 | // and their strips: http://www.adafruit.com/products/306 |
bikeNomad | 0:a8535703f23b | 6 | // Released under the MIT License: http://mbed.org/license/mit |
bikeNomad | 0:a8535703f23b | 7 | |
bikeNomad | 0:a8535703f23b | 8 | // This is a pure virtual parent class for all LED strips, so that different types |
bikeNomad | 0:a8535703f23b | 9 | // of strip may be used in a single array or container. |
bikeNomad | 0:a8535703f23b | 10 | |
bikeNomad | 0:a8535703f23b | 11 | #include "mbed.h" |
bikeNomad | 0:a8535703f23b | 12 | |
bikeNomad | 0:a8535703f23b | 13 | #ifndef LEDSTRIP_H |
bikeNomad | 0:a8535703f23b | 14 | #define LEDSTRIP_H |
bikeNomad | 0:a8535703f23b | 15 | |
Tomo2k | 3:2b5b03a3c0a5 | 16 | /** Generic LED Strip |
Tomo2k | 3:2b5b03a3c0a5 | 17 | Pure virtual parent class for all types of LED strip |
Tomo2k | 3:2b5b03a3c0a5 | 18 | */ |
bikeNomad | 0:a8535703f23b | 19 | class LedStrip |
bikeNomad | 0:a8535703f23b | 20 | { |
bikeNomad | 0:a8535703f23b | 21 | public: |
Tomo2k | 3:2b5b03a3c0a5 | 22 | /** Create an LED strip |
Tomo2k | 7:58623ad7f310 | 23 | @param pixelCount Number of RGB LEDs on the strip |
Tomo2k | 3:2b5b03a3c0a5 | 24 | */ |
Tomo2k | 7:58623ad7f310 | 25 | LedStrip(uint16_t pixelCount); |
bikeNomad | 0:a8535703f23b | 26 | ~LedStrip(); |
bikeNomad | 0:a8535703f23b | 27 | |
Tomo2k | 3:2b5b03a3c0a5 | 28 | //! Initialise the LED strip |
bikeNomad | 0:a8535703f23b | 29 | virtual void begin(void)=0; |
Tomo2k | 7:58623ad7f310 | 30 | //! Apply the new LED strip values |
bikeNomad | 0:a8535703f23b | 31 | virtual void show(void)=0; |
Tomo2k | 3:2b5b03a3c0a5 | 32 | //! Blank the LED strip |
bikeNomad | 0:a8535703f23b | 33 | virtual void blank(void)=0; |
bikeNomad | 0:a8535703f23b | 34 | |
Tomo2k | 3:2b5b03a3c0a5 | 35 | /** Pack RGB Color data |
Tomo2k | 7:58623ad7f310 | 36 | @param red Amount of Red |
Tomo2k | 7:58623ad7f310 | 37 | @param green Amount of Green |
Tomo2k | 7:58623ad7f310 | 38 | @param blue Amount of Blue |
Tomo2k | 7:58623ad7f310 | 39 | @returns Packed RGB color data for one pixel |
Tomo2k | 3:2b5b03a3c0a5 | 40 | */ |
Tomo2k | 7:58623ad7f310 | 41 | static uint32_t Color(uint8_t red, uint8_t green, uint8_t blue); |
bikeNomad | 0:a8535703f23b | 42 | |
Tomo2k | 3:2b5b03a3c0a5 | 43 | //! Number of RGB pixels |
Tomo2k | 7:58623ad7f310 | 44 | uint16_t numPixels() { |
Tomo2k | 7:58623ad7f310 | 45 | return numLEDs; |
Tomo2k | 7:58623ad7f310 | 46 | } |
Tomo2k | 3:2b5b03a3c0a5 | 47 | //! Number of bytes used for pixel colour data |
Tomo2k | 7:58623ad7f310 | 48 | uint16_t numPixelBytes() { |
Tomo2k | 7:58623ad7f310 | 49 | return numLEDs * 3; |
Tomo2k | 7:58623ad7f310 | 50 | } |
Tomo2k | 7:58623ad7f310 | 51 | /** Total brightness of all diodes\n |
Tomo2k | 7:58623ad7f310 | 52 | * Use to check power budget |
Tomo2k | 7:58623ad7f310 | 53 | @returns Sum total of all diodes (red + green + blue) |
Tomo2k | 7:58623ad7f310 | 54 | */ |
Tomo2k | 7:58623ad7f310 | 55 | uint32_t total_luminance(); |
bikeNomad | 0:a8535703f23b | 56 | |
Tomo2k | 3:2b5b03a3c0a5 | 57 | /** Set Blue level of pixel |
Tomo2k | 7:58623ad7f310 | 58 | @param pixNum Pixel Number |
Tomo2k | 7:58623ad7f310 | 59 | @param blue Amount of Blue |
Tomo2k | 3:2b5b03a3c0a5 | 60 | */ |
Tomo2k | 7:58623ad7f310 | 61 | void setPixelB(uint16_t pixNum, uint8_t blue); |
Tomo2k | 3:2b5b03a3c0a5 | 62 | /** Set Green level of pixel |
Tomo2k | 7:58623ad7f310 | 63 | @param pixNum Pixel Number |
Tomo2k | 7:58623ad7f310 | 64 | @param green Amount of Green |
Tomo2k | 3:2b5b03a3c0a5 | 65 | */ |
Tomo2k | 7:58623ad7f310 | 66 | void setPixelG(uint16_t pixNum, uint8_t green); |
Tomo2k | 3:2b5b03a3c0a5 | 67 | /** Set Red level of pixel |
Tomo2k | 7:58623ad7f310 | 68 | @param pixNum Pixel Number |
Tomo2k | 7:58623ad7f310 | 69 | @param red Amount of Red |
Tomo2k | 3:2b5b03a3c0a5 | 70 | */ |
Tomo2k | 7:58623ad7f310 | 71 | void setPixelR(uint16_t pixNum, uint8_t red); |
Tomo2k | 7:58623ad7f310 | 72 | |
Tomo2k | 3:2b5b03a3c0a5 | 73 | /** Set color of pixel |
Tomo2k | 7:58623ad7f310 | 74 | @param pixNum Pixel Number |
Tomo2k | 7:58623ad7f310 | 75 | @param color Packed RGB color data |
Tomo2k | 3:2b5b03a3c0a5 | 76 | */ |
Tomo2k | 7:58623ad7f310 | 77 | void setPixelColor(uint16_t pixNum, uint32_t color); |
Tomo2k | 3:2b5b03a3c0a5 | 78 | /** Set color of pixel |
Tomo2k | 7:58623ad7f310 | 79 | @param pixNum Pixel Number |
Tomo2k | 7:58623ad7f310 | 80 | @param red Amount of Red |
Tomo2k | 7:58623ad7f310 | 81 | @param green Amount of Green |
Tomo2k | 7:58623ad7f310 | 82 | @param blue Amount of Blue |
Tomo2k | 3:2b5b03a3c0a5 | 83 | */ |
Tomo2k | 7:58623ad7f310 | 84 | void setPixelColor(uint16_t pixNum, uint8_t red, uint8_t green, uint8_t blue); |
Tomo2k | 3:2b5b03a3c0a5 | 85 | /** Set color of all pixels |
Tomo2k | 3:2b5b03a3c0a5 | 86 | @param *buffer Packed pixel data |
Tomo2k | 7:58623ad7f310 | 87 | @param count Number of pixels |
Tomo2k | 7:58623ad7f310 | 88 | */ |
Tomo2k | 7:58623ad7f310 | 89 | void setPackedPixels(uint8_t * buffer, uint32_t count); |
bikeNomad | 0:a8535703f23b | 90 | |
bikeNomad | 0:a8535703f23b | 91 | protected: |
bikeNomad | 0:a8535703f23b | 92 | uint8_t *pixels; // Holds LED color values |
bikeNomad | 0:a8535703f23b | 93 | uint16_t numLEDs; // Number of RGB LEDs in strand |
bikeNomad | 0:a8535703f23b | 94 | }; |
bikeNomad | 0:a8535703f23b | 95 | #endif |