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

◆ loop()

void loop ( )

Definition at line 173 of file LuminescentGrand.ino.

173 {
174 //FL_DBG("loop");
175
176
177 // Calculate dt.
178 static uint32_t s_prev_time = 0;
179 uint32_t prev_time = 0;
180 FASTLED_UNUSED(prev_time); // actually used in perf tests.
181 uint32_t now_ms = fl::millis();
182 uint32_t delta_ms = now_ms - s_prev_time;
183 s_prev_time = now_ms;
184
185 if (!is_debugging) {
186 if (Serial.available() > 0) {
187 int v = Serial.read();
188 if (v == 'd') {
189 is_debugging = true;
190 }
191 }
192 }
193
195
196 const unsigned long start_time = fl::millis();
197 // Each frame we call the midi processor 100 times to make sure that all notes
198 // are processed.
199 for (int i = 0; i < 100; ++i) {
200 MY_MIDI.read();
201 }
202
203 const unsigned long midi_time = fl::millis() - start_time;
204
205 // Updates keyboard: releases sustained keys that.
206
207 const uint32_t keyboard_time_start = fl::millis();
208
209 // This is kind of a hack... but give the keyboard a future time
210 // so that all keys just pressed get a value > 0 for their time
211 // durations.
212 keyboard.Update(now_ms + delta_ms, delta_ms);
213 const uint32_t keyboard_delta_time = fl::millis() - keyboard_time_start;
214
215 ui_state ui_st = ui_update(now_ms, delta_ms);
216
217 //dprint("vis selector = ");
218 //dprintln(vis_state);
219
220
221 // These int values are for desting the performance of the
222 // app. If the app ever runs slow then set kShowFps to 1
223 // in the settings.h file.
224 const unsigned long start_painting = fl::millis();
225 FASTLED_UNUSED(start_painting);
226
227
228 // Paints the keyboard using the led_rope.
230 Painter::Paint(now_ms, delta_ms, which_vis, &keyboard, &led_rope);
231
232 const unsigned long paint_time = fl::millis() - start_time;
233 const unsigned long total_time = midi_time + paint_time + keyboard_delta_time;
234
235 if (kShowFps) {
236 float fps = 1.0f/(float(total_time) / 1000.f);
237 Serial.print("fps - "); Serial.println(fps);
238 Serial.print("midi time - "); Serial.println(midi_time);
239 Serial.print("keyboard update time - "); Serial.println(keyboard_delta_time);
240 Serial.print("draw & paint time - "); Serial.println(paint_time);
241 }
242
243 EVERY_N_SECONDS(1) {
244 FL_DBG("is_debugging = " << is_debugging);
245 }
246
247
248 FastLED.show();
249}
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
LedRopeTCL led_rope(kNumKeys)
void DbgDoSimulatedKeyboardPress()
KeyboardState keyboard
bool is_debugging
Definition dprint.cpp:5
#define EVERY_N_SECONDS(N)
Checks whether to execute a block of code every N seconds.
Definition lib8tion.h:1010
#define FL_DBG
Definition log.h:388
fl::u32 uint32_t
Definition s16x16x4.h:219
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
#define FASTLED_UNUSED(x)
@ kShowFps
Definition settings.h:17
static void Paint(uint32_t now_ms, uint32_t delta_ms, VisState vis_state, KeyboardState *keyboard, LedRopeInterface *light_rope)
Definition Painter.cpp:99
int which_visualizer
Definition ui_state.h:13
#define Serial
Definition serial.h:304
ui_state ui_update(uint32_t now_ms, uint32_t delta_ms)
Definition ui_state.cpp:58

References DbgDoSimulatedKeyboardPress(), EVERY_N_SECONDS, FastLED, FASTLED_UNUSED, FL_DBG, is_debugging, keyboard, kShowFps, led_rope, fl::millis(), Painter::Paint(), Serial, ui_update(), and ui_state::which_visualizer.

+ Here is the call graph for this function: