VersaMCU/src/hal/matrix.h
2026-03-29 14:47:13 +02:00

22 lines
599 B
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.

#pragma once
#include <stdint.h>
// 5×5 button matrix
// COL_0 × ROW_03 = encoder SW buttons
// COL_14 × ROW_04 = 20 Cherry MX buttons
// COL_0 × ROW_4 = not connected
#define MATRIX_COLS 5
#define MATRIX_ROWS 5
#define MATRIX_KEYS 25 // col * MATRIX_ROWS + row
// Callback: key index (024), pressed = true / released = false
typedef void (*matrix_cb_t)(uint8_t key, bool pressed);
void matrix_init(matrix_cb_t cb);
void matrix_scan();
// Helper: key index from logical position
inline uint8_t matrix_key(uint8_t col, uint8_t row) {
return col * MATRIX_ROWS + row;
}