FastLED 3.9.15
Loading...
Searching...
No Matches
module_experiment4.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.031;
16 e->timings.ratio[0] = 0.0025;
17 e->timings.ratio[1] = 0.0027;
18 e->timings.ratio[2] = 0.029;
19 e->timings.ratio[3] = 0.033;
20 e->timings.ratio[4] = 0.036;
21
22 e->calculate_oscillators(e->timings);
23
24 for (int x = 0; x < e->num_x; x++) {
25 for (int y = 0; y < e->num_y; y++) {
26
27 float s = 0.8;
28
29 e->animation.dist = (e->distance[x][y] * e->distance[x][y]) * 0.7;
30 e->animation.angle = e->polar_theta[x][y];
31 e->animation.z = 5;
32 e->animation.scale_x = 0.004 * s;
33 e->animation.scale_y = 0.003 * s;
34 e->animation.offset_z = 0.1 * e->move.linear[2];
35 e->animation.offset_y = -20 * e->move.linear[2];
36 e->animation.offset_x = 10;
37 e->animation.low_limit = 0;
38 e->show1 = e->render_value(e->animation);
39
40 e->animation.dist = (e->distance[x][y] * e->distance[x][y]) * 0.8;
41 e->animation.angle = e->polar_theta[x][y];
42 e->animation.z = 50;
43 e->animation.scale_x = 0.004 * s;
44 e->animation.scale_y = 0.003 * s;
45 e->animation.offset_z = 0.1 * e->move.linear[3];
46 e->animation.offset_y = -20 * e->move.linear[3];
47 e->animation.offset_x = 100;
48 e->animation.low_limit = 0;
49 e->show2 = e->render_value(e->animation);
50
51 e->animation.dist = (e->distance[x][y] * e->distance[x][y]) * 0.9;
52 e->animation.angle = e->polar_theta[x][y];
53 e->animation.z = 5000;
54 e->animation.scale_x = 0.004 * s;
55 e->animation.scale_y = 0.003 * s;
56 e->animation.offset_z = 0.1 * e->move.linear[4];
57 e->animation.offset_y = -20 * e->move.linear[4];
58 e->animation.offset_x = 1000;
59 e->animation.low_limit = 0;
60 e->show3 = e->render_value(e->animation);
61
62 e->pixel.red = e->show1 - e->show2 - e->show3;
63 e->pixel.blue = e->show2 - e->show1 - e->show3;
64 e->pixel.green = e->show3 - e->show1 - e->show2;
65
66 e->pixel = e->rgb_sanity_check(e->pixel);
67
68 e->setPixelColorInternal(x, y, e->pixel);
69 }
70 }
71}
72
73
74// ============================================================================
75// Fixed-Point Implementation of Module_Experiment4
76// ============================================================================
77
79 auto *e = ctx.mEngine.get();
80 e->get_ready();
81 mState.ensureCache(e);
82 const fl::i32 *fade_lut = fl::assume_aligned<16>(mState.fade_lut);
83 const fl::u8 *perm = PERLIN_NOISE;
84
85 e->timings.master_speed = 0.031;
86 e->timings.ratio[0] = 0.0025;
87 e->timings.ratio[1] = 0.0027;
88 e->timings.ratio[2] = 0.029;
89 e->timings.ratio[3] = 0.033;
90 e->timings.ratio[4] = 0.036;
91
92 e->calculate_oscillators(e->timings);
93
94 for (int x = 0; x < e->num_x; x++) {
95 for (int y = 0; y < e->num_y; y++) {
96
97 float s = 0.8;
98
99 e->animation.dist = (e->distance[x][y] * e->distance[x][y]) * 0.7;
100 e->animation.angle = e->polar_theta[x][y];
101 e->animation.z = 5;
102 e->animation.scale_x = 0.004 * s;
103 e->animation.scale_y = 0.003 * s;
104 e->animation.offset_z = 0.1 * e->move.linear[2];
105 e->animation.offset_y = -20 * e->move.linear[2];
106 e->animation.offset_x = 10;
107 e->animation.low_limit = 0;
108 e->show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
109
110 e->animation.dist = (e->distance[x][y] * e->distance[x][y]) * 0.8;
111 e->animation.angle = e->polar_theta[x][y];
112 e->animation.z = 50;
113 e->animation.scale_x = 0.004 * s;
114 e->animation.scale_y = 0.003 * s;
115 e->animation.offset_z = 0.1 * e->move.linear[3];
116 e->animation.offset_y = -20 * e->move.linear[3];
117 e->animation.offset_x = 100;
118 e->animation.low_limit = 0;
119 e->show2 = render_value_fp_from_float(e->animation, fade_lut, perm);
120
121 e->animation.dist = (e->distance[x][y] * e->distance[x][y]) * 0.9;
122 e->animation.angle = e->polar_theta[x][y];
123 e->animation.z = 5000;
124 e->animation.scale_x = 0.004 * s;
125 e->animation.scale_y = 0.003 * s;
126 e->animation.offset_z = 0.1 * e->move.linear[4];
127 e->animation.offset_y = -20 * e->move.linear[4];
128 e->animation.offset_x = 1000;
129 e->animation.low_limit = 0;
130 e->show3 = render_value_fp_from_float(e->animation, fade_lut, perm);
131
132 e->pixel.red = e->show1 - e->show2 - e->show3;
133 e->pixel.blue = e->show2 - e->show1 - e->show3;
134 e->pixel.green = e->show3 - e->show1 - e->show2;
135
136 e->pixel = e->rgb_sanity_check(e->pixel);
137
138 e->setPixelColorInternal(x, y, e->pixel);
139 }
140 }
141}
142
143} // namespace fl
144
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
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