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

101 {
102 for (int i = 0; i < KeyboardState::kNumKeys; ++i) {
103 Key& key = keyboard->keys_[i];
104
105 const float time_delta_ms = static_cast<float>(now_ms - key.event_time_);
106
107 const float lum = CalcLuminance(time_delta_ms, keyboard->sustain_pedal_, key, i);
108 const float sat = CalcSaturation(time_delta_ms, key.curr_color_, key.on_);
109
110 //if (key.idx_ == 56) {
111 // dprint("lum: "); dprint(lum*255.f); dprint(" sat:"); dprintln(sat*255.f);
112 //}
113
114 key.curr_color_.v_ = lum;
115 key.curr_color_.s_ = sat;
116
117 // Removing this line breaks one of the visualizers...
118 // TODO: Figure out a cleaner solution.
119 light_rope->Set(i, key.curr_color_.ToRGB());
120 }
121
122 LedColumns led_columns = LedLayoutArray();
123
124 switch (vis_state) {
125 case Painter::kBlockNote: {
127 break;
128 }
130 light_rope->DrawRepeat(led_columns.array, kNumKeys);
131 break;
132 }
133 case Painter::kVUNote: {
134 PaintVuNotes(now_ms, *keyboard, led_columns.array, kNumKeys, light_rope);
135 break;
136 }
137 case Painter::kVUMidNote: {
138 PaintVuMidNotesFade(delta_ms, *keyboard, led_columns.array, kNumKeys, light_rope);
139 break;
140 }
141
142 case Painter::kVegas: { // aka "vegas mode?"
143 VegasVisualizer(*keyboard, led_columns.array, kNumKeys, light_rope);
144 break;
145 }
146
148 PaintBrightSurprise(*keyboard, led_columns.array, kNumKeys, light_rope);
149 break;
150 }
151
153 PaintVuSpaceInvaders(now_ms, *keyboard, led_columns.array, kNumKeys, light_rope);
154 break;
155 }
156
157 default:
158 dprint("Unknown mode: "); dprint(vis_state); dprint(".\n");
159 break;
160 }
161}
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:38
float CalcSaturation(float time_delta_ms, const ColorHSV &color, bool key_on)
Definition Painter.cpp:73
@ 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:401
@ 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:163
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:442
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:228
static void VegasVisualizer(const KeyboardState &keyboard, const int *led_column_table, int led_column_table_length, LedRopeInterface *led_rope)
Definition Painter.cpp:353

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: