diff options
author | Mark Kriegsman <kriegsman@tr.org> | 2015-12-29 08:12:29 +0300 |
---|---|---|
committer | Mark Kriegsman <kriegsman@tr.org> | 2015-12-29 08:12:29 +0300 |
commit | 0f726f72037d2c296a79818d8aec7050ec6d4e33 (patch) | |
tree | 543e16a3e4754c95638e5adfd59f81e4d79b3b7c /noise.cpp | |
parent | 43db133bb83e9238e96f7479b96d4edd937e5a80 (diff) |
Noise behavior can be reverted for backward-stability of animation design with #define FASTLED_NOISE_ALLOW_AVERAGE_TO_OVERFLOW 1
placed BEFORE the #include of FastLED.h
Diffstat (limited to 'noise.cpp')
-rw-r--r-- | noise.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -20,6 +20,13 @@ FL_PROGMEM static uint8_t const p[] = { 151,160,137,91,90,15, 138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180,151 }; + +#if FASTLED_NOISE_ALLOW_AVERAGE_TO_OVERFLOW == 1 +#define AVG15(U,V) (((U)+(V)) >> 1) +#else +#define AVG15(U,V) (avg15((U),(V))) +#endif + // // #define FADE_12 #define FADE_16 @@ -58,7 +65,7 @@ static int16_t inline __attribute__((always_inline)) grad16(uint8_t hash, int16 if(hash&1) { u = -u; } if(hash&2) { v = -v; } - return avg15(u,v); + return AVG15(u,v); #endif } @@ -69,7 +76,7 @@ static int16_t inline __attribute__((always_inline)) grad16(uint8_t hash, int16_ if(hash&1) { u = -u; } if(hash&2) { v = -v; } - return avg15(u,v); + return AVG15(u,v); } static int16_t inline __attribute__((always_inline)) grad16(uint8_t hash, int16_t x) { @@ -81,7 +88,7 @@ static int16_t inline __attribute__((always_inline)) grad16(uint8_t hash, int16_ if(hash&1) { u = -u; } if(hash&2) { v = -v; } - return avg15(u,v); + return AVG15(u,v); } // selectBasedOnHashBit performs this: |