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

◆ draw()

void draw ( uint32_t now)

Definition at line 76 of file FxNoiseRing.ino.

76 {
77 double angle_offset = double(now) / 32000.0 * 2 * FL_M_PI;
78 now = (now << timeBitshift.as<int>()) * timescale.as<double>();
79
80 // get radius/zoom level from slider
81 float noise_radius = scale.as<float>();
82
83 // go in circular formation and set the leds
84 for (int i = 0; i < NUM_LEDS; i++) {
85 float angle = i * 2 * FL_M_PI / NUM_LEDS + angle_offset;
86
87 // Use the new noiseRingHSV8 function to sample three z-slices for HSV components
88 CHSV hsv = fl::noiseRingHSV8(angle, now, noise_radius);
89
90 // Apply same constraints as before: minimum saturation and adjusted value
91 hsv.s = fl::max(128u, (unsigned)hsv.s);
92 // Apply value mapping similar to original: map from 0-255 to -64-255, clamp to 0-255
93 uint16_t val = hsv.v;
94 int16_t adjusted_val = map(val, 0, 255, -64, 255);
95 if (adjusted_val < 0) {
96 adjusted_val = 0;
97 }
98 hsv.v = adjusted_val;
99
100 leds[i] = hsv;
101 }
102}
#define NUM_LEDS
fl::CRGB leds[NUM_LEDS]
fl::UISlider timeBitshift("Time Bitshift", 5, 0, 16, 1)
fl::UISlider timescale("Time Scale", 1,.1, 10,.1)
fl::UISlider scale("Scale", 4,.1, 4,.1)
fl::hsv8 CHSV
Definition chsv.h:11
CHSV noiseRingHSV8(float angle, u32 time, float radius)
Generate HSV8 (8-bit) noise for a ring pattern.
Definition noise.cpp.hpp:51
#define FL_M_PI
Definition math.h:34
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
Definition math.h:75
fl::i16 int16_t
Definition s16x16x4.h:215
fl::u16 uint16_t
Definition s16x16x4.h:214
MapRedBlackTree< Key, T, Compare, fl::allocator_slab< char > > map
Definition map.h:283

References FL_M_PI, leds, fl::max(), fl::noiseRingHSV8(), NUM_LEDS, scale, timeBitshift, and timescale.

Referenced by loop().

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