57 lines
2.3 KiB
C++
57 lines
2.3 KiB
C++
// CMainController.h
|
||
// Zentraler Orchestrator des VersaPad v2.
|
||
// Kennt alle Subsysteme und koordiniert den Datenfluss zwischen ihnen.
|
||
// Einzige Instanz wird in main.cpp angelegt.
|
||
|
||
#pragma once
|
||
#include "CButton.h"
|
||
#include "CEventQueue.h"
|
||
#include "SEvent.h"
|
||
#include "hal/matrix.h"
|
||
#include "hal/encoder.h"
|
||
#include "hal/usb_hid.h"
|
||
#include "hal/usb_serial.h"
|
||
#include "config/action.h"
|
||
#include "config/macro_config.h"
|
||
|
||
class CMainController
|
||
{
|
||
public:
|
||
CMainController();
|
||
void setup(); // Einmalig in Arduino setup() aufrufen
|
||
void work(); // Jeden Loop-Durchlauf aufrufen
|
||
|
||
private:
|
||
// m_queue muss vor m_buttons deklariert sein: C++ initialisiert Member in
|
||
// Deklarationsreihenfolge. Die static-Bridge-Funktion (matrix_cb) erhält
|
||
// einen Pointer auf m_queue – der muss zum Zeitpunkt der Nutzung gültig sein.
|
||
CEventQueue m_queue;
|
||
|
||
// Alle 25 Matrix-Keys (0–24) als CButton-Array.
|
||
// key_id 0–3: Encoder-SW (kein LED), key_id 4: NC, key_id 5–24: MX-Buttons mit LED.
|
||
CButton m_buttons[MATRIX_KEYS];
|
||
|
||
// Encoder CW/CCW-Aktionen aus NVM – Encoder haben kein CButton-Objekt.
|
||
SAction m_enc_cw[4];
|
||
SAction m_enc_ccw[4];
|
||
|
||
void init_buttons(); // Buttons aus NVM-Config initialisieren
|
||
void poll_vendor(); // Eingehende Serial-Pakete (PC→Board) verarbeiten
|
||
void processEvents(); // Queue leeren, Aktionen ausführen
|
||
void execute_action(SAction); // Einzelne Aktion ausführen (HID / Serial)
|
||
void updateLEDs(); // Dirty-LEDs in WS2812-Buffer schreiben
|
||
|
||
// ── Config-Empfangspuffer ─────────────────────────────────────────────────
|
||
uint8_t m_cfg_buf[223]; // sizeof(SDeviceConfig) = 223 Bytes
|
||
uint8_t m_cfg_chunks_expected;
|
||
bool m_cfg_receiving;
|
||
|
||
// ── Makro-Empfangspuffer ──────────────────────────────────────────────────
|
||
uint8_t m_macro_buf[256]; // sizeof(SMacroTable) = 256 Bytes
|
||
uint8_t m_macro_chunks_expected;
|
||
bool m_macro_receiving;
|
||
|
||
// Geladene Makro-Tabelle (im RAM – wird beim Start aus NVM geladen)
|
||
SMacroTable m_macros;
|
||
};
|