FastLED 3.9.15
Loading...
Searching...
No Matches
module_experiment6.cpp.hpp
Go to the documentation of this file.
5
8
9namespace fl {
10
12 auto *e = ctx.mEngine.get();
13 e->get_ready();
14
15 e->timings.master_speed = 0.01;
16
17 float w = 0.7;
18
19 e->timings.ratio[0] = 0.0025;
20 e->timings.ratio[1] = 0.0027;
21 e->timings.ratio[2] = 0.029;
22 e->timings.ratio[3] = 0.33 * w;
23 e->timings.ratio[4] = 0.36 * w;
24
25 e->calculate_oscillators(e->timings);
26
27 for (int x = 0; x < e->num_x; x++) {
28 for (int y = 0; y < e->num_y; y++) {
29
30 float s = 0.8;
31
32 e->animation.dist = e->distance[x][y] +
33 fl::sinf(0.25 * e->distance[x][y] - e->move.radial[3]);
34 e->animation.angle = e->polar_theta[x][y];
35 e->animation.z = 5;
36 e->animation.scale_x = 0.1 * s;
37 e->animation.scale_y = 0.1 * s;
38 e->animation.offset_z = 0.1 * e->move.linear[0];
39 e->animation.offset_y = -20 * e->move.linear[0];
40 e->animation.offset_x = 10;
41 e->animation.low_limit = 0;
42 e->show1 = e->render_value(e->animation);
43
44 e->animation.dist = e->distance[x][y] +
45 fl::sinf(0.24 * e->distance[x][y] - e->move.radial[4]);
46 e->animation.angle = e->polar_theta[x][y];
47 e->animation.z = 10;
48 e->animation.scale_x = 0.1 * s;
49 e->animation.scale_y = 0.1 * s;
50 e->animation.offset_z = 0.1 * e->move.linear[1];
51 e->animation.offset_y = -20 * e->move.linear[1];
52 e->animation.offset_x = 10;
53 e->animation.low_limit = 0;
54 e->show2 = e->render_value(e->animation);
55
56 e->pixel.red = (e->show1 + e->show2);
57 e->pixel.green = ((e->show1 + e->show2) * 0.6) - 30;
58 e->pixel.blue = 0;
59
60 e->pixel = e->rgb_sanity_check(e->pixel);
61
62 e->setPixelColorInternal(x, y, e->pixel);
63 }
64 }
65}
66
67
68// ============================================================================
69// Fixed-Point Implementation of Module_Experiment6
70// ============================================================================
71
73 auto *e = ctx.mEngine.get();
74 e->get_ready();
75 mState.ensureCache(e);
76 const fl::i32 *fade_lut = fl::assume_aligned<16>(mState.fade_lut);
77 const fl::u8 *perm = PERLIN_NOISE;
78
79 e->timings.master_speed = 0.01;
80
81 float w = 0.7;
82
83 e->timings.ratio[0] = 0.0025;
84 e->timings.ratio[1] = 0.0027;
85 e->timings.ratio[2] = 0.029;
86 e->timings.ratio[3] = 0.33 * w;
87 e->timings.ratio[4] = 0.36 * w;
88
89 e->calculate_oscillators(e->timings);
90
91 for (int x = 0; x < e->num_x; x++) {
92 for (int y = 0; y < e->num_y; y++) {
93
94 float s = 0.8;
95
96 e->animation.dist = e->distance[x][y] +
97 fl::sinf(0.25 * e->distance[x][y] - e->move.radial[3]);
98 e->animation.angle = e->polar_theta[x][y];
99 e->animation.z = 5;
100 e->animation.scale_x = 0.1 * s;
101 e->animation.scale_y = 0.1 * s;
102 e->animation.offset_z = 0.1 * e->move.linear[0];
103 e->animation.offset_y = -20 * e->move.linear[0];
104 e->animation.offset_x = 10;
105 e->animation.low_limit = 0;
106 e->show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
107
108 e->animation.dist = e->distance[x][y] +
109 fl::sinf(0.24 * e->distance[x][y] - e->move.radial[4]);
110 e->animation.angle = e->polar_theta[x][y];
111 e->animation.z = 10;
112 e->animation.scale_x = 0.1 * s;
113 e->animation.scale_y = 0.1 * s;
114 e->animation.offset_z = 0.1 * e->move.linear[1];
115 e->animation.offset_y = -20 * e->move.linear[1];
116 e->animation.offset_x = 10;
117 e->animation.low_limit = 0;
118 e->show2 = render_value_fp_from_float(e->animation, fade_lut, perm);
119
120 e->pixel.red = (e->show1 + e->show2);
121 e->pixel.green = ((e->show1 + e->show2) * 0.6) - 30;
122 e->pixel.blue = 0;
123
124 e->pixel = e->rgb_sanity_check(e->pixel);
125
126 e->setPixelColorInternal(x, y, e->pixel);
127 }
128 }
129}
130
131} // namespace fl
132
void draw(Context &ctx) override
void draw(Context &ctx) override
unsigned char u8
Definition s16x16x4.h:132
T * assume_aligned(T *ptr) FL_NOEXCEPT
Definition s16x16x4.h:126
float sinf(float value) FL_NOEXCEPT
Definition math.h:352
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