FastLED 3.9.15
Loading...
Searching...
No Matches

◆ PaintVuNotes()

void Painter::PaintVuNotes ( uint32_t now_ms,
const KeyboardState & keyboard,
const int * led_column_table,
int led_column_table_length,
LedRopeInterface * led_rope )
staticprivate

Definition at line 164 of file Painter.cpp.

167 {
168
169
170 FASTLED_WARN("\n\n############## VU NOTES ################\n\n");
171
172 led_rope->RawBeginDraw();
173
174 for (int i = 0; i < led_column_table_length; ++i) {
175 const Key& key = keyboard.keys_[i];
176
177
178 // Map the white keys to the bottom and the black keys to the top.
179 bool black_key = false;
180 switch (key.idx_ % 12) {
181 case 1:
182 case 4:
183 case 6:
184 case 9:
185 case 11:
186 black_key = true;
187 break;
188 }
189
190 const int pixel_count = led_column_table[i];
191 const int draw_pixel_count = ceil(pixel_count * sqrt(key.curr_color_.v_));
192
193 const int black_pixel_count = pixel_count - draw_pixel_count;
194 const Color3i& c = *led_rope->GetIterator(i);
195
196
197 const bool reverse_correct = black_key == (key.idx_ % 2);
198
199 if (reverse_correct) {
200 for (int j = 0; j < draw_pixel_count; ++j) {
201 if (j < draw_pixel_count - 1) {
202 led_rope->RawDrawPixel(c);
203 } else {
204 // Last pixel.
205 ColorHSV hsv(random(512) / 512.f, random(512) / 512.f, 1.0);
206 led_rope->RawDrawPixel(hsv.ToRGB());
207 }
208 }
209
210 for (int j = 0; j < black_pixel_count; ++j) {
211 led_rope->RawDrawPixel(Color3i::Black());
212 }
213 } else {
214 for (int j = 0; j < black_pixel_count; ++j) {
215 led_rope->RawDrawPixel(Color3i::Black());
216 }
217
218 for (int j = draw_pixel_count - 1; j >= 0; --j) {
219 if (j < draw_pixel_count - 1) {
220 led_rope->RawDrawPixel(c);
221 } else {
222 // Last pixel.
223 ColorHSV hsv(random(512) / 512.f, random(512) / 512.f, 1.0);
224 led_rope->RawDrawPixel(hsv.ToRGB());
225 }
226 }
227 }
228 }
229 led_rope->RawCommitDraw();
230}
Key keys_[kNumKeys]
Definition Keyboard.h:103
virtual void RawDrawPixel(const Color3i &c)=0
virtual void RawCommitDraw()=0
virtual void RawBeginDraw()=0
virtual Color3i * GetIterator(int i)=0
T ceil(T value)
Definition math.h:18
static Color3i Black()
Definition color.h:9
float v_
Definition color.h:98
int idx_
Definition Keyboard.h:40
ColorHSV curr_color_
Definition Keyboard.h:48
#define FASTLED_WARN
Definition warn.h:7

References Color3i::Black(), Key::curr_color_, FASTLED_WARN, LedRopeInterface::GetIterator(), Key::idx_, KeyboardState::keys_, LedRopeInterface::RawBeginDraw(), LedRopeInterface::RawCommitDraw(), LedRopeInterface::RawDrawPixel(), ColorHSV::ToRGB(), and ColorHSV::v_.

Referenced by Paint().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: