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