102cae9d91
- 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
41 lines
958 B
C++
41 lines
958 B
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
class SwitchStub {
|
|
public:
|
|
virtual ~SwitchStub() {}
|
|
|
|
virtual void begin() = 0;
|
|
virtual bool is_pressed(uint8_t switch_id) = 0;
|
|
virtual void configure_switch(uint8_t switch_id, uint8_t gpio_pin) = 0;
|
|
virtual void set_debounce_time(uint32_t time_ms) = 0;
|
|
};
|
|
|
|
struct SwitchState {
|
|
uint8_t id;
|
|
uint8_t gpio_pin;
|
|
bool current_state;
|
|
bool previous_state;
|
|
uint32_t last_change_time;
|
|
uint32_t debounce_time;
|
|
};
|
|
|
|
class PixelStompMux;
|
|
|
|
class DefaultSwitchStub : public SwitchStub {
|
|
private:
|
|
static const uint8_t NUM_SWITCHES = 10;
|
|
SwitchState switch_states[NUM_SWITCHES];
|
|
bool initialized;
|
|
|
|
public:
|
|
DefaultSwitchStub();
|
|
void begin() override;
|
|
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);
|
|
};
|