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

◆ mapNoiseToLEDsUsingPalette()

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

Definition at line 108 of file noisepalette.cpp.

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

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

+ Here is the call graph for this function: