This library lets you control the addressable RGB LED strips from Pololu Robotics. Forked to add selectable colour order (Support RGB or GRB Leds)
Fork of PololuLedStrip by
PololuLedStrip.h
00001 #include "mbed.h" 00002 00003 #ifndef _POLOLU_LED_STRIP_H 00004 #define _POLOLU_LED_STRIP_H 00005 00006 //If multiple colour orders are enabled, GRB will override RGB. 00007 00008 //Use RGB colour order for WS2811 leds 00009 #define _POLOLU_ORDER_RGB 00010 00011 //Use GRB colour order for WS2812b leds 00012 //#define _POLOLU_ORDER_GRB 00013 00014 00015 namespace Pololu 00016 { 00017 #ifndef _POLOLU_RGB_COLOR 00018 #define _POLOLU_RGB_COLOR 00019 00020 /** Represents an RGB color. */ 00021 typedef struct rgb_color 00022 { 00023 uint8_t red ; /*!< A number between 0 and 255 that represents the brightness of the red component. */ 00024 uint8_t green ; /*!< A number between 0 and 255 that represents the brightness of the green component. */ 00025 uint8_t blue ; /*!< A number between 0 and 255 that represents the brightness of the blue component. */ 00026 } rgb_color; 00027 #endif 00028 extern "C" int led_strip_write_color(rgb_color *, volatile uint32_t * set, volatile uint32_t * clear, uint32_t mask); 00029 00030 /** This class lets you control the addressable RGB LED strips from Pololu</a>, 00031 or any other LED strip based on the TM1804 chip. */ 00032 class PololuLedStrip 00033 { 00034 gpio_t gpio; 00035 00036 public: 00037 00038 /** This constructor lets you make an led strip object by specifying the pin name. 00039 There are no restrictions on what pin you can choose. 00040 00041 Example: 00042 @code 00043 PololuLedStrip ledStrip(p8); 00044 @endcode 00045 */ 00046 PololuLedStrip(PinName pin); 00047 00048 /** Writes the specified series of colors to the LED strip. 00049 @param colors should be a pointer to an array of rgb_color structs. 00050 @param count should be the number of colors to write. 00051 00052 The first color in the array will be written to the LED closest to the data input connector. 00053 To update all the LEDs in the LED strip, count should be equal to or greater than the number of LEDs in the strip. 00054 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. 00055 00056 The colors are sent in series and each color takes about 45 microseconds to send. 00057 This function disables interrupts temporarily while it is running. 00058 This function waits for over 10 us at the end before returning to allow the colors to take effect. 00059 */ 00060 void write(rgb_color * colors, unsigned int count); 00061 00062 /** This option defaults to <code>false</code>. 00063 Setting this to true changes the behavior of the write function, making it enable interrupts 00064 after each color is sent, about every 60 microseconds. 00065 This allows your program to respond to interrupts faster, but makes it possible for an interrupt 00066 that takes longer than 8 microseconds to screw up the transmission of colors to the LED strip. 00067 00068 Example: 00069 @code 00070 PololuLedStrip::interruptFriendly = true; 00071 @endcode 00072 */ 00073 static bool interruptFriendly; 00074 00075 static void calculateDelays(); 00076 }; 00077 } 00078 00079 using namespace Pololu; 00080 00081 #endif
Generated on Sat Aug 13 2022 02:11:54 by
1.7.2
