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

◆ mapNoiseToLEDsUsingPalette()

void fl::NoisePalette::mapNoiseToLEDsUsingPalette ( CRGB * leds)

Definition at line 109 of file noisepalette.cpp.

109 {
110 static uint8_t ihue = 0;
111
112 for (uint16_t i = 0; i < width; i++) {
113 for (uint16_t j = 0; j < height; j++) {
114 // We use the value at the (i,j) coordinate in the noise
115 // array for our brightness, and the flipped value from (j,i)
116 // for our pixel's index into the color palette.
117
118 uint8_t index = noise.get()[i * height + j];
119 uint8_t bri = noise.get()[j * width + i];
120
121 // if this palette is a 'loop', add a slowly-changing base value
122 if (colorLoop) {
123 index += ihue;
124 }
125
126 // brighten up, as the color palette itself often contains the
127 // light/dark dynamic range desired
128 if (bri > 127) {
129 bri = 255;
130 } else {
131 bri = dim8_raw(bri * 2);
132 }
133
134 CRGB color = ColorFromPalette(currentPalette, index, bri);
135 leds[XY(i, j)] = color;
136 }
137 }
138
139 ihue += 1;
140}
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
CRGBPalette16 currentPalette
uint16_t XY(uint8_t x, uint8_t y) const
fl::scoped_array< uint8_t > noise
LIB8STATIC uint8_t dim8_raw(uint8_t x)
Adjust a scaling value for dimming.
Definition scale8.h:703
CRGB ColorFromPalette(const CRGBPalette16 &pal, uint8_t index, uint8_t brightness, TBlendType blendType)
Get a color from a palette.

References ColorFromPalette(), colorLoop, currentPalette, dim8_raw(), height, leds, noise, width, and XY().

+ Here is the call graph for this function: