From c41c8ff780996d1d46673ae802bff4dbc3a035b8 Mon Sep 17 00:00:00 2001 From: rainsff <44819800+rainsff@users.noreply.github.com> Date: Fri, 27 Nov 2020 10:04:56 -0800 Subject: [PATCH] Add rainkeeb keyboard (#10875) * Add rainkeeb Add support for rainkeeb * gpl license added * updated * Apply suggestions from code review Co-authored-by: ridingqwerty * Apply suggestions from code review Co-authored-by: ridingqwerty * Update info.json * via keymap added * updated keymap and .h to work properly * fixed oled code oops Co-authored-by: ridingqwerty --- keyboards/rainkeeb/config.h | 51 +++++++++ keyboards/rainkeeb/info.json | 54 +++++++++ keyboards/rainkeeb/keymaps/default/keymap.c | 115 ++++++++++++++++++++ keyboards/rainkeeb/keymaps/via/keymap.c | 115 ++++++++++++++++++++ keyboards/rainkeeb/keymaps/via/rules.mk | 1 + keyboards/rainkeeb/rainkeeb.c | 16 +++ keyboards/rainkeeb/rainkeeb.h | 34 ++++++ keyboards/rainkeeb/readme.md | 24 ++++ keyboards/rainkeeb/rules.mk | 28 +++++ 9 files changed, 438 insertions(+) create mode 100644 keyboards/rainkeeb/config.h create mode 100644 keyboards/rainkeeb/info.json create mode 100644 keyboards/rainkeeb/keymaps/default/keymap.c create mode 100644 keyboards/rainkeeb/keymaps/via/keymap.c create mode 100644 keyboards/rainkeeb/keymaps/via/rules.mk create mode 100644 keyboards/rainkeeb/rainkeeb.c create mode 100644 keyboards/rainkeeb/rainkeeb.h create mode 100644 keyboards/rainkeeb/readme.md create mode 100644 keyboards/rainkeeb/rules.mk diff --git a/keyboards/rainkeeb/config.h b/keyboards/rainkeeb/config.h new file mode 100644 index 000000000..36c3a5d5b --- /dev/null +++ b/keyboards/rainkeeb/config.h @@ -0,0 +1,51 @@ +/* Copyright 2020 Regan Palmer + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0x726B // rk - "rainkeebs" +#define PRODUCT_ID 0x726B // rk - "rainkeeb" +#define DEVICE_VER 0x0001 +#define MANUFACTURER rainkeebs +#define PRODUCT rainkeeb + +/* key matrix size */ +#define MATRIX_ROWS 8 +#define MATRIX_COLS 6 + +/* key matrix pins */ +#define MATRIX_ROW_PINS { D3, D2, D4, C6, D7, E6, B4, B5 } +#define MATRIX_COL_PINS { F4, F5, F6, F7, B1, B3 } +#define UNUSED_PINS + +/* COL2ROW or ROW2COL */ +#define DIODE_DIRECTION COL2ROW + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCE 5 + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE + +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +/* encoder pads */ +#define ENCODERS_PAD_A { B2 } +#define ENCODERS_PAD_B { B6 } +#define ENCODER_RESOLUTION 4 diff --git a/keyboards/rainkeeb/info.json b/keyboards/rainkeeb/info.json new file mode 100644 index 000000000..bf0a7e2c9 --- /dev/null +++ b/keyboards/rainkeeb/info.json @@ -0,0 +1,54 @@ +{ + "keyboard_name": "rainkeeb", + "url": "", + "maintainer": "rain", + "width": 12, + "height": 4, + "layouts": { + "LAYOUT": { + "layout": [ + {"label":"k00", "x":0, "y":0}, + {"label":"k01", "x":1, "y":0}, + {"label":"k02", "x":2, "y":0}, + {"label":"k03", "x":3, "y":0}, + {"label":"k04", "x":4, "y":0}, + {"label":"k05", "x":7, "y":0}, + {"label":"k06", "x":8, "y":0}, + {"label":"k07", "x":9, "y":0}, + {"label":"k08", "x":10, "y":0}, + {"label":"k09", "x":11, "y":0}, + {"label":"k10", "x":0, "y":1}, + {"label":"k11", "x":1, "y":1}, + {"label":"k12", "x":2, "y":1}, + {"label":"k13", "x":3, "y":1}, + {"label":"k14", "x":4, "y":1}, + {"label":"k15", "x":5.5, "y":1}, + {"label":"k16", "x":7, "y":1}, + {"label":"k17", "x":8, "y":1}, + {"label":"k18", "x":9, "y":1}, + {"label":"k19", "x":10, "y":1}, + {"label":"k1a", "x":11, "y":1}, + {"label":"k20", "x":0, "y":2}, + {"label":"k21", "x":1, "y":2}, + {"label":"k22", "x":2, "y":2}, + {"label":"k23", "x":3, "y":2}, + {"label":"k24", "x":4, "y":2}, + {"label":"k25", "x":5.5, "y":2}, + {"label":"k26", "x":7, "y":2}, + {"label":"k27", "x":8, "y":2}, + {"label":"k28", "x":9, "y":2}, + {"label":"k29", "x":10, "y":2}, + {"label":"k2a", "x":11, "y":1}, + {"label":"k30", "x":0, "y":3}, + {"label":"k31", "x":1, "y":3}, + {"label":"k32", "x":2, "y":3}, + {"label":"k33", "x":3, "y":3, "w":2}, + {"label":"k34", "x":5, "y":3, "w":2}, + {"label":"k35", "x":7, "y":3, "w":2}, + {"label":"k36", "x":9, "y":3}, + {"label":"k37", "x":10, "y":3}, + {"label":"k38", "x":11, "y":3} + ] + } + } +} diff --git a/keyboards/rainkeeb/keymaps/default/keymap.c b/keyboards/rainkeeb/keymaps/default/keymap.c new file mode 100644 index 000000000..f68ab2ef0 --- /dev/null +++ b/keyboards/rainkeeb/keymaps/default/keymap.c @@ -0,0 +1,115 @@ +/* Copyright 2020 Regan Palmer + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include QMK_KEYBOARD_H + +enum layers { + _BASE, + _RAISE, + _ADJUST, + _GAME, +}; + +#define RAISE MO(_RAISE) +#define ADJUST MO(_ADJUST) +#define GAME TG(_GAME) +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = LAYOUT( + KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, + KC_A, KC_S, KC_D, KC_F, KC_G, KC_MPLY, KC_H, KC_J, KC_K, KC_L, KC_ENT, + KC_Z, KC_X, KC_C, KC_V, KC_B, KC_PSCR, KC_N, KC_M, KC_COMM, KC_DOT, KC_BSPC, + KC_LCTL, KC_LALT, KC_LGUI, KC_LSFT, RAISE, KC_SPC, KC_RGUI, KC_RALT, KC_RCTL), + + [_RAISE] = LAYOUT( + KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, + KC_ESC, KC_GRV, KC_BSLS, KC_UP, KC_MINS, KC_TRNS, KC_LBRC, KC_RBRC, KC_SCLN, KC_QUOT, KC_TRNS, + KC_TAB, KC_CAPS, KC_LEFT, KC_DOWN, KC_RGHT, ADJUST, KC_EQL, KC_SLSH, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + [_ADJUST] = 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_F13, KC_F14, KC_F15, GAME, KC_HOME, KC_PGDN, KC_PGUP, KC_END, KC_TRNS, + RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + [_GAME] = LAYOUT( + KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, + KC_A, KC_S, KC_D, KC_F, KC_G, GAME, KC_H, KC_J, KC_K, KC_L, KC_ENT, + KC_Z, KC_X, KC_C, KC_V, KC_B, KC_PSCR, KC_N, KC_M, KC_COMM, KC_DOT, KC_BSPC, + KC_LCTL, KC_LALT, KC_LGUI, KC_LSFT, KC_NO, KC_SPC, KC_RGUI, KC_RALT, KC_RCTL) +}; + +void encoder_update_user(uint8_t index, bool clockwise) { + switch (get_highest_layer(layer_state)) { + case _BASE: + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + break; + case _RAISE: + if (clockwise) { + tap_code(KC_MS_WH_DOWN); + } else { + tap_code(KC_MS_WH_UP); + } + break; + case _ADJUST: + if (clockwise) { + tap_code(KC_MS_WH_RIGHT); + } else { + tap_code(KC_MS_WH_LEFT); + } + break; + case _GAME: + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + break; + } +} + +char wpm[10]; + +void oled_task_user(void) { + sprintf(wpm, "WPM: %03d", get_current_wpm()); + + // Host Keyboard Layer Status + oled_write_P(PSTR(" rainkeeb \n"), false); + oled_write_P(PSTR(" Layer: "), false); + + switch (get_highest_layer(layer_state)) { + case _BASE: + oled_write_P(PSTR("Default\n"), false); + break; + case _RAISE: + oled_write_P(PSTR("Raise\n"), false); + break; + case _ADJUST: + oled_write_P(PSTR("Adjust\n"), false); + break; + case _GAME: + oled_write_P(PSTR("Game\n"), false); + break; + default: + // Or use the write_ln shortcut over adding '\n' to the end of your string + oled_write_ln_P(PSTR("Undefined"), false); + } + oled_write_P(PSTR(" "), false); + oled_write(wpm, false); +} diff --git a/keyboards/rainkeeb/keymaps/via/keymap.c b/keyboards/rainkeeb/keymaps/via/keymap.c new file mode 100644 index 000000000..f68ab2ef0 --- /dev/null +++ b/keyboards/rainkeeb/keymaps/via/keymap.c @@ -0,0 +1,115 @@ +/* Copyright 2020 Regan Palmer + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include QMK_KEYBOARD_H + +enum layers { + _BASE, + _RAISE, + _ADJUST, + _GAME, +}; + +#define RAISE MO(_RAISE) +#define ADJUST MO(_ADJUST) +#define GAME TG(_GAME) +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = LAYOUT( + KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, + KC_A, KC_S, KC_D, KC_F, KC_G, KC_MPLY, KC_H, KC_J, KC_K, KC_L, KC_ENT, + KC_Z, KC_X, KC_C, KC_V, KC_B, KC_PSCR, KC_N, KC_M, KC_COMM, KC_DOT, KC_BSPC, + KC_LCTL, KC_LALT, KC_LGUI, KC_LSFT, RAISE, KC_SPC, KC_RGUI, KC_RALT, KC_RCTL), + + [_RAISE] = LAYOUT( + KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, + KC_ESC, KC_GRV, KC_BSLS, KC_UP, KC_MINS, KC_TRNS, KC_LBRC, KC_RBRC, KC_SCLN, KC_QUOT, KC_TRNS, + KC_TAB, KC_CAPS, KC_LEFT, KC_DOWN, KC_RGHT, ADJUST, KC_EQL, KC_SLSH, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + [_ADJUST] = 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_F13, KC_F14, KC_F15, GAME, KC_HOME, KC_PGDN, KC_PGUP, KC_END, KC_TRNS, + RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + [_GAME] = LAYOUT( + KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, + KC_A, KC_S, KC_D, KC_F, KC_G, GAME, KC_H, KC_J, KC_K, KC_L, KC_ENT, + KC_Z, KC_X, KC_C, KC_V, KC_B, KC_PSCR, KC_N, KC_M, KC_COMM, KC_DOT, KC_BSPC, + KC_LCTL, KC_LALT, KC_LGUI, KC_LSFT, KC_NO, KC_SPC, KC_RGUI, KC_RALT, KC_RCTL) +}; + +void encoder_update_user(uint8_t index, bool clockwise) { + switch (get_highest_layer(layer_state)) { + case _BASE: + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + break; + case _RAISE: + if (clockwise) { + tap_code(KC_MS_WH_DOWN); + } else { + tap_code(KC_MS_WH_UP); + } + break; + case _ADJUST: + if (clockwise) { + tap_code(KC_MS_WH_RIGHT); + } else { + tap_code(KC_MS_WH_LEFT); + } + break; + case _GAME: + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + break; + } +} + +char wpm[10]; + +void oled_task_user(void) { + sprintf(wpm, "WPM: %03d", get_current_wpm()); + + // Host Keyboard Layer Status + oled_write_P(PSTR(" rainkeeb \n"), false); + oled_write_P(PSTR(" Layer: "), false); + + switch (get_highest_layer(layer_state)) { + case _BASE: + oled_write_P(PSTR("Default\n"), false); + break; + case _RAISE: + oled_write_P(PSTR("Raise\n"), false); + break; + case _ADJUST: + oled_write_P(PSTR("Adjust\n"), false); + break; + case _GAME: + oled_write_P(PSTR("Game\n"), false); + break; + default: + // Or use the write_ln shortcut over adding '\n' to the end of your string + oled_write_ln_P(PSTR("Undefined"), false); + } + oled_write_P(PSTR(" "), false); + oled_write(wpm, false); +} diff --git a/keyboards/rainkeeb/keymaps/via/rules.mk b/keyboards/rainkeeb/keymaps/via/rules.mk new file mode 100644 index 000000000..036bd6d1c --- /dev/null +++ b/keyboards/rainkeeb/keymaps/via/rules.mk @@ -0,0 +1 @@ +VIA_ENABLE = yes \ No newline at end of file diff --git a/keyboards/rainkeeb/rainkeeb.c b/keyboards/rainkeeb/rainkeeb.c new file mode 100644 index 000000000..b13ecb248 --- /dev/null +++ b/keyboards/rainkeeb/rainkeeb.c @@ -0,0 +1,16 @@ +/* Copyright 2020 Regan Palmer + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include "rainkeeb.h" \ No newline at end of file diff --git a/keyboards/rainkeeb/rainkeeb.h b/keyboards/rainkeeb/rainkeeb.h new file mode 100644 index 000000000..f0179f087 --- /dev/null +++ b/keyboards/rainkeeb/rainkeeb.h @@ -0,0 +1,34 @@ +/* Copyright 2020 Regan Palmer + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +#include "quantum.h" + +#define LAYOUT( \ + K00, K10, K01, K11, K02, K13, K03, K14, K04, K15, \ + K20, K30, K21, K31, K22, K32, K23, K33, K24, K34, K25, \ + K40, K50, K41, K51, K42, K52, K43, K53, K44, K54, K45, \ + K60, K70, K61, K72, K62, K73, K64, K74, K65 \ +) { \ + { K00, K01, K02, K03, K04, KC_NO }, \ + { K10, K11, KC_NO, K13, K14, K15 }, \ + { K20, K21, K22, K23, K24, K25 }, \ + { K30, K31, K32, K33, K34, KC_NO }, \ + { K40, K41, K42, K43, K44, K45 }, \ + { K50, K51, K52, K53, K54, KC_NO }, \ + { K60, K61, K62, KC_NO, K64, K65 }, \ + { K70, KC_NO, K72, K73, K74, KC_NO } \ +} diff --git a/keyboards/rainkeeb/readme.md b/keyboards/rainkeeb/readme.md new file mode 100644 index 000000000..f2c759ebe --- /dev/null +++ b/keyboards/rainkeeb/readme.md @@ -0,0 +1,24 @@ +# rainkeeb + +![rainkeeb](https://i.imgur.com/GpVBRMw.jpg) + +My first custom mech design. 4x10(ish), pro micro based, unibody, split, ortho (any more adjectives?), with OLED and (optional) rotary encoder. + +![Default layout](https://i.imgur.com/rCOwsoy.png) +This is the default layout, at least the base layer. By default the OLED displays "rainkeeb" at the top in case you forget what you're typing on, a layer indicator below that (Default, Raised, Alt), and a WPM counter below that. Encoder toggles Play/Pause on click on the Default and Raised layers, and is supposed to RESET into flash-mode on the Alt layer but that's not working for some reason. Clockwise turn increases volume, scrolls down, and scrolls right on the Default, Raise, and Alt layers respectively. Counterclockwise does the opposite of the clockwise turns, you get the picture. + +* Keyboard Maintainer: [rain](https://github.com/rainsff) +* Hardware Supported: rainkeeb PCB v1 +* Hardware Availability: GB soon + +Make example for this keyboard (after setting up your build environment): + + make rainkeeb:default + +To put reset into bootloader mode just push the reset button from the left side of the board using a pair of tweezers or similar object. + +Install example for this keyboard: + + make rainkeeb:default:flash + +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). diff --git a/keyboards/rainkeeb/rules.mk b/keyboards/rainkeeb/rules.mk new file mode 100644 index 000000000..aa9aab9b7 --- /dev/null +++ b/keyboards/rainkeeb/rules.mk @@ -0,0 +1,28 @@ +# MCU name +MCU = atmega32u4 + +# Bootloader selection +BOOTLOADER = caterina + +# Build Options +# comment out to disable the options. +# +BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = no # Commands for debug and configuration +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +AUDIO_ENABLE = no +RGBLIGHT_ENABLE = no + +# OLED enable +OLED_DRIVER_ENABLE = yes + +# Encoder enable +ENCODER_ENABLE = yes + +# WPM counter enable +WPM_ENABLE = yes