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 163 of file Painter.cpp.

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

References Color3i::Black(), Key::curr_color_, 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: