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

◆ Paint()

void Painter::Paint ( uint32_t now_ms,
uint32_t delta_ms,
VisState vis_state,
KeyboardState * keyboard,
LedRopeInterface * light_rope )
static

Definition at line 98 of file Painter.cpp.

102 {
103 for (int i = 0; i < KeyboardState::kNumKeys; ++i) {
104 Key& key = keyboard->keys_[i];
105
106 const float time_delta_ms = static_cast<float>(now_ms - key.event_time_);
107
108 const float lum = CalcLuminance(time_delta_ms, keyboard->sustain_pedal_, key, i);
109 const float sat = CalcSaturation(time_delta_ms, key.curr_color_, key.on_);
110
111 //if (key.idx_ == 56) {
112 // dprint("lum: "); dprint(lum*255.f); dprint(" sat:"); dprintln(sat*255.f);
113 //}
114
115 key.curr_color_.v_ = lum;
116 key.curr_color_.s_ = sat;
117
118 // Removing this line breaks one of the visualizers...
119 // TODO: Figure out a cleaner solution.
120 light_rope->Set(i, key.curr_color_.ToRGB());
121 }
122
123 LedColumns led_columns = LedLayoutArray();
124
125 switch (vis_state) {
126 case Painter::kBlockNote: {
128 break;
129 }
131 light_rope->DrawRepeat(led_columns.array, kNumKeys);
132 break;
133 }
134 case Painter::kVUNote: {
135 PaintVuNotes(now_ms, *keyboard, led_columns.array, kNumKeys, light_rope);
136 break;
137 }
138 case Painter::kVUMidNote: {
139 PaintVuMidNotesFade(delta_ms, *keyboard, led_columns.array, kNumKeys, light_rope);
140 break;
141 }
142
143 case Painter::kVegas: { // aka "vegas mode?"
144 VegasVisualizer(*keyboard, led_columns.array, kNumKeys, light_rope);
145 break;
146 }
147
149 PaintBrightSurprise(*keyboard, led_columns.array, kNumKeys, light_rope);
150 break;
151 }
152
154 PaintVuSpaceInvaders(now_ms, *keyboard, led_columns.array, kNumKeys, light_rope);
155 break;
156 }
157
158 default:
159 dprint("Unknown mode: "); dprint(vis_state); dprint(".\n");
160 break;
161 }
162}
static const int kNumKeys
Definition Keyboard.h:101
bool sustain_pedal_
Definition Keyboard.h:102
Key keys_[kNumKeys]
Definition Keyboard.h:103
virtual void Set(int i, const Color3i &c)=0
virtual void DrawRepeat(const int *value_array, int array_length)=0
virtual void DrawSequentialRepeat(int repeat)=0
#define dprint(x)
Definition dprint.h:11
LedColumns LedLayoutArray()
float CalcLuminance(float time_delta_ms, bool sustain_pedal_on, const Key &key, int key_idx)
Definition Painter.cpp:39
float CalcSaturation(float time_delta_ms, const ColorHSV &color, bool key_on)
Definition Painter.cpp:74
@ kNumLightsPerNote
Definition settings.h:6
@ kNumKeys
Definition settings.h:5
float v_
Definition color.h:98
Color3i ToRGB() const
Definition color.cpp:128
float s_
Definition color.h:98
ColorHSV curr_color_
Definition Keyboard.h:48
unsigned long event_time_
Definition Keyboard.h:41
bool on_
Definition Keyboard.h:36
const int * array
static void PaintBrightSurprise(const KeyboardState &keyboard, const int *led_column_table, int led_column_table_length, LedRopeInterface *led_rope)
Definition Painter.cpp:408
@ kVUMidNote
Definition Painter.h:13
@ kVUSpaceInvaders
Definition Painter.h:17
@ kVegas
Definition Painter.h:18
@ kBlockNote
Definition Painter.h:15
@ kBrightSurprise
Definition Painter.h:19
@ kVUNote
Definition Painter.h:16
@ kColumnNote
Definition Painter.h:14
static void PaintVuNotes(uint32_t now_ms, const KeyboardState &keyboard, const int *led_column_table, int led_column_table_length, LedRopeInterface *led_rope)
Definition Painter.cpp:164
static void PaintVuSpaceInvaders(uint32_t now_ms, const KeyboardState &keyboard, const int *led_column_table, int led_column_table_length, LedRopeInterface *led_rope)
Definition Painter.cpp:449
static void PaintVuMidNotesFade(uint32_t delta_ms, const KeyboardState &keyboard, const int *led_column_table, int led_column_table_length, LedRopeInterface *led_rope)
Definition Painter.cpp:232
static void VegasVisualizer(const KeyboardState &keyboard, const int *led_column_table, int led_column_table_length, LedRopeInterface *led_rope)
Definition Painter.cpp:360

References LedColumns::array, Key::curr_color_, dprint, LedRopeInterface::DrawRepeat(), LedRopeInterface::DrawSequentialRepeat(), Key::event_time_, kBlockNote, kBrightSurprise, kColumnNote, KeyboardState::keys_, KeyboardState::kNumKeys, kNumKeys, kNumLightsPerNote, kVegas, kVUMidNote, kVUNote, kVUSpaceInvaders, LedLayoutArray(), Key::on_, PaintBrightSurprise(), PaintVuMidNotesFade(), PaintVuNotes(), PaintVuSpaceInvaders(), ColorHSV::s_, LedRopeInterface::Set(), KeyboardState::sustain_pedal_, ColorHSV::ToRGB(), ColorHSV::v_, and VegasVisualizer().

+ Here is the call graph for this function: