MCPcopy Create free account
hub / github.com/FastLED/FastLED / PaintVuNotes

Method PaintVuNotes

examples/LuminescentGrand/shared/Painter.cpp:165–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165void Painter::PaintVuNotes(uint32_t /*now_ms*/,
166 const KeyboardState& keyboard,
167 const int* led_column_table, int led_column_table_length,
168 LedRopeInterface* led_rope) {
169
170
171 FL_WARN("\n\n############## VU NOTES ################\n\n");
172
173 led_rope->RawBeginDraw();
174
175 for (int i = 0; i < led_column_table_length; ++i) {
176 const Key& key = keyboard.mKeys[i];
177
178
179 // Map the white keys to the bottom and the black keys to the top.
180 bool black_key = false;
181 switch (key.mIdx % 12) {
182 case 1:
183 case 4:
184 case 6:
185 case 9:
186 case 11:
187 black_key = true;
188 break;
189 }
190
191 const int pixel_count = led_column_table[i];
192 const int draw_pixel_count = fl::ceil(pixel_count * fl::sqrt(key.mCurrColor.v_));
193
194 const int black_pixel_count = pixel_count - draw_pixel_count;
195 const Color3i& c = *led_rope->GetIterator(i);
196
197
198 const bool reverse_correct = black_key == (key.mIdx % 2);
199
200 if (reverse_correct) {
201 for (int j = 0; j < draw_pixel_count; ++j) {
202 if (j < draw_pixel_count - 1) {
203 led_rope->RawDrawPixel(c);
204 } else {
205 // Last pixel.
206 ColorHSV hsv(random(512) / 512.f, random(512) / 512.f, 1.0);
207 led_rope->RawDrawPixel(hsv.ToRGB());
208 }
209 }
210
211 for (int j = 0; j < black_pixel_count; ++j) {
212 led_rope->RawDrawPixel(Color3i::Black());
213 }
214 } else {
215 for (int j = 0; j < black_pixel_count; ++j) {
216 led_rope->RawDrawPixel(Color3i::Black());
217 }
218
219 for (int j = draw_pixel_count - 1; j >= 0; --j) {
220 if (j < draw_pixel_count - 1) {
221 led_rope->RawDrawPixel(c);
222 } else {

Callers

nothing calls this directly

Calls 8

ceilFunction · 0.85
sqrtFunction · 0.85
RawBeginDrawMethod · 0.80
RawDrawPixelMethod · 0.80
RawCommitDrawMethod · 0.80
randomClass · 0.50
GetIteratorMethod · 0.45
ToRGBMethod · 0.45

Tested by

no test coverage detected