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

◆ rainbowWave()

void rainbowWave ( )

Definition at line 93 of file ColorBoost.h.

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

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

Referenced by loop().

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