236 {
237
238 FL_WARN(
"\n\n############## VU MID NOTES FADE ################\n\n");
239
240 struct DrawPoints {
241 int n_black0;
242 int n_fade0;
243 int n_fill;
244 int n_fade1;
245 int n_black1;
246 float fade_factor;
247
248 float SumBrightness() const {
249 float out = 0;
250 out += n_fill;
251 out += (fade_factor * n_fade0);
252 out += (fade_factor * n_fade1);
253 return out;
254 }
255 };
256
257
258
259
260 struct F {
261 static DrawPoints Generate(int n_led, float factor) {
262 DrawPoints out;
264 if (n_led == 0 || factor == 0.0f) {
265 out.n_black0 = n_led;
266 return out;
267 }
268 const int is_odd = (n_led % 2);
269 const int n_half_lights = n_led / 2 + is_odd;
270 const float f_half_fill = n_half_lights * factor;
271 const int n_half_fill = static_cast<int>(f_half_fill);
272
273 float fade_pix_perc = f_half_fill - static_cast<float>(n_half_fill);
274 int n_fade_pix = fade_pix_perc < 1.0f;
275 if (n_half_fill == 0) {
276 n_fade_pix = 1;
277 }
278 int n_half_black = n_half_lights - n_half_fill - n_fade_pix;
279
280 int n_fill_pix = 0;
281 if (n_half_fill > 0) {
282 n_fill_pix = n_half_fill * 2 + (is_odd ? -1 : 0);
283 }
284
285 out.n_black0 = n_half_black;
286 out.n_fade0 = n_fade_pix;
287 out.n_fill = n_fill_pix;
288 out.n_fade1 = n_fade_pix;
289 if (!n_fill_pix && is_odd) {
290 out.n_fade1 = 0;
291 }
292 out.n_black1 = n_half_black;
293 out.fade_factor = fade_pix_perc;
294 return out;
295 }
296 };
297
298
300
301 for (int i = 0; i < led_column_table_length; ++i) {
303
305
306
307
308
309
310 const int n_led = led_column_table[i];
311
312 if (active_lights_factor > 0.0f) {
313 DrawPoints dp = F::Generate(n_led, active_lights_factor);
314
317 Color3i color = hsv.
ToRGB();
318
319 Color3i fade_col;
321 c.
v_ = dp.fade_factor;
322 fade_col = c.
ToRGB();
323
324
330
331#ifdef DEBUG_PAINTER
332 if (active_lights_factor > 0.0) {
333 int total_lights_on = dp.SumBrightness();
334
335
336
337
338 #define P(X) dprint(", "#X ": "); dprint(X);
339
340
341
342
344 P(active_lights_factor);
345
347 }
348#endif
349 } else {
351 }
352
353
354
355 }
356
357
359}
LedRopeTCL led_rope(kNumKeys)
void RawDrawPixels(const Color3i &c, int n)
void * memset(void *s, int c, size_t n) FL_NOEXCEPT
FASTLED_FORCE_INLINE fl::u8 P(fl::u8 x)
float IntensityFactor() const