Add PixelStomp MUX driver (DAT=9, LD=10, CLK=11, DI=12)
- New PixelStompMux class with shift register read/write - Read 10 buttons via DI (active LOW) - Drive 10 LEDs via DAT (shift out + latch) - LED startup animation uses MUX - Switch polling reads from MUX shift register - MUX instance shared between switch and LED drivers
This commit is contained in:
@@ -23,6 +23,8 @@ struct LedState {
|
||||
bool active;
|
||||
};
|
||||
|
||||
class PixelStompMux;
|
||||
|
||||
class DefaultLedStub : public LedStub {
|
||||
private:
|
||||
static const uint8_t NUM_LEDS = 10;
|
||||
@@ -34,4 +36,6 @@ public:
|
||||
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);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class PixelStompMux {
|
||||
public:
|
||||
static const uint8_t NUM_INPUTS = 10;
|
||||
static const uint8_t NUM_OUTPUTS = 10;
|
||||
|
||||
PixelStompMux(uint8_t dat_pin, uint8_t ld_pin, uint8_t clk_pin, uint8_t di_pin);
|
||||
|
||||
void begin();
|
||||
|
||||
uint16_t read_buttons();
|
||||
bool is_button_pressed(uint8_t index);
|
||||
|
||||
void write_leds(uint16_t led_state);
|
||||
void set_led(uint8_t index, bool on);
|
||||
void clear_all();
|
||||
|
||||
void dump();
|
||||
|
||||
private:
|
||||
uint8_t pin_dat;
|
||||
uint8_t pin_ld;
|
||||
uint8_t pin_clk;
|
||||
uint8_t pin_di;
|
||||
|
||||
uint16_t last_button_state;
|
||||
uint16_t current_led_state;
|
||||
|
||||
void shift_out(uint16_t data, uint8_t bits);
|
||||
uint16_t shift_in(uint8_t bits);
|
||||
void pulse_pin(uint8_t pin, uint8_t level, uint16_t duration_us = 1);
|
||||
};
|
||||
@@ -21,6 +21,8 @@ struct SwitchState {
|
||||
uint32_t debounce_time;
|
||||
};
|
||||
|
||||
class PixelStompMux;
|
||||
|
||||
class DefaultSwitchStub : public SwitchStub {
|
||||
private:
|
||||
static const uint8_t NUM_SWITCHES = 10;
|
||||
@@ -33,4 +35,6 @@ public:
|
||||
bool is_pressed(uint8_t switch_id) override;
|
||||
void configure_switch(uint8_t switch_id, uint8_t gpio_pin) override;
|
||||
void set_debounce_time(uint32_t time_ms) override;
|
||||
|
||||
void set_mux(PixelStompMux* mux);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user