FastLED 3.9.15
Loading...
Searching...
No Matches
module_experiment5.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.33;
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 = 1.5;
28
29 e->animation.dist = e->distance[x][y] +
30 fl::sinf(0.5 * e->distance[x][y] - e->move.radial[3]);
31 e->animation.angle = e->polar_theta[x][y];
32 e->animation.z = 5;
33 e->animation.scale_x = 0.1 * s;
34 e->animation.scale_y = 0.1 * s;
35 e->animation.offset_z = 0.1 * e->move.linear[0];
36 e->animation.offset_y = -20 * e->move.linear[0];
37 e->animation.offset_x = 10;
38 e->animation.low_limit = 0;
39 e->show1 = e->render_value(e->animation);
40
41 e->pixel.red = e->show1;
42 e->pixel.green = 0;
43 e->pixel.blue = 0;
44
45 e->pixel = e->rgb_sanity_check(e->pixel);
46
47 e->setPixelColorInternal(x, y, e->pixel);
48 }
49 }
50}
51
52
53// ============================================================================
54// Fixed-Point Implementation of Module_Experiment5
55// ============================================================================
56
58 auto *e = ctx.mEngine.get();
59 e->get_ready();
60 mState.ensureCache(e);
61 const fl::i32 *fade_lut = fl::assume_aligned<16>(mState.fade_lut);
62 const fl::u8 *perm = PERLIN_NOISE;
63
64 e->timings.master_speed = 0.031;
65 e->timings.ratio[0] = 0.0025;
66 e->timings.ratio[1] = 0.0027;
67 e->timings.ratio[2] = 0.029;
68 e->timings.ratio[3] = 0.33;
69 e->timings.ratio[4] = 0.036;
70
71 e->calculate_oscillators(e->timings);
72
73 for (int x = 0; x < e->num_x; x++) {
74 for (int y = 0; y < e->num_y; y++) {
75
76 float s = 1.5;
77
78 e->animation.dist = e->distance[x][y] +
79 fl::sinf(0.5 * e->distance[x][y] - e->move.radial[3]);
80 e->animation.angle = e->polar_theta[x][y];
81 e->animation.z = 5;
82 e->animation.scale_x = 0.1 * s;
83 e->animation.scale_y = 0.1 * s;
84 e->animation.offset_z = 0.1 * e->move.linear[0];
85 e->animation.offset_y = -20 * e->move.linear[0];
86 e->animation.offset_x = 10;
87 e->animation.low_limit = 0;
88 e->show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
89
90 e->pixel.red = e->show1;
91 e->pixel.green = 0;
92 e->pixel.blue = 0;
93
94 e->pixel = e->rgb_sanity_check(e->pixel);
95
96 e->setPixelColorInternal(x, y, e->pixel);
97 }
98 }
99}
100
101} // namespace fl
102
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