Remove all LED pulsing - returning to stable baseline
Pulsing code was causing crashes (FastLED.show() RMT conflict with USB). Removed: - update() is now empty no-op (was calling mux_ptr->show() every 33ms) - Removed set_bpm(), beat_interval_ms, bpm serial command Kept: - Per-pad LED colors with dim off state (working fine) - All button/MIDI/expression pedal functionality
This commit is contained in:
@@ -33,7 +33,6 @@ private:
|
||||
static const uint8_t NUM_LEDS = 10;
|
||||
LedState led_states[NUM_LEDS];
|
||||
bool initialized;
|
||||
uint32_t beat_interval_ms = 500;
|
||||
|
||||
public:
|
||||
DefaultLedStub();
|
||||
@@ -45,5 +44,4 @@ public:
|
||||
void update() override;
|
||||
|
||||
void set_mux(PixelStompMux* mux);
|
||||
void set_bpm(uint16_t bpm);
|
||||
};
|
||||
|
||||
@@ -299,36 +299,5 @@ void DefaultLedStub::flash_activity() {
|
||||
// LED feedback is handled directly by set_led_state().
|
||||
}
|
||||
|
||||
void DefaultLedStub::set_bpm(uint16_t bpm) {
|
||||
if (bpm == 0) bpm = 120;
|
||||
beat_interval_ms = 60000 / bpm;
|
||||
Serial.printf("[LED] Pulse BPM set to %d (%dms)\n", bpm, beat_interval_ms);
|
||||
}
|
||||
|
||||
void DefaultLedStub::update() {
|
||||
if (!initialized || !mux_ptr) return;
|
||||
|
||||
uint32_t now = millis();
|
||||
static uint32_t last_pulse_update = 0;
|
||||
|
||||
if (now - last_pulse_update < 33) return;
|
||||
last_pulse_update = now;
|
||||
|
||||
float phase = (now % beat_interval_ms) / (float)beat_interval_ms;
|
||||
|
||||
// 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;
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,13 +89,6 @@ void handle_serial_command(const String& cmd) {
|
||||
} else if (cmd == "exp") {
|
||||
Serial.printf("[CMD] EXP ADC=%d MIDI=%d\n",
|
||||
exp_pedal.get_raw(), exp_pedal.get_value());
|
||||
} else if (cmd.startsWith("bpm ")) {
|
||||
uint16_t bpm = cmd.substring(4).toInt();
|
||||
if (bpm >= 20 && bpm <= 300) {
|
||||
led_driver.set_bpm(bpm);
|
||||
} else {
|
||||
Serial.println("[CMD] BPM must be 20-300");
|
||||
}
|
||||
} else if (cmd == "usb") {
|
||||
Serial.printf("[CMD] USB mounted: %s\n", TinyUSBDevice.mounted() ? "YES" : "NO");
|
||||
Serial.printf("[CMD] USB ready: %s\n", TinyUSBDevice.ready() ? "YES" : "NO");
|
||||
@@ -140,7 +133,6 @@ void handle_serial_command(const String& cmd) {
|
||||
Serial.println(" red/green/blue - solid colour");
|
||||
Serial.println(" pixel0/pixel1 - single pixel test");
|
||||
Serial.println(" exp - expression pedal ADC/MIDI value");
|
||||
Serial.println(" bpm <n> - set LED pulse tempo (20-300, default 120)");
|
||||
Serial.println(" usb - USB connection status and descriptor info");
|
||||
Serial.println(" gpiotest - raw GPIO pin diagnostic");
|
||||
Serial.println(" rawled - bit-bang WS2812 (no library)");
|
||||
@@ -364,9 +356,6 @@ void setup() {
|
||||
Serial.println("[INIT] Initializing Expression Pedal...");
|
||||
exp_pedal.begin();
|
||||
|
||||
Serial.println("[INIT] Setting LED pulse tempo...");
|
||||
led_driver.set_bpm(120);
|
||||
|
||||
Serial.println("[INIT] Registering MIDI callbacks...");
|
||||
controller.begin();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user