46 lines
1.2 KiB
C++
46 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include "midi_transport.h"
|
|
#include "ble_midi_transport.h"
|
|
#include "led_stub.h"
|
|
#include "switch_stub.h"
|
|
|
|
struct PadMapping {
|
|
uint8_t physical_switch;
|
|
uint8_t midi_channel;
|
|
uint8_t midi_note;
|
|
uint8_t led_index;
|
|
};
|
|
|
|
class AppTask {
|
|
public:
|
|
AppTask(LedStub* led, SwitchStub* sw, UsbMidiTransport* usb_midi, BleMidiTransport* ble_midi = nullptr);
|
|
|
|
void begin();
|
|
void update();
|
|
void process_midi_event(const MidiEvent& event); // public for test commands
|
|
|
|
private:
|
|
LedStub* led_driver;
|
|
SwitchStub* switch_driver;
|
|
UsbMidiTransport* usb_midi;
|
|
BleMidiTransport* ble_midi;
|
|
|
|
static const uint8_t NUM_PADS = 10;
|
|
PadMapping pad_mapping[NUM_PADS];
|
|
bool last_switch_state[NUM_PADS];
|
|
uint8_t cc_map[NUM_PADS];
|
|
|
|
// SysEx reassembly buffer
|
|
static const uint8_t SYSEX_MAX_LEN = 64;
|
|
uint8_t sysex_buffer[SYSEX_MAX_LEN];
|
|
uint8_t sysex_len = 0;
|
|
bool sysex_active = false;
|
|
|
|
void process_switch_event(uint8_t switch_id, bool pressed);
|
|
void run_palette_test();
|
|
void handle_sysex(const uint8_t* data, uint8_t len);
|
|
void process_sysex_packet(const uint8_t* packet, uint8_t cin);
|
|
};
|