From 483fd1d0007956cb6bc29e99c2d64a851a56113c Mon Sep 17 00:00:00 2001 From: Ashley Strahle Date: Thu, 2 Jul 2026 07:40:37 +0000 Subject: [PATCH] Fix pulse shape and button responsiveness - Pulse shape: instant-on at beat, quick fade to 0 by phase 0.25 (was smooth sine wave - didn't show exact timing) - Active LEDs no longer overridden by update() - they keep their set_led_state() color, restoring button press responsiveness - Pixel 6 only pulses when not active (acts as visual metronome) When active as a loop trigger, stays at full brightness --- src/led_stub.cpp | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/src/led_stub.cpp b/src/led_stub.cpp index 1ad105a..1f25a58 100644 --- a/src/led_stub.cpp +++ b/src/led_stub.cpp @@ -1,7 +1,6 @@ #include "led_stub.h" #include "pixel_stomp_mux.h" #include -#include static PixelStompMux* mux_ptr = nullptr; @@ -316,30 +315,20 @@ void DefaultLedStub::update() { last_pulse_update = now; float phase = (now % beat_interval_ms) / (float)beat_interval_ms; - float pulse = sinf(M_PI * phase); - bool active = false; - for (int i = 0; i < NUM_LEDS; i++) { - if (led_states[i].active) { - active = true; - float brightness = 0.5f + 0.5f * pulse; - uint32_t base = pad_base_colors[i]; - uint8_t r = (uint8_t)(((base >> 16) & 0xFF) * brightness); - uint8_t g = (uint8_t)(((base >> 8) & 0xFF) * brightness); - uint8_t b = (uint8_t)((base & 0xFF) * brightness); - mux_ptr->set_led_color(i, r, g, b); - } else if (i == 6) { - active = true; - float brightness = 0.3f + 0.7f * pulse; - uint32_t base = pad_base_colors[6]; - uint8_t r = (uint8_t)(((base >> 16) & 0xFF) * brightness); - uint8_t g = (uint8_t)(((base >> 8) & 0xFF) * brightness); - uint8_t b = (uint8_t)((base & 0xFF) * brightness); - mux_ptr->set_led_color(6, r, g, b); - } - } + // Instant-on at beat, quick fade to 0 by phase 0.25 + float pulse = 1.0f - phase * 4.0f; + if (pulse < 0.0f) pulse = 0.0f; - if (active) { + // Active LEDs keep their last set_led_state() color — don't override. + // Pixel 6 pulses only when not active (visual metronome for timing). + if (!led_states[6].active) { + float brightness = 0.3f + 0.7f * pulse; + uint32_t base = pad_base_colors[6]; + uint8_t r = (uint8_t)(((base >> 16) & 0xFF) * brightness); + uint8_t g = (uint8_t)(((base >> 8) & 0xFF) * brightness); + uint8_t b = (uint8_t)((base & 0xFF) * brightness); + mux_ptr->set_led_color(6, r, g, b); mux_ptr->show(); } }