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

◆ mapNoiseToLEDsUsingPalette()

void mapNoiseToLEDsUsingPalette ( )
Examples
NoisePlusPalette.ino.

Definition at line 148 of file NoisePlusPalette.ino.

149{
150 static uint8_t ihue=0;
151
152 for(int i = 0; i < kMatrixWidth; i++) {
153 for(int j = 0; j < kMatrixHeight; j++) {
154 // We use the value at the (i,j) coordinate in the noise
155 // array for our brightness, and the flipped value from (j,i)
156 // for our pixel's index into the color palette.
157
158 uint8_t index = noise[j][i];
159 uint8_t bri = noise[i][j];
160
161 // if this palette is a 'loop', add a slowly-changing base value
162 if( colorLoop) {
163 index += ihue;
164 }
165
166 // brighten up, as the color palette itself often contains the
167 // light/dark dynamic range desired
168 if( bri > 127 ) {
169 bri = 255;
170 } else {
171 bri = dim8_raw( bri * 2);
172 }
173
174 CRGB color = ColorFromPalette( currentPalette, index, bri);
175 leds[XY(i,j)] = color;
176 }
177 }
178
179 ihue+=1;
180}
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
CRGBPalette16 currentPalette
uint8_t noise[NUM_LAYERS][WIDTH][HEIGHT]
Definition Fire2023.ino:86
uint8_t colorLoop
#define kMatrixHeight
#define kMatrixWidth
uint16_t XY(uint8_t x, uint8_t y)
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.
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54

References ColorFromPalette(), colorLoop, currentPalette, dim8_raw(), kMatrixHeight, kMatrixWidth, leds, noise, and XY().

Referenced by fl::NoisePalette::draw(), and loop().

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