FastLED 3.9.15
Loading...
Searching...
No Matches

◆ rainbowWave()

void rainbowWave ( )

Definition at line 95 of file ColorBoost.h.

95 {
96 // Use millis() for consistent timing across different devices
97 // Scale down millis() to get appropriate animation speed
98 uint16_t time = millis() / 16; // Adjust divisor to control wave speed
99 uint8_t hueOffset = millis() / 32; // Adjust divisor to control hue rotation speed
100
101 // Iterate through the entire matrix
102 for (uint16_t y = 0; y < HEIGHT; y++) {
103 for (uint16_t x = 0; x < WIDTH; x++) {
104 // Create a wave pattern using sine function based on position and time
105 uint8_t wave = sin8(time + (x * 8));
106
107 // Calculate hue based on position and time for rainbow effect
108 uint8_t hue = hueOffset + (x * 255 / WIDTH);
109
110 // Use wave for both saturation and brightness variation
111 // uint8_t sat = 255 - (wave / 4); // Subtle saturation variation
112 uint8_t bri = 128 + (wave / 2); // Brightness wave from 128 to 255
113
114 // Create the original color using HSV
115 CRGB original_color = CHSV(hue, satSlider.value(), bri);
116
117 if (y > HEIGHT / 3 * 2) {
118 // Upper third - original colors
119 leds[xyMap(x, y)] = original_color;
120 } else if (y > HEIGHT / 3) {
121 // Middle third - colors transformed with colorBoost()
122 EaseType sat_ease = getEaseType(saturationFunction.as_int());
123 EaseType lum_ease = getEaseType(luminanceFunction.as_int());
124 leds[xyMap(x, y)] = original_color.colorBoost(sat_ease, lum_ease);
125 } else {
126 // Lower third - colors transformed using gamma correction
127 float r = original_color.r / 255.f;
128 float g = original_color.g / 255.f;
129 float b = original_color.b / 255.f;
130
131 r = pow(r, 2.0);
132 g = pow(g, 2.0);
133 b = pow(b, 2.0);
134
135 r = r * 255.f;
136 g = g * 255.f;
137 b = b * 255.f;
138
139 leds[xyMap(x, y)] = CRGB(r, g, b);
140 }
141 }
142 }
143}
CRGB leds[NUM_LEDS]
uint8_t hue
int y
Definition simple.h:93
int x
Definition simple.h:92
UISlider satSlider("Saturation", 60, 0, 255, 1)
fl::XYMap xyMap
Definition ColorBoost.h:57
EaseType getEaseType(int value)
Definition ColorBoost.h:74
UIDropdown luminanceFunction("Luminance Function", easeOptions)
UIDropdown saturationFunction("Saturation Function", easeOptions)
#define WIDTH
Definition advanced.h:34
#define HEIGHT
Definition advanced.h:35
#define sin8
Platform-independent alias of the fast sin implementation.
Definition trig8.h:230
fl::u32 time()
Universal millisecond timer - returns milliseconds since system startup.
Definition time.cpp:136
EaseType
Definition ease.h:21
CRGB colorBoost(fl::EaseType saturation_function=fl::EASE_NONE, fl::EaseType luminance_function=fl::EASE_NONE) const
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:86
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Definition hsv.h:15

References CRGB::colorBoost(), getEaseType(), HEIGHT, hue, leds, luminanceFunction(), satSlider(), saturationFunction(), sin8, fl::time(), WIDTH, x, xyMap, and y.

Referenced by loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: