-- Leo's gemini proxy

-- Connecting to shit.cx:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini;

shit.cx


The Keyboard Is Running


2021-01-19T05:58


Two nights ago, I got QMK to compile for a full keyboard. The single-key firmware that I was testing with didn't allow for an entire keymap and a new keyboard didn't compile for a Teensy LC. After wrestle with that for a while I managed to get it compiling.


But before I could use it, I need to configure it for my buttons. That's done in three steps: configuring the pins on the microcontroller, defining where in the matrix keys exist, and the function of the attached keys.


Configuring the Microcontroller Pins


This is how the matrix is configured. One array lists the pins that make up the rows and another for the pins that make up the columns. The config looks like this:


#define MATRIX_ROW_PINS { C0, B0, B1, B3, B2, D5 }
#define MATRIX_COL_PINS { D1, C5, C7, C6, C4, C3, D3, D2, D4, D7, A2, A1, D0, B17, B16 }

Defining the Shape of the Keyboard


This sets where in the matrix the keys sit. The top-left position would connect the first row pin to the first column pin, or C0 to D1.


#define LAYOUT(                                                                                                  \
      k00,   k01,   k02,   k03,   k04,   k05,   k06,   k07,   k08,   k09,          k0b,   k0c,   k0d,   k0e,     \
      k10,   k11,   k12,   k13,   k14,   k15,   k16,   k17,   k18,   k19,   k1a,   k1b,   k1c,   k1d,   k1e,     \
      k20,   k21,   k22,   k23,   k24,   k25,   k26,   k27,   k28,   k29,   k2a,   k2b,   k2c,   k2d,            \
      k30,   k31,   k32,   k33,   k34,   k35,   k36,   k37,   k38,   k39,   k3a,   k3b,          k3d,            \
      k40,   k41,   k42,   k43,   k44,   k45,   k46,   k47,   k48,   k49,   k4a,                 k4d,            \
             k51,   k52,   k53,          k55,          k57,   k58,          k5a,   k5b,          k5d,   k5e      \
) {                                                                                                              \
    { k00,   k01,   k02,   k03,   k04,   k05,   k06,   k07,   k08,   k09,   KC_NO, k0b,   k0c,   k0d,   k0e },   \
    { k10,   k11,   k12,   k13,   k14,   k15,   k16,   k17,   k18,   k19,   k1a,   k1b,   k1c,   k1d,   k1e },   \
    { k20,   k21,   k22,   k23,   k24,   k25,   k26,   k27,   k28,   k29,   k2a,   k2b,   k2c,   k2d,   KC_NO }, \
    { k30,   k31,   k32,   k33,   k34,   k35,   k36,   k37,   k38,   k39,   k3a,   k3b,   KC_NO, k3d,   KC_NO }, \
    { k40,   k41,   k42,   k43,   k44,   k45,   k46,   k47,   k48,   k49,   k4a,   KC_NO, KC_NO, k4d,   KC_NO }, \
    { KC_NO, k51,   k52,   k53,   KC_NO, k55,   KC_NO, k57,   k58,   KC_NO, k5a,   k5b,   KC_NO, k5d,   k5e   }  \
}

Giving Each Button a Function.


With the layout, we map a function to each of the buttons. In this keymap, I have two layers; the base layer and the layer that is enabled while the Fn key is pressed.


const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* Base Layer
     * ┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐ ┌───┬───┐
     * │ F1│ F2│ F3│ F4││ F5│ F6│ F7│ F8││ F9│F10│F11│F12│ │ V-│ V+│
     * ╞═══╪═══╪═══╪═══╪╧══╤╧══╤╧══╤╧══╤╧╧═╤═╧═╤═╧═╤═╧═╤═╧═╪═══╪═══╡
     * │Esc│  1│  2│  3│  4│  5│  6│  7│  8│  9│  0│  -│  =│  \│  `│
     * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┤
     * │ Tab │  Q│  W│  E│  R│  T│  Y│  U│  I│  O│  P│  [│  ]│ Bksp│
     * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
     * │ Ctrl │  A│  S│  D│  F│  G│  H│  J│  K│  L│  ;│  '│  Enter │
     * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
     * │  Shift │  Z│  X│  C│  V│  B│  N│  M│  ,│  .│  /│  Shift   │
     * └────┬───┴┬──┼───┼───┴─┬─┴───┴───┼───┴┬──┴┬─┬┴──┬┴──┬───┬───┤
     *      │Tmux│  │ Fn│ Cmd │  Space  │ Alt│ Fn│ │ ← │ ↓ │ ↑ │ → │
     *      └────┘  └───┴─────┴─────────┴────┴───┘ └───┴───┴───┴───┘
     */

    [_BASE] = LAYOUT(
        KC_F1,   KC_F2,   KC_F3,   KC_F4,     KC_F5,   KC_F6,   KC_F7,   KC_F8,     KC_F9,   KC_F10,   KC_F11,   KC_F12,        KC_VOLD,   KC_VOLU,
        KC_ESC,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,     KC_0,     KC_MINS,  KC_EQL,   KC_BSLS,   KC_GRV,
        KC_TAB,    KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,    KC_U,    KC_I,    KC_O,    KC_P,    KC_LBRC,  KC_RBRC,  KC_BSPC,
        KC_LCTL,    KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_J,    KC_K,    KC_L,    KC_SCLN, KC_QUOT,            KC_ENTER,
        KC_LSHIFT,    KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,    KC_M,    KC_COMM,  KC_DOT,  KC_SLSH,                  KC_RSHIFT,
             KC_F4,          MO(_FN),    KC_LCMD,   KC_SPACE,   KC_RALT, MO(_FN),                     KC_LEFT,     KC_DOWN,     KC_UP,     KC_RGHT
    ),

    /* Function Layer
     * ┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐ ┌───┬───┐
     * │   │   │   │   ││   │   │   │   ││   │   │   │   │ │   │   │
     * ╞═══╪═══╪═══╪═══╪╧══╤╧══╤╧══╤╧══╤╧╧═╤═╧═╤═╧═╤═╧═╤═╧═╪═══╪═══╡
     * │Esc│   │   │   │   │   │   │   │   │   │   │   │   │   │   │
     * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┤
     * │ Tab │   │   │End│   │   │   │PgU│   │   │   │   │   │ Del │
     * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
     * │ Ctrl │Hom│   │PgD│   │   │ ← │ ↓ │ ↑ │ → │   │   │  Enter │
     * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
     * │  Shift │   │   │   │   │   │   │   │   │   │   │  Shift   │
     * └────┬───┴┬──┼───┼───┴─┬─┴───┴───┼───┴┬──┴┬─┬┴──┬┴──┬───┬───┤
     *      │Tmux│  │ Fn│ Cmd │  Space  │ Alt│ Fn│ │ ← │ ↓ │ ↑ │ → │
     *      └────┘  └───┴─────┴─────────┴────┴───┘ └───┴───┴───┴───┘
     */
    [_FN] = LAYOUT(
        KC_NO,   KC_NO,   KC_NO,   KC_NO,     KC_NO,   KC_NO,   KC_NO,   KC_NO,     KC_NO,   KC_NO,    KC_NO,    KC_NO,         KC_NO,     KC_NO,
        _______, KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,
        _______,   KC_NO,   KC_NO,   KC_END,  KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_PGUP, KC_NO,    KC_NO,    KC_DEL,
        _______,    KC_HOME, KC_NO,   KC_PGDN, KC_NO,   KC_NO,   KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT, KC_NO,   KC_NO,              _______,
        _______,      KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,    KC_NO,   KC_NO,                    _______,
             _______,        _______,    _______,   _______,    _______, _______,                     KC_NO,       KC_NO,       KC_NO,     KC_NO
    )
};

After that compiles, I wrote the hex to the controller, and fixed all the problems.¹ Then had a working keyboard.


¹ The problems were: Looking at the bottom of the switches and the top of the keys caused my to layout the columns in reverse to how they should have been. There were a couple of buttons that were a little too tight still and needed to be filed out. That was made very easy by the fact that the columns and rows weren't insulated over with tape. And the stabiliser for the enter key needed some tuning.



---


More Posts Like This

Return to Homepage


The content for this site is CC-BY-SA-4.0.

-- Response ended

-- Page fetched on Fri Apr 26 07:59:23 2024