From 903028106154d8309d7880974b7e8cf68538f582 Mon Sep 17 00:00:00 2001 From: rabijl Date: Mon, 14 Aug 2023 09:16:26 +0300 Subject: [PATCH] rotary_pad: fix layout and enable encoder mapping * also updated readme with new diagram --- keyboards/rotary_numpad/info.json | 3 +- .../rotary_numpad/keymaps/default/keymap.c | 88 ++++++++++--------- keyboards/rotary_numpad/readme.md | 34 +++---- 3 files changed, 67 insertions(+), 58 deletions(-) diff --git a/keyboards/rotary_numpad/info.json b/keyboards/rotary_numpad/info.json index ae1c05ab2ab7..fa5ae1a0c4ab 100644 --- a/keyboards/rotary_numpad/info.json +++ b/keyboards/rotary_numpad/info.json @@ -15,7 +15,8 @@ "extrakey": true, "mousekey": true, "nkro": true, - "encoder": true + "encoder": true, + "encoder_map": true }, "development_board": "promicro", "diode_direction": "COL2ROW", diff --git a/keyboards/rotary_numpad/keymaps/default/keymap.c b/keyboards/rotary_numpad/keymaps/default/keymap.c index 7ad7f65d3e57..5b32f66e1c32 100644 --- a/keyboards/rotary_numpad/keymaps/default/keymap.c +++ b/keyboards/rotary_numpad/keymaps/default/keymap.c @@ -5,55 +5,62 @@ #include QMK_KEYBOARD_H const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - /* - * ┌───┬───┬───┬───┐ - * │Esc│Tab│MO1│Bsp│ - * ├───┼───┼───┼───┤ - * │Num│ / │ * │ - │ - * ├───┼───┼───┼───┤ - * │ 7 │ 8 │ 9 │ + │ - * ├───┼───┼───┼───┤ - * │ 4 │ 5 │ 6 │ r2│ - * ├───┼───┼───┼───┤ - * │ 1 │ 2 │ 3 │Ent│ - * ├───┼───┼───┼───┤ - * │ r3│ 0 │ . │ r1│ - * └───┴───┴───┴───┘ + /* + * ┌───┐┌───┬───┬───┬───┐ + * │Ply││Esc│Tab│MO1│Bsp│ + * └───┘├───┼───┼───┼───┤ + * │Num│ / │ * │ - │ + * ├───┼───┼───┼───┤ + * │ 7 │ 8 │ 9 │ │ + * ┌───┐├───┼───┼───┤ + │ + * │Esc││ 4 │ 5 │ 6 │ │ + * └───┘├───┼───┼───┼───┤ + * │ 1 │ 2 │ 3 │ │ + * ┌───┐├───┼───┼───┤Ent│ + * │ENT││ 0 │ . │ │ + * └───┘└───┴───┴───┴───┘ */ [0] = LAYOUT( - KC_ESC, KC_TAB, MO(1), KC_BSPC, - KC_NUM, KC_PSLS, KC_PAST, KC_PMNS, - KC_P7, KC_P8, KC_P9, KC_PPLS, - KC_P4, KC_P5, KC_P6, KC_ESC, - KC_P1, KC_P2, KC_P3, KC_PENT, - KC_MPLY, KC_P0, KC_PDOT, KC_ENT + KC_MPLY, KC_ESC, KC_TAB, MO(1), KC_BSPC, + KC_NUM, KC_PSLS, KC_PAST, KC_PMNS, + KC_P7, KC_P8, KC_P9, KC_PPLS, + KC_ESC, KC_P4, KC_P5, KC_P6, + KC_P1, KC_P2, KC_P3, KC_PENT, + KC_ENT, KC_P0, KC_PDOT ), - /* - * ┌───┐───┬───┬───┐ - * │Rst│Tab│MO1│Bsp│ - * └───┘───┼───┼───┤ - * │Num│ / │ * │ - │ - * ┌───┬───┬───┐───┤ - * │Hom│ ↑ │PgU│ │ - * ├───┼───┼───┤ + │ - * │ ← │ │ → │ │ - * ├───┼───┼───┤───┤ - * │End│ ↓ │PgD│ │ - * ├───┴───┼───┤Ent│ - * │Insert │Del│ │ - * └───────┴───┘───┘ + * ┌───┐┌───┬───┬───┬───┐ + * │Ply││Rst│Tab│MO1│Bsp│ + * └───┘├───┼───┼───┼───┤ + * │Num│ / │ * │ - │ + * ├───┼───┼───┼───┤ + * │Hom│ ↑ │PgU│ │ + * ┌───┐├───┼───┼───┤ + │ + * │Esc││ ← │ │ → │ │ + * └───┘├───┼───┼───┼───┤ + * │End│ ↓ │PgD│ │ + * ┌───┐├───┴───┼───┤Ent│ + * │ENT││Insert │Del│ │ + * └───┘└───────┴───┘───┘ */ [1] = LAYOUT( - QK_BOOT, _______, _______, _______, - _______, _______, _______, _______, - KC_HOME, KC_UP, KC_PGUP, _______, - KC_LEFT, XXXXXXX, KC_RGHT, _______, - KC_END, KC_DOWN, KC_PGDN, _______, - _______, KC_INS, KC_DEL, _______ + _______, QK_BOOT, _______, _______, _______, + _______, _______, _______, _______, + KC_HOME, KC_UP, KC_PGUP, _______, + _______, KC_LEFT, KC_NO, KC_RGHT, + KC_END, KC_DOWN, KC_PGDN, _______, + _______, KC_INS, KC_DEL ) }; +#if defined(ENCODER_MAP_ENABLE) + +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { + [0] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(KC_DOWN, KC_UP), ENCODER_CCW_CW(KC_LEFT, KC_RIGHT) }, + [1] = { ENCODER_CCW_CW(_______, _______), ENCODER_CCW_CW(KC_LEFT, KC_RIGHT), ENCODER_CCW_CW(_______, _______) }, +}; +#else + bool encoder_update_kb(uint8_t index, bool clockwise) { if (!encoder_update_user(index, clockwise)) { return false; /* Don't process further events if user function exists and returns false */ @@ -79,3 +86,4 @@ bool encoder_update_kb(uint8_t index, bool clockwise) { } return true; } +#endif diff --git a/keyboards/rotary_numpad/readme.md b/keyboards/rotary_numpad/readme.md index 68fcf12b7d9d..825e87953855 100644 --- a/keyboards/rotary_numpad/readme.md +++ b/keyboards/rotary_numpad/readme.md @@ -21,23 +21,23 @@ to be very useful to identify different pins. You can find useful information on ### matrix -Due to the three rotary encoders, I had to use most of the available pins. \ -I therefore fit their buttons into 6 x 4 matrix at strange positions. See the diagram below. \ -In this matrix r1, r2 and r3 are the buttons for each respective encoder. - \ -┌───┬───┬───┬───┐ \ -│Esc│Tab│MO1│Bsp│ \ -├───┼───┼───┼───┤ \ -│Num│\/ │ * │ - │ \ -├───┼───┼───┼───┤ \ -│ 7 │ 8 │ 9 │ + │ \ -├───┼───┼───┼───┤ \ -│ 4 │ 5 │ 6 │ r2│ \ -├───┼───┼───┼───┤ \ -│ 1 │ 2 │ 3 │Ent│ \ -├───┼───┼───┼───┤ \ -│ r3│ 0 │ . │ r1│ \ -└───┴───┴───┴───┘ +Due to the three rotary encoders, I had to use most of the available pins. Fortunately, all the buttons still fit in a 6x4 matrix. Looking at the diagram below, the three buttons in the first column correspond to each encoder button. + +``` +┌───┐┌───┬───┬───┬───┐ +│Ply││Esc│Tab│MO1│Bsp│ +└───┘├───┼───┼───┼───┤ + │Num│ / │ * │ - │ + ├───┼───┼───┼───┤ + │ 7 │ 8 │ 9 │ │ +┌───┐├───┼───┼───┤ + │ +│Esc││ 4 │ 5 │ 6 │ │ +└───┘├───┼───┼───┼───┤ + │ 1 │ 2 │ 3 │ │ +┌───┐├───┼───┼───┤Ent│ +│Ent││ 0 │ . │ │ +└───┘└───┴───┴───┴───┘ +``` ## Flashing