LeeT WiFiLamp code and test

Dependencies:   ESP8266_WebServer mbed

Fork of WiFiLamp by Sebastian Schocke

Committer:
sschocke
Date:
Mon Dec 01 08:29:02 2014 +0000
Revision:
2:48412ab84b71
Parent:
1:f07afcffeb5a
Child:
3:34cd0bb34971
Fix Pololu LED Strip library to compile for both F401 and F103 platforms

Who changed what in which revision?

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