VersaMCU/src/CMainController.h

57 lines
2.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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 (024) als CButton-Array.
// key_id 03: Encoder-SW (kein LED), key_id 4: NC, key_id 524: 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;
};