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:
Diffstat (limited to 'src/colorutils.cpp')
-rw-r--r--src/colorutils.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/colorutils.cpp b/src/colorutils.cpp
index a1acaa5a..941f4686 100644
--- a/src/colorutils.cpp
+++ b/src/colorutils.cpp
@@ -62,6 +62,47 @@ void fill_rainbow( struct CHSV * targetArray, int numToFill,
}
+void fill_rainbow_circular(struct CRGB* targetArray, int numToFill, uint8_t initialhue, bool reversed)
+{
+ if (numToFill == 0) return; // avoiding div/0
+
+ CHSV hsv;
+ hsv.hue = initialhue;
+ hsv.val = 255;
+ hsv.sat = 240;
+
+ const uint16_t hueChange = 65535 / (uint16_t)numToFill; // hue change for each LED, * 256 for precision (256 * 256 - 1)
+ uint16_t hueOffset = 0; // offset for hue value, with precision (*256)
+
+ for (int i = 0; i < numToFill; ++i) {
+ targetArray[i] = hsv;
+ if (reversed) hueOffset -= hueChange;
+ else hueOffset += hueChange;
+ hsv.hue = initialhue + (uint8_t)(hueOffset >> 8); // assign new hue with precise offset (as 8-bit)
+ }
+}
+
+void fill_rainbow_circular(struct CHSV* targetArray, int numToFill, uint8_t initialhue, bool reversed)
+{
+ if (numToFill == 0) return; // avoiding div/0
+
+ CHSV hsv;
+ hsv.hue = initialhue;
+ hsv.val = 255;
+ hsv.sat = 240;
+
+ const uint16_t hueChange = 65535 / (uint16_t) numToFill; // hue change for each LED, * 256 for precision (256 * 256 - 1)
+ uint16_t hueOffset = 0; // offset for hue value, with precision (*256)
+
+ for (int i = 0; i < numToFill; ++i) {
+ targetArray[i] = hsv;
+ if (reversed) hueOffset -= hueChange;
+ else hueOffset += hueChange;
+ hsv.hue = initialhue + (uint8_t)(hueOffset >> 8); // assign new hue with precise offset (as 8-bit)
+ }
+}
+
+
void fill_gradient_RGB( CRGB* leds,
uint16_t startpos, CRGB startcolor,
uint16_t endpos, CRGB endcolor )