Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotary numpad #21744

Merged
merged 12 commits into from
Sep 25, 2023
27 changes: 27 additions & 0 deletions keyboards/rotary_numpad/config.h
RABijl marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2023 rabijl (@rabijl)
// 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

// it seems that declaring encoder pins in info.json
// is not working exactly and compilation fails when
// this macro is not set. But it will warn that the
// encoders have been declared twice ¯\_(ツ)_/¯
#define ENCODERS_PAD_A { D1, D4, D7}
#define ENCODERS_PAD_B { D0, C6, E6}
64 changes: 64 additions & 0 deletions keyboards/rotary_numpad/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"manufacturer": "rabijl",
"keyboard_name": "rotary_numpad",
"maintainer": "rabijl",
"bootloader": "caterina",
"diode_direction": "COL2ROW",
"features": {
"bootmagic": true,
"command": false,
"console": false,
"extrakey": true,
"mousekey": true,
"nkro": true,
"encoder": true
},
"matrix_pins": {
"cols": ["F5", "F4", "B5", "B4"],
"rows": ["F6", "F7", "B1", "B3", "B2", "B6"]
},
"processor": "atmega32u4",
RABijl marked this conversation as resolved.
Show resolved Hide resolved
"url": "",
"usb": {
"device_version": "1.0.0",
"pid": "0x0000",
"vid": "0xFEED"
},
"layouts": {
"LAYOUT_numpad_6x4": {
RABijl marked this conversation as resolved.
Show resolved Hide resolved
"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": [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": [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": [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": [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": [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}
]
}
},
"encoder": {
"rotary": [
{"pin_a": "D1", "pin_b": "D0", "resolution": 1},
{"pin_a": "D4", "pin_b": "C6", "resolution": 1},
{"pin_a": "D7", "pin_b": "E6", "resolution": 1}
]
}
}
81 changes: 81 additions & 0 deletions keyboards/rotary_numpad/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// 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│Tab│MO1│Bsp│
* ├───┼───┼───┼───┤
* │Num│ / │ * │ - │
* ├───┼───┼───┼───┤
* │ 7 │ 8 │ 9 │ + │
* ├───┼───┼───┼───┤
* │ 4 │ 5 │ 6 │ r2│
* ├───┼───┼───┼───┤
* │ 1 │ 2 │ 3 │Ent│
* ├───┼───┼───┼───┤
* │ r3│ 0 │ . │ r1│
* └───┴───┴───┴───┘
*/
[0] = LAYOUT_numpad_6x4(
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
),

/*
* ┌───┐───┬───┬───┐
* │Rst│Tab│MO1│Bsp│
* └───┘───┼───┼───┤
* │Num│ / │ * │ - │
* ┌───┬───┬───┐───┤
* │Hom│ ↑ │PgU│ │
* ├───┼───┼───┤ + │
* │ ← │ │ → │ │
* ├───┼───┼───┤───┤
* │End│ ↓ │PgD│ │
* ├───┴───┼───┤Ent│
* │Insert │Del│ │
* └───────┴───┘───┘
*/
[1] = LAYOUT_numpad_6x4(
QK_BOOT, _______, _______, _______,
_______, _______, _______, _______,
KC_HOME, KC_UP, KC_PGUP, _______,
KC_LEFT, XXXXXXX, KC_RGHT, _______,
KC_END, KC_DOWN, KC_PGDN, _______,
_______, KC_INS, KC_DEL, _______
)
};

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 */
}
if (index == 0) { /* First encoder */
if (clockwise) {
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
}
} else if (index == 1) { /* Second encoder */
if (clockwise) {
tap_code(KC_UP);
} else {
tap_code(KC_DOWN);
}
} else if (index == 2) { /* Third encoder */
if (clockwise) {
tap_code(KC_RIGHT);
} else {
tap_code(KC_LEFT);
}
}
return true;
}
68 changes: 68 additions & 0 deletions keyboards/rotary_numpad/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Rotary Numpad


![rotary_numpad](https://i.imgur.com/GwEH4WO.jpeg)
RABijl marked this conversation as resolved.
Show resolved Hide resolved

*A short description of the keyboard/project*

* Keyboard Maintainer: [rabijl](https://github.com/rabijl)
* Hardware Supported: Sparkfun Pro Micro 5V (atmega32u4)
* Hardware Availability: https://www.sparkfun.com/products/12640

This is a personal project of mine where I wanted a number pad that I can put on the left \
side of keyboard that doesn't have a numberpad. I fell in love with the feel of rotary encoders \
on my 3d printer, so added three to be able to play around with.
RABijl marked this conversation as resolved.
Show resolved Hide resolved

## How to build from scratch

I handsoldered gateron blue switches to a 3D printed case. The design is modified from the [Ultipad](https://www.thingiverse.com/thing:4248565). \
I used a sparkfun Pro Micro as my microcontroller and the pinout can be found in the `info.json`. I found this [site](https://golem.hu/article/pro-micro-pinout/) \
to be very useful to identify different pins. You can find useful information on rotary encoders from the qmk docs [here](https://docs.qmk.fm/#/reference_info_json?id=encoders) and [here](https://docs.qmk.fm/#/feature_encoders).

### matrix
RABijl marked this conversation as resolved.
Show resolved Hide resolved

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│ \
└───┴───┴───┴───┘

## Flashing

Make example for this keyboard (after setting up your build environment): \
**note:** you may need to run this in the root of the repository for this to work

```
qmk compile -kb rotary_numpad -km default
```

Flashing example for this keyboard:

```
qmk flash -kb rotary_numpad -km default
```
RABijl marked this conversation as resolved.
Show resolved Hide resolved

See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).

## Bootloader

Enter the bootloader in 3 ways:
RABijl marked this conversation as resolved.
Show resolved Hide resolved

* **Short reset leads**: tab the reset lead to ground twice quickly after qmk is in flash mode
* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available

**Note:** if the keyboard doesn't show up after putting the keyboard in reset mode, check that
your user is added to the `tty` and/or `uucp` groups. \
You may need to logout after adding these groups to your user, for the changes to take affect.
1 change: 1 addition & 0 deletions keyboards/rotary_numpad/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# file intentionally left blank