69 lines
3.1 KiB
C
69 lines
3.1 KiB
C
#pragma once
|
||
// VersaPad v2 – Logical pin names
|
||
// All Arduino pin numbers reference the custom variant (variants/versapad/variant.h)
|
||
|
||
// ─── Button Matrix ────────────────────────────────────────────────────────────
|
||
// Layout (viewed from front):
|
||
//
|
||
// COL_0 COL_1 COL_2 COL_3 COL_4
|
||
// ROW_0 [ENC3] [ ] [ ] [ ] [ ]
|
||
// ROW_1 [ENC2] [ ] [ ] [ ] [ ]
|
||
// ROW_2 [ENC1] [ ] [ ] [ ] [ ]
|
||
// ROW_3 [ENC0] [ ] [ ] [ ] [ ]
|
||
// ROW_4 --- [ ] [ ] [ ] [ ]
|
||
//
|
||
// COL_0 × ROW_0–3 = encoder push buttons
|
||
// COL_1–4 × ROW_0–4 = 20 Cherry MX buttons
|
||
// COL_0 × ROW_4 = not connected
|
||
|
||
#define BTN_COL_COUNT 5
|
||
#define BTN_ROW_COUNT 5
|
||
|
||
// Column pins: driven OUTPUT LOW during scan, otherwise INPUT (high-Z or HIGH)
|
||
static const uint8_t BTN_COLS[BTN_COL_COUNT] = {
|
||
PIN_COL0, // PB10 – encoder SW column
|
||
PIN_COL1, // PA11 – Cherry MX col 1 (leftmost)
|
||
PIN_COL2, // PA10 – Cherry MX col 2
|
||
PIN_COL3, // PA09 – Cherry MX col 3
|
||
PIN_COL4, // PA08 – Cherry MX col 4 (rightmost)
|
||
};
|
||
|
||
// Row pins: INPUT_PULLUP, read LOW when button pressed
|
||
static const uint8_t BTN_ROWS[BTN_ROW_COUNT] = {
|
||
PIN_ROW0, // PB11
|
||
PIN_ROW1, // PA12
|
||
PIN_ROW2, // PA13
|
||
PIN_ROW3, // PA14
|
||
PIN_ROW4, // PA15
|
||
};
|
||
|
||
// Button index helper: col * ROW_COUNT + row → 0..24
|
||
#define BTN_INDEX(col, row) ((col) * BTN_ROW_COUNT + (row))
|
||
|
||
// Encoder SW buttons are at column 0
|
||
#define BTN_ENC_SW(enc) BTN_INDEX(0, (enc)) // enc = 0..3
|
||
|
||
// ─── Rotary Encoders ──────────────────────────────────────────────────────────
|
||
// ENC0 = closest to USB connector, ENC3 = furthest
|
||
|
||
static const uint8_t ENC_A[4] = { PIN_ENC0_A, PIN_ENC1_A, PIN_ENC2_A, PIN_ENC3_A };
|
||
static const uint8_t ENC_B[4] = { PIN_ENC0_B, PIN_ENC1_B, PIN_ENC2_B, PIN_ENC3_B };
|
||
|
||
// ─── WS2812 LEDs ─────────────────────────────────────────────────────────────
|
||
#define LED_COUNT 20
|
||
#define LED_DATA_PIN PIN_SPI_MOSI // PB22, SERCOM5 PAD2
|
||
|
||
// LED index: serpentine (even rows L→R, odd rows R→L)
|
||
// Row 0: 0,1,2,3 Row 1: 7,6,5,4 Row 2: 8,9,10,11 Row 3: 15,14,13,12 Row 4: 16,17,18,19
|
||
#define LED_COLS (BTN_COL_COUNT - 1) // 4 Cherry MX columns
|
||
#define LED_INDEX(col, row) \
|
||
((row) * LED_COLS + (((row) & 1) ? (LED_COLS - (col)) : ((col) - 1)))
|
||
|
||
// ─── Faders (ADC) ─────────────────────────────────────────────────────────────
|
||
#define FADER_COUNT 3
|
||
static const uint8_t FADER_PINS[FADER_COUNT] = {
|
||
PIN_FADER0, // PA02 A0
|
||
PIN_FADER1, // PA03 A1 (also VREFA – analog only, no digitalRead)
|
||
PIN_FADER2, // PB08 A2
|
||
};
|