235 {
236
237 FASTLED_WARN(
"\n\n############## VU MID NOTES FADE ################\n\n");
238
239 struct DrawPoints {
240 int n_black0;
241 int n_fade0;
242 int n_fill;
243 int n_fade1;
244 int n_black1;
245 float fade_factor;
246
247 float SumBrightness() const {
248 float out = 0;
249 out += n_fill;
250 out += (fade_factor * n_fade0);
251 out += (fade_factor * n_fade1);
252 return out;
253 }
254 };
255
256
257
258
259 struct F {
260 static DrawPoints Generate(int n_led, float factor) {
261 DrawPoints out;
262 memset(&out, 0, sizeof(out));
263 if (n_led == 0 || factor == 0.0f) {
264 out.n_black0 = n_led;
265 return out;
266 }
267 const int is_odd = (n_led % 2);
268 const int n_half_lights = n_led / 2 + is_odd;
269 const float f_half_fill = n_half_lights * factor;
270 const int n_half_fill = static_cast<int>(f_half_fill);
271
272 float fade_pix_perc = f_half_fill - static_cast<float>(n_half_fill);
273 int n_fade_pix = fade_pix_perc < 1.0f;
274 if (n_half_fill == 0) {
275 n_fade_pix = 1;
276 }
277 int n_half_black = n_half_lights - n_half_fill - n_fade_pix;
278
279 int n_fill_pix = 0;
280 if (n_half_fill > 0) {
281 n_fill_pix = n_half_fill * 2 + (is_odd ? -1 : 0);
282 }
283
284 out.n_black0 = n_half_black;
285 out.n_fade0 = n_fade_pix;
286 out.n_fill = n_fill_pix;
287 out.n_fade1 = n_fade_pix;
288 if (!n_fill_pix && is_odd) {
289 out.n_fade1 = 0;
290 }
291 out.n_black1 = n_half_black;
292 out.fade_factor = fade_pix_perc;
293 return out;
294 }
295 };
296
297
299
300 for (int i = 0; i < led_column_table_length; ++i) {
301 const Key& key = keyboard.
keys_[i];
302
304
305
306
307
308
309 const int n_led = led_column_table[i];
310
311 if (active_lights_factor > 0.0f) {
312 DrawPoints dp = F::Generate(n_led, active_lights_factor);
313
316 Color3i color = hsv.
ToRGB();
317
318 Color3i fade_col;
320 c.
v_ = dp.fade_factor;
321 fade_col = c.
ToRGB();
322
323
329
330#ifdef DEBUG_PAINTER
331 if (active_lights_factor > 0.0) {
332 int total_lights_on = dp.SumBrightness();
333
334
335
336
337 #define P(X) dprint(", "#X ": "); dprint(X);
338
339
340
341
343 P(active_lights_factor);
344
346 }
347#endif
348 } else {
350 }
351
352
353
354 }
355
356
358}
virtual void RawCommitDraw()=0
virtual void RawBeginDraw()=0
virtual void RawDrawPixels(const Color3i &c, int n)=0
#define P(x)
Reads a single byte from the p array.
float IntensityFactor() const