| 231 | } |
| 232 | |
| 233 | void Painter::PaintVuMidNotesFade(uint32_t /*delta_ms*/, |
| 234 | const KeyboardState& keyboard, |
| 235 | const int* led_column_table, int led_column_table_length, |
| 236 | LedRopeInterface* led_rope) { |
| 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; // 0->1.0 |
| 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 | // Generator for the DrawPoints struct above. |
| 258 | // n_led: How many led's there are in total. |
| 259 | // factor: 0->1, indicates % of led's "on". |
| 260 | struct F { |
| 261 | static DrawPoints Generate(int n_led, float factor) { |
| 262 | DrawPoints out; |
| 263 | fl::memset(&out, 0, sizeof(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); // Truncates float. |
| 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; |
nothing calls this directly
no test coverage detected