diff options
author | Daniel Garcia <danielgarcia@gmail.com> | 2015-02-09 11:07:19 +0300 |
---|---|---|
committer | Daniel Garcia <danielgarcia@gmail.com> | 2015-02-09 11:07:19 +0300 |
commit | 033f47f3c95f4143d7f1d97144b0100dafa3d1df (patch) | |
tree | 3d0fa216d45342bfc7545c8afc7773d0e65b7d50 | |
parent | f149084f46492e0d012be82b96bf7b2d50e24a5a (diff) |
SparkCore needs FastLED to be in a namespace.
-rw-r--r-- | FastLED.cpp | 2 | ||||
-rw-r--r-- | FastLED.h | 4 | ||||
-rw-r--r-- | bitswap.h | 5 | ||||
-rw-r--r-- | chipsets.h | 4 | ||||
-rw-r--r-- | color.h | 7 | ||||
-rw-r--r-- | colorpalettes.cpp | 2 | ||||
-rw-r--r-- | colorpalettes.h | 3 | ||||
-rw-r--r-- | colorutils.cpp | 1 | ||||
-rw-r--r-- | colorutils.h | 126 | ||||
-rw-r--r-- | controller.h | 4 | ||||
-rw-r--r-- | delay.h | 3 | ||||
-rw-r--r-- | dmx.h | 9 | ||||
-rw-r--r-- | fastpin.h | 69 | ||||
-rw-r--r-- | fastspi.h | 4 | ||||
-rw-r--r-- | fastspi_bitbang.h | 4 | ||||
-rw-r--r-- | fastspi_nop.h | 4 | ||||
-rw-r--r-- | fastspi_ref.h | 6 | ||||
-rw-r--r-- | fastspi_types.h | 4 | ||||
-rw-r--r-- | hsv2rgb.cpp | 2 | ||||
-rw-r--r-- | hsv2rgb.h | 3 | ||||
-rw-r--r-- | led_sysdefs.h | 10 | ||||
-rw-r--r-- | lib8tion.cpp | 2 | ||||
-rw-r--r-- | lib8tion.h | 4 | ||||
-rw-r--r-- | noise.cpp | 2 | ||||
-rw-r--r-- | noise.h | 4 | ||||
-rw-r--r-- | pixeltypes.h | 3 | ||||
-rw-r--r-- | platforms.h | 2 | ||||
-rw-r--r-- | power_mgt.cpp | 2 | ||||
-rw-r--r-- | power_mgt.h | 4 | ||||
-rw-r--r-- | wiring.cpp | 2 |
30 files changed, 235 insertions, 66 deletions
diff --git a/FastLED.cpp b/FastLED.cpp index 821f1e2f..b3718576 100644 --- a/FastLED.cpp +++ b/FastLED.cpp @@ -1,6 +1,8 @@ #define FASTLED_INTERNAL #include "FastLED.h" +FASTLED_USING_NAMESPACE + #if defined(__SAM3X8E__) volatile uint32_t fuckit; #endif @@ -52,6 +52,8 @@ #include "fastspi.h" #include "chipsets.h" +FASTLED_NAMESPACE_BEGIN + enum ESPIChipsets { LPD8806, WS2801, @@ -464,4 +466,6 @@ extern CFastLED FastLED; #endif +FASTLED_NAMESPACE_END + #endif @@ -1,6 +1,8 @@ #ifndef __INC_BITSWAP_H #define __INC_BITSWAP_H +FASTLED_NAMESPACE_BEGIN + #ifdef FASTLED_ARM // structure representing 8 bits of access typedef union { @@ -254,4 +256,7 @@ __attribute__((always_inline)) inline void transpose8(unsigned char *A, unsigned // B[4*n]=y>>24; B[5*n]=y>>16; B[6*n]=y>>8; B[7*n]=y>>0; } #endif + +FASTLED_NAMESPACE_END + #endif @@ -3,6 +3,8 @@ #include "pixeltypes.h" +FASTLED_NAMESPACE_BEGIN + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // DeepPixel controller class - takes data/clock/select pin values (N.B. should take an SPI definition?) @@ -577,4 +579,6 @@ class LPD1886Controller1250Khz : public ClocklessController<DATA_PIN, NS(200), N #endif +FASTLED_NAMESPACE_END + #endif @@ -1,6 +1,8 @@ #ifndef __INC_COLOR_H #define __INC_COLOR_H +FASTLED_NAMESPACE_BEGIN + // definitions for color correction and light temperatures typedef enum { @@ -51,4 +53,7 @@ typedef enum { // Uncorrected temperature 0xFFFFFF UncorrectedTemperature=0xFFFFFF } ColorTemperature; -#endif
\ No newline at end of file + +FASTLED_NAMESPACE_END + +#endif diff --git a/colorpalettes.cpp b/colorpalettes.cpp index dea16f77..d4d4b56c 100644 --- a/colorpalettes.cpp +++ b/colorpalettes.cpp @@ -5,6 +5,8 @@ #include "colorutils.h" #include "colorpalettes.h" +FASTLED_USING_NAMESPACE + // Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734 #ifdef FASTLED_AVR #ifdef PROGMEM diff --git a/colorpalettes.h b/colorpalettes.h index 340349d4..a1de78fe 100644 --- a/colorpalettes.h +++ b/colorpalettes.h @@ -3,6 +3,7 @@ #include "colorutils.h" +FASTLED_NAMESPACE_BEGIN // Preset color schemes, such as they are. @@ -39,4 +40,6 @@ extern const TProgmemRGBPalette16 PartyColors_p PROGMEM; // which looks wrong. extern const TProgmemRGBPalette16 HeatColors_p PROGMEM; +FASTLED_NAMESPACE_END + #endif diff --git a/colorutils.cpp b/colorutils.cpp index 86e946b0..a0cfc43f 100644 --- a/colorutils.cpp +++ b/colorutils.cpp @@ -5,6 +5,7 @@ #include "FastLED.h" +FASTLED_USING_NAMESPACE diff --git a/colorutils.h b/colorutils.h index 5750cad6..f8db545b 100644 --- a/colorutils.h +++ b/colorutils.h @@ -1,10 +1,13 @@ #ifndef __INC_COLORUTILS_H #define __INC_COLORUTILS_H +#ifdef ARDUINO #include <avr/pgmspace.h> +#endif #include "pixeltypes.h" +FASTLED_NAMESPACE_BEGIN // fill_solid - fill a range of LEDs with a solid color // Example: fill_solid( leds, NUM_LEDS, CRGB(50,0,200)); @@ -14,14 +17,14 @@ void fill_solid( struct CRGB * leds, int numToFill, void fill_solid( struct CHSV* targetArray, int numToFill, const struct CHSV& hsvColor); - + // fill_rainbow - fill a range of LEDs with a rainbow of colors, at // full saturation and full value (brightness) void fill_rainbow( struct CRGB * pFirstLED, int numToFill, uint8_t initialhue, uint8_t deltahue = 5); - + void fill_rainbow( struct CHSV * targetArray, int numToFill, uint8_t initialhue, uint8_t deltahue = 5); @@ -43,11 +46,11 @@ void fill_rainbow( struct CHSV * targetArray, int numToFill, // // fill_gradient can write the gradient colors EITHER // (1) into an array of CRGBs (e.g., into leds[] array, or an RGB Palette) -// OR +// OR // (2) into an array of CHSVs (e.g. an HSV Palette). // -// In the case of writing into a CRGB array, the gradient is -// computed in HSV space, and then HSV values are converted to RGB +// In the case of writing into a CRGB array, the gradient is +// computed in HSV space, and then HSV values are converted to RGB // as they're written into the RGB array. typedef enum { FORWARD_HUES, BACKWARD_HUES, SHORTEST_HUES, LONGEST_HUES } TGradientDirectionCode; @@ -71,7 +74,7 @@ void fill_gradient( T* targetArray, endcolor = startcolor; endpos = startpos; } - + // If we're fading toward black (val=0) or white (sat=0), // then set the endhue to the starthue. // This lets us ramp smoothly to black or white, regardless @@ -79,7 +82,7 @@ void fill_gradient( T* targetArray, if( endcolor.value == 0 || endcolor.saturation == 0) { endcolor.hue = startcolor.hue; } - + // Similarly, if we're fading in from black (val=0) or white (sat=0) // then set the starthue to the endhue. // This lets us ramp smoothly up from black or white, regardless @@ -87,30 +90,30 @@ void fill_gradient( T* targetArray, if( startcolor.value == 0 || startcolor.saturation == 0) { startcolor.hue = endcolor.hue; } - + saccum87 huedistance87; saccum87 satdistance87; saccum87 valdistance87; - + satdistance87 = (endcolor.sat - startcolor.sat) << 7; valdistance87 = (endcolor.val - startcolor.val) << 7; - + uint8_t huedelta8 = endcolor.hue - startcolor.hue; - + if( directionCode == SHORTEST_HUES ) { directionCode = FORWARD_HUES; if( huedelta8 > 127) { directionCode = BACKWARD_HUES; } } - + if( directionCode == LONGEST_HUES ) { directionCode = FORWARD_HUES; if( huedelta8 < 128) { directionCode = BACKWARD_HUES; } } - + if( directionCode == FORWARD_HUES) { huedistance87 = huedelta8 << 7; } @@ -119,18 +122,18 @@ void fill_gradient( T* targetArray, huedistance87 = (uint8_t)(256 - huedelta8) << 7; huedistance87 = -huedistance87; } - + uint16_t pixeldistance = endpos - startpos; int16_t divisor = pixeldistance ? pixeldistance : 1; - + saccum87 huedelta87 = huedistance87 / divisor; saccum87 satdelta87 = satdistance87 / divisor; saccum87 valdelta87 = valdistance87 / divisor; - + huedelta87 *= 2; satdelta87 *= 2; valdelta87 *= 2; - + accum88 hue88 = startcolor.hue << 8; accum88 sat88 = startcolor.sat << 8; accum88 val88 = startcolor.val << 8; @@ -146,7 +149,7 @@ void fill_gradient( T* targetArray, // Convenience functions to fill an array of colors with a // two-color, three-color, or four-color gradient template <typename T> -void fill_gradient( T* targetArray, uint16_t numLeds, const CHSV& c1, const CHSV& c2, +void fill_gradient( T* targetArray, uint16_t numLeds, const CHSV& c1, const CHSV& c2, TGradientDirectionCode directionCode = SHORTEST_HUES ) { uint16_t last = numLeds - 1; @@ -154,8 +157,8 @@ void fill_gradient( T* targetArray, uint16_t numLeds, const CHSV& c1, const CHSV } template <typename T> -void fill_gradient( T* targetArray, uint16_t numLeds, - const CHSV& c1, const CHSV& c2, const CHSV& c3, +void fill_gradient( T* targetArray, uint16_t numLeds, + const CHSV& c1, const CHSV& c2, const CHSV& c3, TGradientDirectionCode directionCode = SHORTEST_HUES ) { uint16_t half = (numLeds / 2); @@ -165,8 +168,8 @@ void fill_gradient( T* targetArray, uint16_t numLeds, } template <typename T> -void fill_gradient( T* targetArray, uint16_t numLeds, - const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4, +void fill_gradient( T* targetArray, uint16_t numLeds, + const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4, TGradientDirectionCode directionCode = SHORTEST_HUES ) { uint16_t onethird = (numLeds / 3); @@ -363,7 +366,7 @@ class CHSVPalette16; class CHSVPalette256; typedef uint32_t TProgmemRGBPalette16[16]; typedef uint32_t TProgmemHSVPalette16[16]; -#define TProgmemPalette16 TProgmemRGBPalette16 +#define TProgmemPalette16 TProgmemRGBPalette16 // Convert a 16-entry palette to a 256-entry palette void UpscalePalette(const struct CRGBPalette16& srcpal16, struct CRGBPalette256& destpal256); @@ -383,7 +386,7 @@ public: entries[8]=c08; entries[9]=c09; entries[10]=c10; entries[11]=c11; entries[12]=c12; entries[13]=c13; entries[14]=c14; entries[15]=c15; }; - + CHSVPalette16( const CHSVPalette16& rhs) { memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); @@ -393,7 +396,7 @@ public: memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); return *this; } - + CHSVPalette16( const TProgmemHSVPalette16& rhs) { for( uint8_t i = 0; i < 16; i++) { @@ -413,7 +416,7 @@ public: } return *this; } - + inline CHSV& operator[] (uint8_t x) __attribute__((always_inline)) { return entries[x]; @@ -422,7 +425,7 @@ public: { return entries[x]; } - + inline CHSV& operator[] (int x) __attribute__((always_inline)) { return entries[(uint8_t)x]; @@ -431,12 +434,12 @@ public: { return entries[(uint8_t)x]; } - + operator CHSV*() { return &(entries[0]); } - + CHSVPalette16( const CHSV& c1) { fill_solid( &(entries[0]), 16, c1); @@ -453,7 +456,7 @@ public: { fill_gradient( &(entries[0]), 16, c1, c2, c3, c4); } - + }; class CHSVPalette256 { @@ -469,7 +472,7 @@ public: c08,c09,c10,c11,c12,c13,c14,c15); *this = p16; }; - + CHSVPalette256( const CHSVPalette256& rhs) { memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); @@ -479,7 +482,7 @@ public: memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); return *this; } - + CHSVPalette256( const CHSVPalette16& rhs16) { UpscalePalette( rhs16, *this); @@ -489,7 +492,7 @@ public: UpscalePalette( rhs16, *this); return *this; } - + CHSVPalette256( const TProgmemRGBPalette16& rhs) { CHSVPalette16 p16(rhs); @@ -501,7 +504,7 @@ public: *this = p16; return *this; } - + inline CHSV& operator[] (uint8_t x) __attribute__((always_inline)) { return entries[x]; @@ -510,7 +513,7 @@ public: { return entries[x]; } - + inline CHSV& operator[] (int x) __attribute__((always_inline)) { return entries[(uint8_t)x]; @@ -524,7 +527,7 @@ public: { return &(entries[0]); } - + CHSVPalette256( const CHSV& c1) { fill_solid( &(entries[0]), 256, c1); @@ -557,7 +560,7 @@ public: entries[8]=c08; entries[9]=c09; entries[10]=c10; entries[11]=c11; entries[12]=c12; entries[13]=c13; entries[14]=c14; entries[15]=c15; }; - + CRGBPalette16( const CRGBPalette16& rhs) { memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); @@ -567,13 +570,13 @@ public: memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); return *this; } - + CRGBPalette16( const CHSVPalette16& rhs) { for( uint8_t i = 0; i < 16; i++) { entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion } - } + } CRGBPalette16& operator=( const CHSVPalette16& rhs) { for( uint8_t i = 0; i < 16; i++) { @@ -595,7 +598,7 @@ public: } return *this; } - + inline CRGB& operator[] (uint8_t x) __attribute__((always_inline)) { return entries[x]; @@ -604,7 +607,7 @@ public: { return entries[x]; } - + inline CRGB& operator[] (int x) __attribute__((always_inline)) { return entries[(uint8_t)x]; @@ -613,12 +616,12 @@ public: { return entries[(uint8_t)x]; } - + operator CRGB*() { return &(entries[0]); } - + CRGBPalette16( const CHSV& c1) { fill_solid( &(entries[0]), 16, c1); @@ -635,7 +638,7 @@ public: { fill_gradient( &(entries[0]), 16, c1, c2, c3, c4); } - + CRGBPalette16( const CRGB& c1) { fill_solid( &(entries[0]), 16, c1); @@ -652,7 +655,7 @@ public: { fill_gradient_RGB( &(entries[0]), 16, c1, c2, c3, c4); } - + }; @@ -669,7 +672,7 @@ public: c08,c09,c10,c11,c12,c13,c14,c15); *this = p16; }; - + CRGBPalette256( const CRGBPalette256& rhs) { memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); @@ -679,7 +682,7 @@ public: memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); return *this; } - + CRGBPalette256( const CHSVPalette256& rhs) { for( int i = 0; i < 256; i++) { @@ -703,7 +706,7 @@ public: UpscalePalette( rhs16, *this); return *this; } - + CRGBPalette256( const TProgmemRGBPalette16& rhs) { CRGBPalette16 p16(rhs); @@ -715,7 +718,7 @@ public: *this = p16; return *this; } - + inline CRGB& operator[] (uint8_t x) __attribute__((always_inline)) { return entries[x]; @@ -724,7 +727,7 @@ public: { return entries[x]; } - + inline CRGB& operator[] (int x) __attribute__((always_inline)) { return entries[(uint8_t)x]; @@ -738,7 +741,7 @@ public: { return &(entries[0]); } - + CRGBPalette256( const CHSV& c1) { fill_solid( &(entries[0]), 256, c1); @@ -755,7 +758,7 @@ public: { fill_gradient( &(entries[0]), 256, c1, c2, c3, c4); } - + CRGBPalette256( const CRGB& c1) { fill_solid( &(entries[0]), 256, c1); @@ -772,7 +775,7 @@ public: { fill_gradient_RGB( &(entries[0]), 256, c1, c2, c3, c4); } - + }; @@ -807,7 +810,7 @@ CHSV ColorFromPalette( const CHSVPalette256& pal, // Fill a range of LEDs with a sequece of entryies from a palette -template <typename PALETTE> +template <typename PALETTE> void fill_palette(CRGB* L, uint16_t N, uint8_t startIndex, uint8_t incIndex, const PALETTE& pal, uint8_t brightness, TBlendType blendType) { @@ -819,12 +822,12 @@ void fill_palette(CRGB* L, uint16_t N, uint8_t startIndex, uint8_t incIndex, } template <typename PALETTE> -void map_data_into_colors_through_palette( - uint8_t *dataArray, uint16_t dataCount, - CRGB* targetColorArray, - const PALETTE& pal, - uint8_t brightness=255, - uint8_t opacity=255, +void map_data_into_colors_through_palette( + uint8_t *dataArray, uint16_t dataCount, + CRGB* targetColorArray, + const PALETTE& pal, + uint8_t brightness=255, + uint8_t opacity=255, TBlendType blendType=BLEND) { for( uint16_t i = 0; i < dataCount; i++) { @@ -876,4 +879,7 @@ void nblendPaletteTowardPalette( CRGBPalette16& currentPalette, CRGBPalette16& targetPalette, uint8_t maxChanges=24); + +FASTLED_NAMESPACE_END + #endif diff --git a/controller.h b/controller.h index ace0d888..763075e3 100644 --- a/controller.h +++ b/controller.h @@ -5,6 +5,8 @@ #include "pixeltypes.h" #include "color.h" +FASTLED_NAMESPACE_BEGIN + #define RO(X) RGB_BYTE(RGB_ORDER, X) #define RGB_BYTE(RO,X) (((RO)>>(3*(2-(X)))) & 0x3) @@ -541,4 +543,6 @@ struct MultiPixelController { __attribute__((always_inline)) inline uint8_t stepAdvanceAndLoadAndScale0(int lane) { stepDithering(); return advanceAndLoadAndScale<0>(*this, lane); } }; +FASTLED_NAMESPACE_END + #endif @@ -1,6 +1,8 @@ #ifndef __INC_DELAY_H #define __INC_DELAY_H +FASTLED_NAMESPACE_BEGIN + // Class to ensure that a minimum amount of time has kicked since the last time run - and delay if not enough time has passed yet // this should make sure that chipsets that have template<int WAIT> class CMinWait { @@ -112,5 +114,6 @@ template<> __attribute__((always_inline)) inline void delaycycles<5>() {NOP2;NOP // Macro for making sure there's enough time available #define NO_TIME(A, B, C) (NS(A) < 3 || NS(B) < 3 || NS(C) < 6) +FASTLED_NAMESPACE_END #endif @@ -6,6 +6,8 @@ #include<DmxSimple.h> #define HAS_DMX_SIMPLE +FASTLED_NAMESPACE_BEGIN + // note - dmx simple must be included before FastSPI for this code to be enabled template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB> class DMXSimpleController : public CLEDController { public: @@ -49,11 +51,15 @@ protected: #endif }; +FASTLED_NAMESPACE_END + #endif #ifdef DmxSerial_h #include<DMXSerial.h> +FASTLED_NAMESPACE_BEGIN + template <EOrder RGB_ORDER = RGB> class DMXSerialController : public CLEDController { public: // initialize the LED controller @@ -94,6 +100,9 @@ public: virtual void show(const struct CARGB *data, int nLeds, uint8_t scale = 255) = 0; #endif }; + +FASTLED_NAMESPACE_END + #define HAS_DMX_SERIAL #endif @@ -3,6 +3,8 @@ #include "led_sysdefs.h" +FASTLED_NAMESPACE_BEGIN + #define NO_PIN 255 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -18,7 +20,7 @@ public: virtual bool isSelected() = 0; }; -#if defined(ARDUINO) +#if !defined(FASTLED_NO_PINMAP) class Pin : public Selectable { volatile RwReg *mPort; @@ -72,6 +74,66 @@ public: InputPin(int pin) : Pin(pin) { setInput(); } }; +#else +// This is the empty code version of the raw pin class, method bodies should be filled in to Do The Right Thing[tm] when making this +// available on a new platform +class Pin : public Selectable { + volatile RwReg *mPort; + volatile RoReg *mInPort; + RwReg mPinMask; + uint8_t mPin; + + void _init() { + // TODO: fill in init on a new platform + mPinMask = 0; + mPort = NULL; + mInPort = NULL; + } +public: + Pin(int pin) : mPin(pin) { _init(); } + + void setPin(int pin) { mPin = pin; _init(); } + + typedef volatile RwReg * port_ptr_t; + typedef RwReg port_t; + + inline void setOutput() { /* TODO: Set pin output */ } + inline void setInput() { /* TODO: Set pin input */ } + + inline void hi() __attribute__ ((always_inline)) { *mPort |= mPinMask; } + inline void lo() __attribute__ ((always_inline)) { *mPort &= ~mPinMask; } + + inline void strobe() __attribute__ ((always_inline)) { toggle(); toggle(); } + inline void toggle() __attribute__ ((always_inline)) { *mInPort = mPinMask; } + + inline void hi(register port_ptr_t port) __attribute__ ((always_inline)) { *port |= mPinMask; } + inline void lo(register port_ptr_t port) __attribute__ ((always_inline)) { *port &= ~mPinMask; } + inline void set(register port_t val) __attribute__ ((always_inline)) { *mPort = val; } + + inline void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port = val; } + + port_t hival() __attribute__ ((always_inline)) { return *mPort | mPinMask; } + port_t loval() __attribute__ ((always_inline)) { return *mPort & ~mPinMask; } + port_ptr_t port() __attribute__ ((always_inline)) { return mPort; } + port_t mask() __attribute__ ((always_inline)) { return mPinMask; } + + virtual void select() { hi(); } + virtual void release() { lo(); } + virtual bool isSelected() { return (*mPort & mPinMask) == mPinMask; } +}; + +class OutputPin : public Pin { +public: + OutputPin(int pin) : Pin(pin) { setOutput(); } +}; + +class InputPin : public Pin { +public: + InputPin(int pin) : Pin(pin) { setInput(); } +}; + +#endif + /// The simplest level of Pin class. This relies on runtime functions durinig initialization to get the port/pin mask for the pin. Most /// of the accesses involve references to these static globals that get set up. This won't be the fastest set of pin operations, but it /// will provide pin level access on pretty much all arduino environments. In addition, it includes some methods to help optimize access in @@ -91,9 +153,11 @@ template<uint8_t PIN> class FastPin { static volatile RwReg *sPort; static volatile RoReg *sInPort; static void _init() { + #if !defined(FASTLED_NO_PINMAP) sPinMask = digitalPinToBitMask(PIN); sPort = portOutputRegister(digitalPinToPort(PIN)); sInPort = portInputRegister(digitalPinToPort(PIN)); + #endif } public: typedef volatile RwReg * port_ptr_t; @@ -126,11 +190,10 @@ template<uint8_t PIN> volatile RwReg *FastPin<PIN>::sPort; template<uint8_t PIN> volatile RoReg *FastPin<PIN>::sInPort; template<uint8_t PIN> class FastPinBB : public FastPin<PIN> {}; -#endif // defined(ARDUINO) typedef volatile uint32_t & reg32_t; typedef volatile uint32_t * ptr_reg32_t; - +FASTLED_NAMESPACE_END #endif // __INC_FASTPIN_H @@ -6,6 +6,8 @@ #include "fastspi_bitbang.h" +FASTLED_NAMESPACE_BEGIN + #if (CLK_DBL == 1) #define DATA_RATE_MHZ(X) (((F_CPU / 1000000L) / X)/2) #define DATA_RATE_KHZ(X) (((F_CPU / 1000L) / X)/2) @@ -92,4 +94,6 @@ class SPIOutput<SPI_UART1_DATA, SPI_UART1_CLOCK, SPI_SPEED> : public AVRUSART1SP #warning "Forcing software SPI - no hardware SPI for you!" #endif +FASTLED_NAMESPACE_END + #endif diff --git a/fastspi_bitbang.h b/fastspi_bitbang.h index 4da32f63..db162f2b 100644 --- a/fastspi_bitbang.h +++ b/fastspi_bitbang.h @@ -1,6 +1,8 @@ #ifndef __INC_FASTSPI_BITBANG_H #define __INC_FASTSPI_BITBANG_H +FASTLED_NAMESPACE_BEGIN + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Software SPI (aka bit-banging) support - with aggressive optimizations for when the clock and data pin are on the same port @@ -345,4 +347,6 @@ public: } }; +FASTLED_NAMESPACE_END + #endif diff --git a/fastspi_nop.h b/fastspi_nop.h index e9cd4aa7..5b2984ce 100644 --- a/fastspi_nop.h +++ b/fastspi_nop.h @@ -1,6 +1,8 @@ #ifndef __INC_FASTSPI_NOP_H #define __INC_FASTSPI_NOP_H +FASTLED_NAMESPACE_BEGIN + // A nop/stub class, mostly to show the SPI methods that are needed/used by the various SPI chipset implementations. Should // be used as a definition for the set of methods that the spi implementation classes should use (since C++ doesn't support the // idea of interfaces - it's possible this could be done with virtual classes, need to decide if i want that overhead) @@ -51,4 +53,6 @@ public: }; +FASTLED_NAMESPACE_END + #endif diff --git a/fastspi_ref.h b/fastspi_ref.h index 709bec34..a2bbd70d 100644 --- a/fastspi_ref.h +++ b/fastspi_ref.h @@ -1,6 +1,8 @@ #ifndef __INC_FASTSPI_ARM_SAM_H #define __INC_FASTSPI_ARM_SAM_H +FASTLED_NAMESPACE_BEGIN + // A skeletal implementation of hardware SPI support. Fill in the necessary code for init, waiting, and writing. The rest of // the method implementations should provide a starting point, even if not hte most efficient to start with template <uint8_t _DATA_PIN, uint8_t _CLOCK_PIN, uint8_t _SPI_CLOCK_DIVIDER> @@ -95,4 +97,6 @@ public: }; -#endif
\ No newline at end of file +FASTLED_NAMESPACE_END + +#endif diff --git a/fastspi_types.h b/fastspi_types.h index e0de6de3..6fbb7e3e 100644 --- a/fastspi_types.h +++ b/fastspi_types.h @@ -1,6 +1,8 @@ #ifndef __INC_FASTSPI_TYPES_H #define __INC_FASTSPI_TYPES_H +FASTLED_NAMESPACE_BEGIN + // Some helper macros for getting at mis-ordered byte values #define SPI_B0 (RGB_BYTE0(RGB_ORDER) + (MASK_SKIP_BITS & SKIP)) #define SPI_B1 (RGB_BYTE1(RGB_ORDER) + (MASK_SKIP_BITS & SKIP)) @@ -34,4 +36,6 @@ public: #define MAX_DATA_RATE 0 +FASTLED_NAMESPACE_END + #endif diff --git a/hsv2rgb.cpp b/hsv2rgb.cpp index a1c713b1..6690e980 100644 --- a/hsv2rgb.cpp +++ b/hsv2rgb.cpp @@ -3,6 +3,8 @@ #include "FastLED.h" +FASTLED_USING_NAMESPACE + // Functions to convert HSV colors to RGB colors. // // The basically fall into two groups: spectra, and rainbows. @@ -3,6 +3,7 @@ #include "pixeltypes.h" +FASTLED_NAMESPACE_BEGIN // hsv2rgb_rainbow - convert a hue, saturation, and value to RGB // using a visually balanced rainbow (vs a straight @@ -83,4 +84,6 @@ void hsv2rgb_raw(const struct CHSV* phsv, struct CRGB * prgb, int numLeds); // CHSV rgb2hsv_approximate( const CRGB& rgb); +FASTLED_NAMESPACE_END + #endif diff --git a/led_sysdefs.h b/led_sysdefs.h index 1605ef5c..bf563899 100644 --- a/led_sysdefs.h +++ b/led_sysdefs.h @@ -12,15 +12,23 @@ #elif defined(__SAM3X8E__) // Include sam/due headers #include "platforms/arm/sam/led_sysdefs_arm_sam.h" +#elif defined(STM32F10X_MD) +#include "platforms/arm/stm32/led_sysdefs_arm_stm32.h" #else // AVR platforms #include "platforms/avr/led_sysdefs_avr.h" #endif - +#ifndef FASTLED_NAMESPACE_BEGIN +#define FASTLED_NAMESPACE_BEGIN +#define FASTLED_NAMESPACE_END +#define FASTLED_USING_NAMESPACE +#endif // Arduino.h needed for convinience functions digitalPinToPort/BitMask/portOutputRegister and the pinMode methods. +#ifdef ARDUINO #include<Arduino.h> +#endif #define CLKS_PER_US (F_CPU/1000000) diff --git a/lib8tion.cpp b/lib8tion.cpp index 84bcafdb..1b42bf5d 100644 --- a/lib8tion.cpp +++ b/lib8tion.cpp @@ -1,6 +1,8 @@ #define FASTLED_INTERNAL #include <stdint.h> +FASTLED_USING_NAMESPACE + #define RAND16_SEED 1337 uint16_t rand16seed = RAND16_SEED; @@ -5,6 +5,8 @@ #ifndef __INC_LIB8TION_H #define __INC_LIB8TION_H +FASTLED_NAMESPACE_BEGIN + /* Fast, efficient 8-bit math functions specifically @@ -2112,4 +2114,6 @@ typedef CEveryNTimePeriods<uint8_t,hours8> CEveryNHours; #define CEveryNMilliseconds CEveryNMillis #define EVERY_N_MILLISECONDS(N) EVERY_N_MILLIS(N) +FASTLED_NAMESPACE_END + #endif @@ -6,6 +6,8 @@ #define USE_PROGMEM #endif +FASTLED_USING_NAMESPACE + // Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734 #ifdef FASTLED_AVR #ifdef PROGMEM @@ -1,6 +1,8 @@ #ifndef __INC_NOISE_H #define __INC_NOISE_H +FASTLED_NAMESPACE_BEGIN + #if 0 /// Class for accessing 16 bit noise. Provides methods for setting origin, scale, /// frequency, alplitude, time, octave blurring @@ -113,4 +115,6 @@ void fill_2dnoise16(CRGB *leds, int width, int height, bool serpentine, uint8_t octaves, uint32_t x, int xscale, uint32_t y, int yscale, uint32_t time, uint8_t hue_octaves, uint16_t hue_x, int hue_xscale, uint16_t hue_y, uint16_t hue_yscale,uint16_t hue_time, bool blend, uint16_t hue_shift=0); +FASTLED_NAMESPACE_END + #endif diff --git a/pixeltypes.h b/pixeltypes.h index 3c583a42..fa4e36f8 100644 --- a/pixeltypes.h +++ b/pixeltypes.h @@ -5,6 +5,8 @@ #include "lib8tion.h" #include "color.h" +FASTLED_NAMESPACE_BEGIN + struct CRGB; struct CHSV; @@ -811,5 +813,6 @@ enum EOrder { BGR=0210 }; +FASTLED_NAMESPACE_END #endif diff --git a/platforms.h b/platforms.h index b414dfbc..3fd1b443 100644 --- a/platforms.h +++ b/platforms.h @@ -12,6 +12,8 @@ #elif defined(__SAM3X8E__) // Include sam/due headers #include "platforms/arm/sam/fastled_arm_sam.h" +#elif defined(STM32F10X_MD) +#include "platforms/arm/stm32/fastled_arm_stm32.h" #else // AVR platforms #include "platforms/avr/fastled_avr.h" diff --git a/power_mgt.cpp b/power_mgt.cpp index c9367147..1d6ca9dc 100644 --- a/power_mgt.cpp +++ b/power_mgt.cpp @@ -2,6 +2,8 @@ #include "FastLED.h" #include "power_mgt.h" +FASTLED_USING_NAMESPACE + //// POWER MANAGEMENT // These power usage values are approximate, and your exact readings diff --git a/power_mgt.h b/power_mgt.h index 60b92e95..8f2b2231 100644 --- a/power_mgt.h +++ b/power_mgt.h @@ -3,6 +3,8 @@ #include "pixeltypes.h" +FASTLED_NAMESPACE_BEGIN + // Power Control setup functions // // Example: @@ -43,6 +45,8 @@ uint32_t calculate_unscaled_power_mW( const CRGB* ledbuffer, uint16_t numLeds); uint8_t calculate_max_brightness_for_power_mW( uint8_t target_brightness, uint32_t max_power_mW); +FASTLED_NAMESPACE_END // POWER_MGT_H + #endif @@ -1,6 +1,8 @@ #define FASTLED_INTERNAL #include "FastLED.h" +FASTLED_USING_NAMESPACE + #if 0 #if defined(FASTLED_AVR) && !defined(TEENSYDUINO) && !defined(LIB8_ATTINY) |