FastLED 3.9.15
Loading...
Searching...
No Matches
waves.cpp.hpp
Go to the documentation of this file.
5
8
9namespace fl {
10
11void Waves::draw(Context &ctx) {
12 auto *e = ctx.mEngine.get();
13 e->get_ready();
14
15 e->timings.master_speed = 0.01;
16 e->timings.ratio[0] = 2;
17 e->timings.ratio[1] = 2.1;
18 e->timings.ratio[2] = 1.2;
19
20 e->timings.offset[1] = 100;
21 e->timings.offset[2] = 200;
22 e->timings.offset[3] = 300;
23
24 e->calculate_oscillators(e->timings);
25
26 for (int x = 0; x < e->num_x; x++) {
27 for (int y = 0; y < e->num_y; y++) {
28 e->animation.angle = e->polar_theta[x][y];
29 e->animation.scale_x = 0.1;
30 e->animation.scale_y = 0.1;
31 e->animation.scale_z = 0.1;
32 e->animation.dist = e->distance[x][y];
33 e->animation.offset_y = 0;
34 e->animation.offset_x = 0;
35 e->animation.z = 2 * e->distance[x][y] - e->move.linear[0];
36 float show1 = e->render_value(e->animation);
37
38 e->animation.angle = e->polar_theta[x][y];
39 e->animation.dist = e->distance[x][y];
40 e->animation.z = 2 * e->distance[x][y] - e->move.linear[1];
41 float show2 = e->render_value(e->animation);
42
43 e->pixel.red = show1;
44 e->pixel.green = 0;
45 e->pixel.blue = show2;
46
47 e->pixel = e->rgb_sanity_check(e->pixel);
48 e->setPixelColorInternal(x, y, e->pixel);
49 }
50 }
51}
52
53
54// ============================================================================
55// Fixed-Point Implementation of Waves
56// ============================================================================
57
59 auto *e = ctx.mEngine.get();
60 e->get_ready();
61 mState.ensureCache(e);
62 const fl::i32 *fade_lut = fl::assume_aligned<16>(mState.fade_lut);
63 const fl::u8 *perm = PERLIN_NOISE;
64
65 e->timings.master_speed = 0.01;
66 e->timings.ratio[0] = 2;
67 e->timings.ratio[1] = 2.1;
68 e->timings.ratio[2] = 1.2;
69
70 e->timings.offset[1] = 100;
71 e->timings.offset[2] = 200;
72 e->timings.offset[3] = 300;
73
74 e->calculate_oscillators(e->timings);
75
76 for (int x = 0; x < e->num_x; x++) {
77 for (int y = 0; y < e->num_y; y++) {
78 e->animation.angle = e->polar_theta[x][y];
79 e->animation.scale_x = 0.1;
80 e->animation.scale_y = 0.1;
81 e->animation.scale_z = 0.1;
82 e->animation.dist = e->distance[x][y];
83 e->animation.offset_y = 0;
84 e->animation.offset_x = 0;
85 e->animation.z = 2 * e->distance[x][y] - e->move.linear[0];
86 float show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
87
88 e->animation.angle = e->polar_theta[x][y];
89 e->animation.dist = e->distance[x][y];
90 e->animation.z = 2 * e->distance[x][y] - e->move.linear[1];
91 float show2 = render_value_fp_from_float(e->animation, fade_lut, perm);
92
93 e->pixel.red = show1;
94 e->pixel.green = 0;
95 e->pixel.blue = show2;
96
97 e->pixel = e->rgb_sanity_check(e->pixel);
98 e->setPixelColorInternal(x, y, e->pixel);
99 }
100 }
101}
102
103} // namespace fl
104
FPVizState mState
Definition waves.h:22
void draw(Context &ctx) override
Definition waves.cpp.hpp:58
void draw(Context &ctx) override
Definition waves.cpp.hpp:11
unsigned char u8
Definition s16x16x4.h:132
T * assume_aligned(T *ptr) FL_NOEXCEPT
Definition s16x16x4.h:126
FASTLED_FORCE_INLINE fl::i32 render_value_fp_from_float(const render_parameters &anim, const fl::i32 *fade_lut, const fl::u8 *perm)
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_OPTIMIZATION_LEVEL_O3_BEGIN
#define FL_FAST_MATH_BEGIN
#define FL_FAST_MATH_END
#define FL_OPTIMIZATION_LEVEL_O3_END
fl::unique_ptr< Engine > mEngine
Definition context.h:38