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

◆ rainbowWave()

void rainbowWave ( )

Definition at line 98 of file ColorBoost.h.

98 {
99 // Use millis() for consistent timing across different devices
100 // Scale down millis() to get appropriate animation speed
101 uint16_t time = millis() / 16; // Adjust divisor to control wave speed
102 uint8_t hueOffset = millis() / 32; // Adjust divisor to control hue rotation speed
103
104 // Iterate through the entire 100x100 matrix
105 for (uint16_t y = 0; y < NUM_STRIPS; y++) {
106 for (uint16_t x = 0; x < NUM_LEDS_PER_STRIP; x++) {
107 // Create a wave pattern using sine function based on position and
108 // time
109 uint8_t wave = sin8(time + (x * 8));
110
111 // Calculate hue based on position and time for rainbow effect
112 uint8_t hue = hueOffset + (x * 255 / NUM_LEDS_PER_STRIP);
113
114 // Use wave for both saturation and brightness variation
115 // uint8_t sat = 255 - (wave / 4); // Subtle saturation variation
116 uint8_t bri = 128 + (wave / 2); // Brightness wave from 128 to 255
117
118 // Create the original color using HSV
119 CRGB original_color = CHSV(hue, satSlider.value(), bri);
120
121 // Upper half (rows 0-49): original colors
122 // Lower half (rows 50-99): transformed colors using
123 // toVideoRGB_8bit()
124 if (y > NUM_STRIPS / 3 * 2) {
125 // Upper half - original colors
126 leds[xyMap(x, y)] = original_color;
127 } else if (y > NUM_STRIPS / 3) {
128 // Middle half - transformed colors
129 EaseType sat_ease = getEaseType(saturationFunction.as_int());
130 EaseType lum_ease = getEaseType(luminanceFunction.as_int());
131 leds[xyMap(x, y)] = original_color.colorBoost(sat_ease, lum_ease);
132 } else {
133 // Lower half - transformed colors
134 float r = original_color.r / 255.f;
135 float g = original_color.g / 255.f;
136 float b = original_color.b / 255.f;
137
138 r = pow(r, 2.0);
139 g = pow(g, 2.0);
140 b = pow(b, 2.0);
141
142 r = r * 255.f;
143 g = g * 255.f;
144 b = b * 255.f;
145
146 leds[xyMap(x, y)] = CRGB(r, g, b);
147 }
148 }
149 }
150}
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)
#define NUM_LEDS_PER_STRIP
Definition ColorBoost.h:51
#define NUM_STRIPS
Definition ColorBoost.h:52
fl::XYMap xyMap
Definition ColorBoost.h:61
EaseType getEaseType(int value)
Definition ColorBoost.h:80
UIDropdown luminanceFunction("Luminance Function", easeOptions)
UIDropdown saturationFunction("Saturation Function", easeOptions)
#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(), hue, leds, luminanceFunction(), NUM_LEDS_PER_STRIP, NUM_STRIPS, satSlider(), saturationFunction(), sin8, fl::time(), x, xyMap, and y.

Referenced by loop().

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