FastLED 3.9.15
Loading...
Searching...
No Matches
yves.cpp.hpp
Go to the documentation of this file.
5
8
9namespace fl {
10
11void Yves::draw(Context &ctx) {
12 auto *e = ctx.mEngine.get();
13 e->get_ready();
14
15 e->a = fl::micros();
16
17 e->timings.master_speed = 0.001;
18 e->timings.ratio[0] = 3;
19 e->timings.ratio[1] = 2;
20 e->timings.ratio[2] = 1;
21 e->timings.ratio[3] = 0.13;
22 e->timings.ratio[4] = 0.15;
23 e->timings.ratio[5] = 0.03;
24 e->timings.ratio[6] = 0.025;
25 e->timings.offset[0] = 0;
26 e->timings.offset[1] = 100;
27 e->timings.offset[2] = 200;
28 e->timings.offset[3] = 300;
29 e->timings.offset[4] = 400;
30 e->timings.offset[5] = 500;
31 e->timings.offset[6] = 600;
32
33 e->calculate_oscillators(e->timings);
34
35 for (int x = 0; x < e->num_x; x++) {
36 for (int y = 0; y < e->num_y; y++) {
37 e->animation.dist = e->distance[x][y];
38 e->animation.angle =
39 e->polar_theta[x][y] + 2 * PI + e->move.noise_angle[5];
40 e->animation.scale_x = 0.08;
41 e->animation.scale_y = 0.08;
42 e->animation.scale_z = 0.08;
43 e->animation.offset_y = -e->move.linear[0];
44 e->animation.offset_x = 0;
45 e->animation.offset_z = 0;
46 e->animation.z = 0;
47 float show1 = e->render_value(e->animation);
48
49 e->animation.dist = e->distance[x][y];
50 e->animation.angle =
51 e->polar_theta[x][y] + 2 * PI + e->move.noise_angle[6];
52 ;
53 e->animation.scale_x = 0.08;
54 e->animation.scale_y = 0.08;
55 e->animation.scale_z = 0.08;
56 e->animation.offset_y = -e->move.linear[1];
57 e->animation.offset_x = 0;
58 e->animation.offset_z = 0;
59 e->animation.z = 0;
60 float show2 = e->render_value(e->animation);
61
62 e->animation.angle = e->polar_theta[x][y] + show1 / 100 +
63 e->move.noise_angle[3] + e->move.noise_angle[4];
64 e->animation.dist = e->distance[x][y] + show2 / 50;
65 e->animation.offset_y = -e->move.linear[2];
66
67 e->animation.offset_y += show1 / 100;
68 e->animation.offset_x += show2 / 100;
69
70 float show3 = e->render_value(e->animation);
71
72 e->animation.offset_y = 0;
73 e->animation.offset_x = 0;
74
75 float show4 = e->render_value(e->animation);
76
77 e->pixel.red = show3;
78 e->pixel.green = show3 * show4 / 255;
79 e->pixel.blue = 0;
80
81 e->pixel = e->rgb_sanity_check(e->pixel);
82 e->setPixelColorInternal(x, y, e->pixel);
83 }
84 }
85}
86
87
88// ============================================================================
89// Fixed-Point Implementation of Yves
90// ============================================================================
91
93 auto *e = ctx.mEngine.get();
94 e->get_ready();
95 mState.ensureCache(e);
96 const fl::i32 *fade_lut = fl::assume_aligned<16>(mState.fade_lut);
97 const fl::u8 *perm = PERLIN_NOISE;
98
99 e->a = fl::micros();
100
101 e->timings.master_speed = 0.001;
102 e->timings.ratio[0] = 3;
103 e->timings.ratio[1] = 2;
104 e->timings.ratio[2] = 1;
105 e->timings.ratio[3] = 0.13;
106 e->timings.ratio[4] = 0.15;
107 e->timings.ratio[5] = 0.03;
108 e->timings.ratio[6] = 0.025;
109 e->timings.offset[0] = 0;
110 e->timings.offset[1] = 100;
111 e->timings.offset[2] = 200;
112 e->timings.offset[3] = 300;
113 e->timings.offset[4] = 400;
114 e->timings.offset[5] = 500;
115 e->timings.offset[6] = 600;
116
117 e->calculate_oscillators(e->timings);
118
119 for (int x = 0; x < e->num_x; x++) {
120 for (int y = 0; y < e->num_y; y++) {
121 e->animation.dist = e->distance[x][y];
122 e->animation.angle =
123 e->polar_theta[x][y] + 2 * PI + e->move.noise_angle[5];
124 e->animation.scale_x = 0.08;
125 e->animation.scale_y = 0.08;
126 e->animation.scale_z = 0.08;
127 e->animation.offset_y = -e->move.linear[0];
128 e->animation.offset_x = 0;
129 e->animation.offset_z = 0;
130 e->animation.z = 0;
131 float show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
132
133 e->animation.dist = e->distance[x][y];
134 e->animation.angle =
135 e->polar_theta[x][y] + 2 * PI + e->move.noise_angle[6];
136 ;
137 e->animation.scale_x = 0.08;
138 e->animation.scale_y = 0.08;
139 e->animation.scale_z = 0.08;
140 e->animation.offset_y = -e->move.linear[1];
141 e->animation.offset_x = 0;
142 e->animation.offset_z = 0;
143 e->animation.z = 0;
144 float show2 = render_value_fp_from_float(e->animation, fade_lut, perm);
145
146 e->animation.angle = e->polar_theta[x][y] + show1 / 100 +
147 e->move.noise_angle[3] + e->move.noise_angle[4];
148 e->animation.dist = e->distance[x][y] + show2 / 50;
149 e->animation.offset_y = -e->move.linear[2];
150
151 e->animation.offset_y += show1 / 100;
152 e->animation.offset_x += show2 / 100;
153
154 float show3 = render_value_fp_from_float(e->animation, fade_lut, perm);
155
156 e->animation.offset_y = 0;
157 e->animation.offset_x = 0;
158
159 float show4 = render_value_fp_from_float(e->animation, fade_lut, perm);
160
161 e->pixel.red = show3;
162 e->pixel.green = show3 * show4 / 255;
163 e->pixel.blue = 0;
164
165 e->pixel = e->rgb_sanity_check(e->pixel);
166 e->setPixelColorInternal(x, y, e->pixel);
167 }
168 }
169}
170
171} // namespace fl
172
#define PI
void draw(Context &ctx) override
Definition yves.cpp.hpp:92
FPVizState mState
Definition yves.h:22
void draw(Context &ctx) override
Definition yves.cpp.hpp:11
unsigned char u8
Definition s16x16x4.h:132
T * assume_aligned(T *ptr) FL_NOEXCEPT
Definition s16x16x4.h:126
fl::u32 micros()
Universal microsecond timer - returns microseconds since system startup.
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