FastLED 3.9.15
Loading...
Searching...
No Matches
rings.cpp.hpp
Go to the documentation of this file.
5
8
9namespace fl {
10
11void Rings::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] = 1;
17 e->timings.ratio[1] = 1.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 = 5;
29 e->animation.scale_x = 0.2;
30 e->animation.scale_y = 0.2;
31 e->animation.scale_z = 1;
32 e->animation.dist = e->distance[x][y];
33 e->animation.offset_y = -e->move.linear[0];
34 e->animation.offset_x = 0;
35 float show1 = e->render_value(e->animation);
36
37 e->animation.angle = 10;
38 e->animation.dist = e->distance[x][y];
39 e->animation.offset_y = -e->move.linear[1];
40 float show2 = e->render_value(e->animation);
41
42 e->animation.angle = 12;
43 e->animation.dist = e->distance[x][y];
44 e->animation.offset_y = -e->move.linear[2];
45 float show3 = e->render_value(e->animation);
46
47 e->pixel.red = show1;
48 e->pixel.green = show2 / 4;
49 e->pixel.blue = show3 / 4;
50
51 e->pixel = e->rgb_sanity_check(e->pixel);
52 e->setPixelColorInternal(x, y, e->pixel);
53 }
54 }
55}
56
57
58// ============================================================================
59// Fixed-Point Implementation of Rings
60// ============================================================================
61
63 auto *e = ctx.mEngine.get();
64 e->get_ready();
65 mState.ensureCache(e);
66 const fl::i32 *fade_lut = fl::assume_aligned<16>(mState.fade_lut);
67 const fl::u8 *perm = PERLIN_NOISE;
68
69 e->timings.master_speed = 0.01;
70 e->timings.ratio[0] = 1;
71 e->timings.ratio[1] = 1.1;
72 e->timings.ratio[2] = 1.2;
73
74 e->timings.offset[1] = 100;
75 e->timings.offset[2] = 200;
76 e->timings.offset[3] = 300;
77
78 e->calculate_oscillators(e->timings);
79
80 for (int x = 0; x < e->num_x; x++) {
81 for (int y = 0; y < e->num_y; y++) {
82 e->animation.angle = 5;
83 e->animation.scale_x = 0.2;
84 e->animation.scale_y = 0.2;
85 e->animation.scale_z = 1;
86 e->animation.dist = e->distance[x][y];
87 e->animation.offset_y = -e->move.linear[0];
88 e->animation.offset_x = 0;
89 float show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
90
91 e->animation.angle = 10;
92 e->animation.dist = e->distance[x][y];
93 e->animation.offset_y = -e->move.linear[1];
94 float show2 = render_value_fp_from_float(e->animation, fade_lut, perm);
95
96 e->animation.angle = 12;
97 e->animation.dist = e->distance[x][y];
98 e->animation.offset_y = -e->move.linear[2];
99 float show3 = render_value_fp_from_float(e->animation, fade_lut, perm);
100
101 e->pixel.red = show1;
102 e->pixel.green = show2 / 4;
103 e->pixel.blue = show3 / 4;
104
105 e->pixel = e->rgb_sanity_check(e->pixel);
106 e->setPixelColorInternal(x, y, e->pixel);
107 }
108 }
109}
110
111} // namespace fl
112
void draw(Context &ctx) override
Definition rings.cpp.hpp:62
FPVizState mState
Definition rings.h:22
void draw(Context &ctx) override
Definition rings.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