Files
loopy_midi_controller/include/led_stub.h
T
ash 5dc10eea87 Add MIDI clock-driven LED pulsing
- New MidiClock module: tracks 24 PPQN clock ticks, computes beat phase
  and smooth sine pulse from incoming MIDI Clock (0xF8)
- midi_transport: detect CIN=0xF real-time packets, route 0xF8 to
  MidiClock::tick(), 0xFA/FB to start(), 0xFC to stop()
- led_stub update(): every 20ms, modulates active LED brightness
  using pulse curve (50%-100%), pixel 6 always throbs when clock
  is running even if no loops active
- Aligned set_led_state() all paths to use pad_base_colors
- Removed dead activity flash code
2026-07-02 07:15:53 +00:00

48 lines
1.1 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;
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);
};