Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Multi_WS2811 by
LedStrip.h@1:c4123ca9b02c, 2014-12-14 (annotated)
- Committer:
- ryanfeng
- Date:
- Sun Dec 14 04:49:52 2014 +0000
- Revision:
- 1:c4123ca9b02c
- Parent:
- 0:a8535703f23b
Changed values for flippityflappity
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 | |
| bikeNomad | 0:a8535703f23b | 16 | class LedStrip |
| bikeNomad | 0:a8535703f23b | 17 | { |
| bikeNomad | 0:a8535703f23b | 18 | public: |
| bikeNomad | 0:a8535703f23b | 19 | LedStrip(int n); |
| bikeNomad | 0:a8535703f23b | 20 | ~LedStrip(); |
| bikeNomad | 0:a8535703f23b | 21 | |
| bikeNomad | 0:a8535703f23b | 22 | virtual void begin(void)=0; |
| bikeNomad | 0:a8535703f23b | 23 | virtual void show(void)=0; |
| bikeNomad | 0:a8535703f23b | 24 | virtual void blank(void)=0; |
| bikeNomad | 0:a8535703f23b | 25 | |
| bikeNomad | 0:a8535703f23b | 26 | static uint32_t Color(uint8_t r, uint8_t g, uint8_t b); |
| bikeNomad | 0:a8535703f23b | 27 | |
| bikeNomad | 0:a8535703f23b | 28 | uint16_t numPixels(void) { return numLEDs; } |
| bikeNomad | 0:a8535703f23b | 29 | uint16_t numPixelBytes(void) { return numLEDs * 3; } |
| bikeNomad | 0:a8535703f23b | 30 | uint32_t total_luminance(void); |
| bikeNomad | 0:a8535703f23b | 31 | |
| bikeNomad | 0:a8535703f23b | 32 | void setPixelB(uint16_t n, uint8_t b); |
| bikeNomad | 0:a8535703f23b | 33 | void setPixelG(uint16_t n, uint8_t g); |
| bikeNomad | 0:a8535703f23b | 34 | void setPixelR(uint16_t n, uint8_t r); |
| bikeNomad | 0:a8535703f23b | 35 | |
| bikeNomad | 0:a8535703f23b | 36 | void setPixelColor(uint16_t n, uint32_t c); |
| bikeNomad | 0:a8535703f23b | 37 | void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b); |
| bikeNomad | 0:a8535703f23b | 38 | void setPackedPixels(uint8_t * buffer, uint32_t n); |
| bikeNomad | 0:a8535703f23b | 39 | |
| bikeNomad | 0:a8535703f23b | 40 | protected: |
| bikeNomad | 0:a8535703f23b | 41 | uint8_t *pixels; // Holds LED color values |
| bikeNomad | 0:a8535703f23b | 42 | uint16_t numLEDs; // Number of RGB LEDs in strand |
| bikeNomad | 0:a8535703f23b | 43 | }; |
| bikeNomad | 0:a8535703f23b | 44 | #endif |
