Forked PololuLedStrip and modified it to work with the KL25Z. Renamed it to Adafruit_NeoPixel.

Dependents:   idd_hw3 idd_fa15_hw3_lauren_bill_tomas idd_fa15_hw3_lauren_bill_tomas Raiden ... more

Fork of PololuLedStrip by David Grayson

Committer:
DavidEGrayson
Date:
Wed Feb 27 01:43:44 2013 +0000
Revision:
1:102307d9b701
Parent:
0:06475317f283
Child:
7:9a088f042ee0
Initial commit.;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DavidEGrayson 0:06475317f283 1 #include "mbed.h"
DavidEGrayson 0:06475317f283 2
DavidEGrayson 0:06475317f283 3 #ifndef _POLOLU_LED_STRIP_H
DavidEGrayson 0:06475317f283 4 #define _POLOLU_LED_STRIP_H
DavidEGrayson 0:06475317f283 5
DavidEGrayson 0:06475317f283 6 namespace Pololu
DavidEGrayson 0:06475317f283 7 {
DavidEGrayson 0:06475317f283 8 #ifndef _POLOLU_RGB_COLOR
DavidEGrayson 0:06475317f283 9 #define _POLOLU_RGB_COLOR
DavidEGrayson 1:102307d9b701 10
DavidEGrayson 1:102307d9b701 11 /** Represents an RGB color. */
DavidEGrayson 0:06475317f283 12 typedef struct rgb_color
DavidEGrayson 0:06475317f283 13 {
DavidEGrayson 1:102307d9b701 14 uint8_t red; /*!< A number between 0 and 255 that represents the brightness of the red component. */
DavidEGrayson 1:102307d9b701 15 uint8_t green; /*!< A number between 0 and 255 that represents the brightness of the green component. */
DavidEGrayson 1:102307d9b701 16 uint8_t blue; /*!< A number between 0 and 255 that represents the brightness of the blue component. */
DavidEGrayson 0:06475317f283 17 } rgb_color;
DavidEGrayson 0:06475317f283 18 #endif
DavidEGrayson 0:06475317f283 19
DavidEGrayson 0:06475317f283 20 extern "C" int led_strip_write_color(rgb_color *, volatile uint32_t * set, volatile uint32_t * clear, uint32_t mask);
DavidEGrayson 0:06475317f283 21
DavidEGrayson 1:102307d9b701 22 /** This class lets you control the
DavidEGrayson 1:102307d9b701 23 <a href="http://www.pololu.com/catalog/category/20">addressable RGB LED strips from Pololu</a>,
DavidEGrayson 1:102307d9b701 24 or any other LED strip based on the TM1804 chip. */
DavidEGrayson 0:06475317f283 25 class PololuLedStrip
DavidEGrayson 0:06475317f283 26 {
DavidEGrayson 0:06475317f283 27 gpio_t gpio;
DavidEGrayson 1:102307d9b701 28
DavidEGrayson 0:06475317f283 29 public:
DavidEGrayson 1:102307d9b701 30
DavidEGrayson 1:102307d9b701 31 /** This constructor lets you make an led strip object by specifying the pin name.
DavidEGrayson 1:102307d9b701 32 There are no restrictions on what pin you can choose.
DavidEGrayson 1:102307d9b701 33
DavidEGrayson 1:102307d9b701 34 Example:
DavidEGrayson 1:102307d9b701 35 @code
DavidEGrayson 1:102307d9b701 36 PololuLedStrip ledStrip(p8);
DavidEGrayson 1:102307d9b701 37 @endcode
DavidEGrayson 1:102307d9b701 38 */
DavidEGrayson 0:06475317f283 39 PololuLedStrip(PinName pin);
DavidEGrayson 1:102307d9b701 40
DavidEGrayson 1:102307d9b701 41 /** Writes the specified series of colors to the LED strip.
DavidEGrayson 1:102307d9b701 42 @param colors should be a pointer to an array of rgb_color structs.
DavidEGrayson 1:102307d9b701 43 @param count should be the number of colors to write.
DavidEGrayson 1:102307d9b701 44
DavidEGrayson 1:102307d9b701 45 The first color in the array will be written to the LED closest to the data input connector.
DavidEGrayson 1:102307d9b701 46 To update all the LEDs in the LED strip, count should be equal to or greater than the number of LEDs in the strip.
DavidEGrayson 1:102307d9b701 47 If count is less than the number of LEDs in the strip, then some LEDs near the end of the strip will not be updated.
DavidEGrayson 1:102307d9b701 48
DavidEGrayson 1:102307d9b701 49 The colors are sent in series and each color takes about 60 microseconds to send.
DavidEGrayson 1:102307d9b701 50 This function disables interrupts temporarily while it is running.
DavidEGrayson 1:102307d9b701 51 This function waits for over 10 us at the end before returning to allow the colors to take effect.
DavidEGrayson 1:102307d9b701 52 */
DavidEGrayson 0:06475317f283 53 void write(rgb_color * colors, unsigned int count);
DavidEGrayson 1:102307d9b701 54
DavidEGrayson 1:102307d9b701 55 /** This option defaults to <code>false</code>.
DavidEGrayson 1:102307d9b701 56 Setting this to true changes the behavior of the write function, making it enable interrupts
DavidEGrayson 1:102307d9b701 57 after each color is sent, about every 60 microseconds.
DavidEGrayson 1:102307d9b701 58 This allows your program to respond to interrupts faster, but makes it possible for an interrupt
DavidEGrayson 1:102307d9b701 59 that takes longer than 8 microseconds to screw up the transmission of colors to the LED strip.
DavidEGrayson 1:102307d9b701 60
DavidEGrayson 1:102307d9b701 61 Example:
DavidEGrayson 1:102307d9b701 62 @code
DavidEGrayson 1:102307d9b701 63 PololuLedStrip::interruptFriendly = true;
DavidEGrayson 1:102307d9b701 64 @endcode
DavidEGrayson 1:102307d9b701 65 */
DavidEGrayson 0:06475317f283 66 static bool interruptFriendly;
DavidEGrayson 0:06475317f283 67 };
DavidEGrayson 0:06475317f283 68 }
DavidEGrayson 0:06475317f283 69
DavidEGrayson 0:06475317f283 70 using namespace Pololu;
DavidEGrayson 0:06475317f283 71
DavidEGrayson 0:06475317f283 72 #endif