Files
loopy_midi_controller/include/led_stub.h
T
ash 1676bbb044 Fix LED flash/restore logic, heartbeat only on LED 9
- flash_activity: only LED 0, restores properly
- flash_sysex: saves ALL LED states, restores all properly
- heartbeat: only LED 9, only when no activity flash active
- Added sysex_saved arrays to track all LED states
2026-06-25 07:48:05 +00:00

56 lines
1.4 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) = 0;
virtual void clear_all() = 0;
virtual void set_led_brightness(uint8_t brightness) = 0;
virtual void flash_activity() {}
virtual void flash_sysex() {}
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 activity_off_time = 0;
uint8_t saved_r = 0, saved_g = 0, saved_b = 0;
uint8_t sysex_saved_r[10] = {0}, sysex_saved_g[10] = {0}, sysex_saved_b[10] = {0};
bool sysex_flash_active = false;
uint32_t heartbeat_time = 0;
uint8_t heartbeat_phase = 0;
public:
DefaultLedStub();
void begin() override;
void set_led_state(uint8_t note, uint8_t channel, uint8_t velocity) override;
void clear_all() override;
void set_led_brightness(uint8_t brightness) override;
void flash_activity() override;
void flash_sysex() override;
void update() override;
void set_mux(PixelStompMux* mux);
};