Files
loopy_midi_controller/include/led_stub.h
T
ash af14c2f759 Replace MIDI clock with internal BPM timer for pixel 6 pulse
Revert:
- Remove midi_clock.h/cpp (was causing cross-core crash)
- Remove real-time MIDI message parsing from midi_transport.cpp

New approach:
- Pixel 6 (and all active LEDs) pulse to internal BPM timer
- Default 120 BPM (500ms beat interval)
- 'bpm <n>' serial command to change tempo (20-300)
- Only calls FastLED.show() when actively pulsing (avoids USB/WS2812 interference)
- 33ms update rate (30fps)
- Inactive LEDs left untouched (no unnecessary show() calls)
2026-07-02 07:27:26 +00:00

50 lines
1.2 KiB
C++

#pragma once
#include <cstdint>
class LedStub {
public:
virtual ~LedStub() {}
virtual void begin() = 0;
virtual void set_led_state(uint8_t note, uint8_t channel, uint8_t velocity, int8_t led_index = -1) = 0;
virtual void clear_all() = 0;
virtual void set_led_brightness(uint8_t brightness) = 0;
virtual void flash_activity() {}
virtual void update() {}
virtual uint8_t note_to_index(uint8_t note) {
return note;
}
};
struct LedState {
uint8_t note;
uint8_t channel;
uint8_t velocity;
uint32_t timestamp;
bool active;
};
class PixelStompMux;
class DefaultLedStub : public LedStub {
private:
static const uint8_t NUM_LEDS = 10;
LedState led_states[NUM_LEDS];
bool initialized;
uint32_t beat_interval_ms = 500;
public:
DefaultLedStub();
void begin() override;
void set_led_state(uint8_t note, uint8_t channel, uint8_t velocity, int8_t led_index = -1) override;
void clear_all() override;
void set_led_brightness(uint8_t brightness) override;
void flash_activity() override;
void update() override;
void set_mux(PixelStompMux* mux);
void set_bpm(uint16_t bpm);
};