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

◆ showGenerative()

void showGenerative ( )

Definition at line 156 of file FestivalStick.ino.

156 {
157 // This function is called to show the generative pattern
158 uint32_t now = millis();
160
161 for (int i = 0; i < NUM_LEDS; i++) {
162 // Get the 2D position of this LED from the screen map
164 float x = pos.x;
165 float y = pos.y;
166 float z = pos.z;
167
168 x*= 20.0f * ledsScale.value();
169 y*= 20.0f * ledsScale.value();
170 z*= 20.0f * ledsScale.value();
171
172 uint16_t noise_value = inoise16(x,y,z, now / 100);
173 // Normalize the noise value to 0-255
174 uint8_t brightness = map(noise_value, 0, 65535, 0, 255);
175 // Create a hue that changes with position and time
176 uint8_t sat = int32_t((x * 10 + y * 5 + now / 5)) % 256;
177 // Set the color
178 leds[i] = CHSV(170, sat, fl::clamp(255- sat, 64, 255));
179 }
180
181 FastLED.show();
182}
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
#define NUM_LEDS
Definition Apa102.ino:6
int y
Definition Audio.ino:72
int x
Definition Audio.ino:71
uint8_t pos
Definition Blur.ino:11
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:58
UISlider ledsScale("Leds scale", 0.1f, 0.1f, 1.0f, 0.01f)
fl::vector< vec3f > mapCorkScrew
uint32_t z[NUM_LAYERS]
Definition Fire2023.ino:84
UISlider brightness("Brightness", 255, 0, 255, 1)
uint16_t inoise16(uint32_t x, uint32_t y, uint32_t z, uint32_t t)
16-bit, fixed point implementation of Perlin's noise.
Definition noise.cpp:440
long map(long x, long in_min, long in_max, long out_min, long out_max)
void clear(CRGB(&arr)[N])
Definition clear.h:8
FASTLED_FORCE_INLINE T clamp(T value, T min, T max)
Definition clamp.h:10
vec3< float > vec3f
Definition geometry.h:156
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Definition chsv.h:16

References brightness, fl::clamp(), fl::clear(), FastLED, inoise16(), leds, ledsScale, mapCorkScrew, NUM_LEDS, pos, x, y, and z.

Referenced by loop().

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