Files
loopy_midi_controller/components/hal/switch_stub.h
T
ash 458cb5060f Fix Phase 1 skeleton: add build system, fix compilation errors
- Add CMakeLists.txt for project and all components
- Add idf_component.yml with TinyUSB dependency
- Create switch_stub.cpp implementation
- Fix app_task.h to match .cpp implementation (2-param signature)
- Fix led_stub.h/cpp class naming (DefaultLedStub)
- Fix midi_transport.cpp TinyUSB API usage (tud_midi_*)
- Move main.cpp to main/ directory
- Add sdkconfig.defaults for ESP32-S3
2026-06-23 08:59:53 +00:00

42 lines
1.2 KiB
C++

// components/hal/switch_stub.h
#pragma once
#include <cstdint>
class SwitchStub {
public:
virtual ~SwitchStub() {}
virtual void begin() = 0;
virtual bool is_pressed(uint8_t switch_id) = 0;
// Configuration methods
virtual void configure_switch(uint8_t switch_id, uint8_t gpio_pin) = 0;
virtual void set_debounce_time(uint32_t time_ms) = 0;
};
// Switch state structure
struct SwitchState {
uint8_t id; // Switch identifier
uint8_t gpio_pin; // GPIO pin (if applicable)
bool current_state; // Current pressed state
bool previous_state; // Previous state (for debounce)
uint32_t last_change_time; // Timestamp of last state change
uint32_t debounce_time; // Debounce time in ms
};
// Default stub implementation
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;
};