14#define DEBUG_FORCED_KEYBOARD
17#define MIDI_SERIAL_PORT Serial1
42#ifdef MIDI_AUTO_INSTANCIATE
43#undef MIDI_AUTO_INSTANCIATE
44#define MIDI_AUTO_INSTANCIATE 0
71 FL_DBG(
"HandleNoteOn: midi_note = " <<
int(midi_note) <<
", velocity = " <<
int(velocity));
83 FL_DBG(
"HandleNoteOn: midi_note = " <<
int(midi_note) <<
", velocity = " <<
int(velocity));
93 keyboard.HandleAfterTouchPoly(note, pressure);
101 keyboard.HandleControlChange(d1, d2);
109 for (
int i = 0; i <
kNumKeys; ++i) {
140#ifdef DEBUG_FORCED_KEYBOARD
141 static uint32_t start_time = 0;
144 const uint32_t time_on = 25;
145 const uint32_t time_off = 500;
151 uint32_t delta_time = now - start_time;
154 uint32_t threshold_time =
toggle ? time_off : time_on;
155 if (delta_time < threshold_time) {
159 int random_key = random(0, 88);
178 static uint32_t s_prev_time = 0;
179 uint32_t prev_time = 0;
182 uint32_t delta_ms = now_ms - s_prev_time;
183 s_prev_time = now_ms;
186 if (
Serial.available() > 0) {
196 const unsigned long start_time =
fl::millis();
199 for (
int i = 0; i < 100; ++i) {
203 const unsigned long midi_time =
fl::millis() - start_time;
207 const uint32_t keyboard_time_start =
fl::millis();
212 keyboard.Update(now_ms + delta_ms, delta_ms);
213 const uint32_t keyboard_delta_time =
fl::millis() - keyboard_time_start;
224 const unsigned long start_painting =
fl::millis();
232 const unsigned long paint_time =
fl::millis() - start_time;
233 const unsigned long total_time = midi_time + paint_time + keyboard_delta_time;
236 float fps = 1.0f/(float(total_time) / 1000.f);
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);
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
void HandleAfterTouchPoly(byte channel, byte note, byte pressure)
FASTLED_DESCRIPTION("A midi keyboard visualizer.")
void HandleAfterTouchChannel(byte channel, byte pressure)
LedRopeTCL led_rope(kNumKeys)
void HandleNoteOff(byte channel, byte midi_note, byte velocity)
void DbgDoSimulatedKeyboardPress()
void HandleNoteOn(byte channel, byte midi_note, byte velocity)
FASTLED_TITLE("Luminescent Grand")
void HandleControlChange(byte channel, byte d1, byte d2)
MIDI Library for the Arduino.
#define EVERY_N_SECONDS(N)
Checks whether to execute a block of code every N seconds.
Centralized logging categories for FastLED hardware interfaces and subsystems.
#define MIDI_CHANNEL_OMNI
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
#define FASTLED_UNUSED(x)
#define MIDI_CREATE_INSTANCE(Type, SerialPort, Name)
Create an instance of the library attached to a serial port. You can use HardwareSerial or SoftwareSe...
void SetOff(uint32_t now_ms)
static void Paint(uint32_t now_ms, uint32_t delta_ms, VisState vis_state, KeyboardState *keyboard, LedRopeInterface *light_rope)
Aggregator header for the fl/ui/ family of per-element UI types.
ui_state ui_update(uint32_t now_ms, uint32_t delta_ms)
ColorSelector color_selector(PIN_COLOR_SELECT)