Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FastLED/FastLED.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kriegsman <kriegsman@tr.org>2015-12-29 08:12:29 +0300
committerMark Kriegsman <kriegsman@tr.org>2015-12-29 08:12:29 +0300
commit0f726f72037d2c296a79818d8aec7050ec6d4e33 (patch)
tree543e16a3e4754c95638e5adfd59f81e4d79b3b7c /noise.cpp
parent43db133bb83e9238e96f7479b96d4edd937e5a80 (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.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/noise.cpp b/noise.cpp
index 4d2dbcef..49aa6e7c 100644
--- a/noise.cpp
+++ b/noise.cpp
@@ -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: