07e5cd8994
PixelStomp MUX uses: - WS2812C LEDs: one data line via DAT (GPIO 9), NeoPixel protocol - 74HC165 shift register: LD/CLK/DI for reading 8 button states Changes: - Use Adafruit NeoPixel library for LED control - Proper 74HC165 parallel-load shift-in for buttons - 8 switches + 8 LEDs (was incorrectly 10) - Diagnostic commands: dump, ledtest, red, green, blue, read
42 lines
832 B
C++
42 lines
832 B
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 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 = 8;
|
|
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) override;
|
|
void clear_all() override;
|
|
|
|
void set_mux(PixelStompMux* mux);
|
|
};
|