diff --git a/include/led_stub.h b/include/led_stub.h index 5537f37..87ce4cd 100644 --- a/include/led_stub.h +++ b/include/led_stub.h @@ -35,6 +35,8 @@ private: bool initialized; uint32_t activity_off_time = 0; uint8_t saved_r = 0, saved_g = 0, saved_b = 0; + uint32_t heartbeat_time = 0; + uint8_t heartbeat_phase = 0; public: DefaultLedStub(); diff --git a/platformio.ini b/platformio.ini index 01ceb8a..c074ca8 100644 --- a/platformio.ini +++ b/platformio.ini @@ -16,6 +16,10 @@ build_flags = -DARDUINO_USB_MODE=0 -DARDUINO_USB_CDC_ON_BOOT=1 -DUSE_TINYUSB=1 + -DUSB_VID=0x1235 + -DUSB_PID=0x0103 + -DUSB_MANUFACTURER="Novation" + -DUSB_PRODUCT="Launchpad X" monitor_speed = 115200 diff --git a/src/app_task.cpp b/src/app_task.cpp index d2739d4..b210eda 100644 --- a/src/app_task.cpp +++ b/src/app_task.cpp @@ -55,6 +55,7 @@ void AppTask::process_midi_event(const MidiEvent& event) { uint8_t cin = event.channel; uint8_t packet[3] = {event.data1, event.data2, 0}; process_sysex_packet(packet, cin); + led_driver->flash_sysex(); return; } diff --git a/src/led_stub.cpp b/src/led_stub.cpp index c64b955..654c812 100644 --- a/src/led_stub.cpp +++ b/src/led_stub.cpp @@ -277,20 +277,44 @@ void DefaultLedStub::flash_activity() { } } - // Flash LED 0 white - mux_ptr->set_led_color(0, 255, 255, 255); + // Flash ALL LEDs white for SysEx (more visible), LED 0 for regular MIDI + for (int i = 0; i < NUM_LEDS; i++) { + mux_ptr->set_led_color(i, 255, 255, 255); + } mux_ptr->show(); - activity_off_time = now + 30; + activity_off_time = now + 50; +} + +void DefaultLedStub::flash_sysex() { + if (!initialized || !mux_ptr) return; + for (int i = 0; i < NUM_LEDS; i++) { + mux_ptr->set_led_color(i, 255, 255, 255); + } + mux_ptr->show(); + activity_off_time = millis() + 200; } void DefaultLedStub::update() { if (!initialized || !mux_ptr) return; - // Turn off activity flash after 30ms + // Turn off activity flash uint32_t now = millis(); if (activity_off_time > 0 && now >= activity_off_time) { mux_ptr->set_led_color(0, saved_r, saved_g, saved_b); mux_ptr->show(); activity_off_time = 0; } + + // Heartbeat: pulse LED 9 slowly so we know device is alive + if (now - heartbeat_time > 2000) { + heartbeat_time = now; + heartbeat_phase = 1; + } + if (heartbeat_phase) { + uint8_t brightness = (heartbeat_phase < 100) ? (heartbeat_phase * 2) : (400 - heartbeat_phase * 2); + mux_ptr->set_led_color(9, brightness, brightness / 4, 0); + mux_ptr->show(); + heartbeat_phase++; + if (heartbeat_phase > 200) heartbeat_phase = 0; + } }