Building QMK
QMK is actually really easy to work with. You need to edit 4 files.
info.json
This is where you tell QMK that you are using a RP2040 and let it know which GPIO pins your matrix is hooked up to. Initially I had my rows and columns in the wrong order and it resulted in my keymap being upside down and inverted. Changing the order of the GPIO pins in the config sorted this out.
{
"manufacturer": "n",
"keyboard_name": "tartarus_mech",
"maintainer": "n",
"bootloader": "rp2040",
"diode_direction": "COL2ROW",
"features": {
"bootmagic": true,
"command": false,
"console": false,
"extrakey": true,
"mousekey": true,
"nkro": true
},
"matrix_pins": {
"cols": ["GP5", "GP4", "GP3", "GP2", "GP1"],
"rows": ["GP9", "GP8", "GP7", "GP6", "GP10", "GP11"]
},
"processor": "RP2040",
"url": "",
"usb": {
"device_version": "1.0.0",
"pid": "0x0000",
"vid": "0xFEED"
},
"layouts": {
"LAYOUT_tartarus_5x6": {
"layout": [
{"matrix": [0, 0], "x": 0, "y": 0},
{"matrix": [0, 1], "x": 1, "y": 0},
{"matrix": [0, 2], "x": 2, "y": 0},
{"matrix": [0, 3], "x": 3, "y": 0},
{"matrix": [0, 4], "x": 4, "y": 0},
{"matrix": [1, 0], "x": 0, "y": 1},
{"matrix": [1, 1], "x": 1, "y": 1},
{"matrix": [1, 2], "x": 2, "y": 1},
{"matrix": [1, 3], "x": 3, "y": 1},
{"matrix": [1, 4], "x": 4, "y": 1},
{"matrix": [2, 0], "x": 0, "y": 2},
{"matrix": [2, 1], "x": 1, "y": 2},
{"matrix": [2, 2], "x": 2, "y": 2},
{"matrix": [2, 3], "x": 3, "y": 2},
{"matrix": [2, 4], "x": 4, "y": 2},
{"matrix": [3, 0], "x": 0, "y": 3},
{"matrix": [3, 1], "x": 1, "y": 3},
{"matrix": [3, 2], "x": 2, "y": 3},
{"matrix": [3, 3], "x": 3, "y": 3},
{"matrix": [3, 4], "x": 4, "y": 3},
{"matrix": [4, 0], "x": 0, "y": 4},
{"matrix": [4, 1], "x": 1, "y": 4},
{"matrix": [4, 2], "x": 2, "y": 4},
{"matrix": [4, 3], "x": 3, "y": 4},
{"matrix": [4, 4], "x": 4, "y": 4},
{"matrix": [5, 0], "x": 0, "y": 5},
{"matrix": [5, 1], "x": 1, "y": 5},
{"matrix": [5, 2], "x": 2, "y": 5},
{"matrix": [5, 3], "x": 3, "y": 5},
{"matrix": [5, 4], "x": 4, "y": 5} ]
}
}
}
keymap.c
Here we tell QMK what key to send of each switch. We also tell it what the wheel should do.
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include QMK_KEYBOARD_H
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/*
* ┌───┬───┬───┬───┬───┐
* │esc│ 1 │ 2 │ 3 │ 4 │
* ├───┼───┼───┼───┼───┤
* │ b │ q │ w │ e │ r │
* ├───┼───┼───┼───┼───┤ Keypad
* │ n │ a │ s │ d │ f │
* ├───┼───┼───┼───┼───┤
* │ m │ z │ x │ c │ f │
* ├───┼───┼───┼───┼───┤
* │ 5 │ 6 │ 7 │ 8 │ 9 │ D-Pad
* ├───┼───┼───┼───┼───┤
* │ 0 │ │ │ │ │ Spacebar
* └───┴───┴───┴───┴───┘
*/
[0] = LAYOUT_tartarus_5x6(
KC_ESC, KC_1, KC_2, KC_3, KC_4,
KC_B, KC_Q, KC_W, KC_E, KC_R,
KC_N, KC_A, KC_S, KC_D, KC_F,
KC_M, KC_Z, KC_X, KC_C, KC_V,
KC_5, KC_6, KC_7, KC_8, KC_9,
KC_0, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX
)
};
#if defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
[0] = { ENCODER_CCW_CW(KC_MS_WH_UP, KC_MS_WH_DOWN) },
};
#endif
rules.mk
We enable the encoder wheel here.
ENCODER_ENABLE = yes
ENCODER_MAP_ENABLE = yes
config.h
And here we tell QMK how the encoder is hooked up and what its resolution is.
// Copyright 2024 n (@n)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
/*
* Feature disable options
* These options are also useful to firmware size reduction.
*/
/* disable debug print */
//#define NO_DEBUG
/* disable print */
//#define NO_PRINT
/* disable action features */
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
#define ENCODERS_PAD_A { GP28 }
#define ENCODERS_PAD_B { GP29 }
#define ENCODER_RESOLUTION 1