From 5de655023e7d66ecaaba73d85409468aa95a701a Mon Sep 17 00:00:00 2001 From: yiancar Date: Tue, 9 Aug 2022 18:40:32 +0100 Subject: [PATCH] [Keyboard] Add NK20 (#17907) Co-authored-by: Joel Challis Co-authored-by: yiancar --- keyboards/novelkeys/nk20/config.h | 131 ++++++++++++++++++ keyboards/novelkeys/nk20/halconf.h | 21 +++ keyboards/novelkeys/nk20/info.json | 16 +++ .../novelkeys/nk20/keymaps/default/keymap.c | 34 +++++ .../novelkeys/nk20/keymaps/default/readme.md | 9 ++ keyboards/novelkeys/nk20/keymaps/via/keymap.c | 50 +++++++ .../novelkeys/nk20/keymaps/via/readme.md | 9 ++ keyboards/novelkeys/nk20/keymaps/via/rules.mk | 1 + keyboards/novelkeys/nk20/mcuconf.h | 22 +++ keyboards/novelkeys/nk20/nk20.c | 40 ++++++ keyboards/novelkeys/nk20/nk20.h | 38 +++++ keyboards/novelkeys/nk20/readme.md | 32 +++++ keyboards/novelkeys/nk20/rules.mk | 29 ++++ 13 files changed, 432 insertions(+) create mode 100644 keyboards/novelkeys/nk20/config.h create mode 100644 keyboards/novelkeys/nk20/halconf.h create mode 100644 keyboards/novelkeys/nk20/info.json create mode 100644 keyboards/novelkeys/nk20/keymaps/default/keymap.c create mode 100644 keyboards/novelkeys/nk20/keymaps/default/readme.md create mode 100644 keyboards/novelkeys/nk20/keymaps/via/keymap.c create mode 100644 keyboards/novelkeys/nk20/keymaps/via/readme.md create mode 100644 keyboards/novelkeys/nk20/keymaps/via/rules.mk create mode 100644 keyboards/novelkeys/nk20/mcuconf.h create mode 100644 keyboards/novelkeys/nk20/nk20.c create mode 100644 keyboards/novelkeys/nk20/nk20.h create mode 100644 keyboards/novelkeys/nk20/readme.md create mode 100644 keyboards/novelkeys/nk20/rules.mk diff --git a/keyboards/novelkeys/nk20/config.h b/keyboards/novelkeys/nk20/config.h new file mode 100644 index 00000000000..7b56d50c6f6 --- /dev/null +++ b/keyboards/novelkeys/nk20/config.h @@ -0,0 +1,131 @@ +/* +Copyright 2022 Yiancar + +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" + +/* key matrix size */ +#define MATRIX_ROWS 6 +#define MATRIX_COLS 4 + +#define MATRIX_ROW_PINS { B12, A5, A3, A2, A1, A0 } +#define MATRIX_COL_PINS { B13, B14, B15, A4 } + +/* COL2ROW, ROW2COL*/ +#define DIODE_DIRECTION COL2ROW + +/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ +#define DEBOUNCE 5 + +/* define if matrix has ghost (lacks anti-ghosting diodes) */ +// #define MATRIX_HAS_GHOST + +/* If defined, GRAVE_ESC will always act as ESC when CTRL is held. + * This is userful for the Windows task manager shortcut (ctrl+shift+esc). + */ +// #define GRAVE_ESC_CTRL_OVERRIDE + +/* + * Force NKRO + * + * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved + * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the + * makefile for this to work.) + * + * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) + * until the next keyboard reset. + * + * NKRO may prevent your keystrokes from being detected in the BIOS, but it is + * fully operational during normal computer usage. + * + * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) + * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by + * bootmagic, NKRO mode will always be enabled until it is toggled again during a + * power-up. + * + */ +// #define FORCE_NKRO + +/* Bootmagic Lite key configuration */ +#define BOOTMAGIC_LITE_ROW 0 +#define BOOTMAGIC_LITE_COLUMN 0 + +/* RGB options */ + +#define RGB_DI_PIN A7 +#define WS2812_PWM_DRIVER PWMD3 +#define WS2812_PWM_CHANNEL 2 +#define WS2812_PWM_PAL_MODE 1 +#define WS2812_DMA_STREAM STM32_DMA1_STREAM3 +#define WS2812_DMA_CHANNEL 3 + +#define RGBLED_NUM 20 +#define DRIVER_LED_TOTAL 20 +#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 210 +#define RGB_DISABLE_WHEN_USB_SUSPENDED +#define RGB_MATRIX_KEYPRESSES +#define RGB_MATRIX_FRAMEBUFFER_EFFECTS + +// RGB Matrix Animation modes. Explicitly enabled +// For full list of effects, see: +// https://docs.qmk.fm/#/feature_rgb_matrix?id=rgb-matrix-effects +#define ENABLE_RGB_MATRIX_ALPHAS_MODS +#define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN +#define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT +#define ENABLE_RGB_MATRIX_BREATHING +#define ENABLE_RGB_MATRIX_BAND_SAT +#define ENABLE_RGB_MATRIX_BAND_VAL +#define ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT +#define ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL +#define ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT +#define ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL +#define ENABLE_RGB_MATRIX_CYCLE_ALL +#define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT +#define ENABLE_RGB_MATRIX_CYCLE_UP_DOWN +#define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON +#define ENABLE_RGB_MATRIX_CYCLE_OUT_IN +#define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL +#define ENABLE_RGB_MATRIX_CYCLE_PINWHEEL +#define ENABLE_RGB_MATRIX_CYCLE_SPIRAL +#define ENABLE_RGB_MATRIX_DUAL_BEACON +#define ENABLE_RGB_MATRIX_RAINBOW_BEACON +#define ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS +#define ENABLE_RGB_MATRIX_RAINDROPS +#define ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS +#define ENABLE_RGB_MATRIX_HUE_BREATHING +#define ENABLE_RGB_MATRIX_HUE_PENDULUM +#define ENABLE_RGB_MATRIX_HUE_WAVE +#define ENABLE_RGB_MATRIX_PIXEL_RAIN +#define ENABLE_RGB_MATRIX_PIXEL_FLOW +#define ENABLE_RGB_MATRIX_PIXEL_FRACTAL +// enabled only if RGB_MATRIX_FRAMEBUFFER_EFFECTS is defined +#define ENABLE_RGB_MATRIX_TYPING_HEATMAP +#define ENABLE_RGB_MATRIX_DIGITAL_RAIN +// enabled only of RGB_MATRIX_KEYPRESSES or RGB_MATRIX_KEYRELEASES is defined +#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE +#define ENABLE_RGB_MATRIX_SOLID_REACTIVE +#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE +#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE +#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS +#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS +#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS +#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS +#define ENABLE_RGB_MATRIX_SPLASH +#define ENABLE_RGB_MATRIX_MULTISPLASH +#define ENABLE_RGB_MATRIX_SOLID_SPLASH +#define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH diff --git a/keyboards/novelkeys/nk20/halconf.h b/keyboards/novelkeys/nk20/halconf.h new file mode 100644 index 00000000000..ce14bc0c416 --- /dev/null +++ b/keyboards/novelkeys/nk20/halconf.h @@ -0,0 +1,21 @@ +/* Copyright 2022 Yiancar + * + * 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 + +#define HAL_USE_PWM TRUE + +#include_next diff --git a/keyboards/novelkeys/nk20/info.json b/keyboards/novelkeys/nk20/info.json new file mode 100644 index 00000000000..d6a714ea0b5 --- /dev/null +++ b/keyboards/novelkeys/nk20/info.json @@ -0,0 +1,16 @@ +{ + "keyboard_name": "NK20", + "manufacturer": "Yiancar-Designs", + "url": "www.yiancar-designs.com", + "maintainer": "Yiancar", + "usb": { + "vid": "0x8968", + "pid": "0x4E4E", + "device_version": "0.0.1" + }, + "layouts": { + "LAYOUT_all": { + "layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":0, "y":1}, {"x":1, "y":1}, {"x":2, "y":1}, {"x":3, "y":1}, {"x":0, "y":2}, {"x":1, "y":2}, {"x":2, "y":2}, {"x":3, "y":2, "h":2}, {"x":0, "y":3}, {"x":1, "y":3}, {"x":2, "y":3}, {"x":0, "y":4}, {"x":1, "y":4}, {"x":2, "y":4}, {"x":3, "y":4, "h":2}, {"x":0, "y":5, "w":2}, {"x":2, "y":5}] + } + } +} diff --git a/keyboards/novelkeys/nk20/keymaps/default/keymap.c b/keyboards/novelkeys/nk20/keymaps/default/keymap.c new file mode 100644 index 00000000000..4bd3c48da11 --- /dev/null +++ b/keyboards/novelkeys/nk20/keymaps/default/keymap.c @@ -0,0 +1,34 @@ +/* Copyright 2022 Yiancar + * + * 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 + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +[0] = LAYOUT_all( /* Base */ + KC_VOLD, KC_VOLU, KC_MUTE, + MO(1), KC_PSLS, KC_PAST, KC_PMNS, + KC_P7, KC_P8, KC_P9, KC_PPLS, + KC_P4, KC_P5, KC_P6, + KC_P1, KC_P2, KC_P3, KC_PENT, + KC_P0, KC_PDOT), + +[1] = LAYOUT_all( /* FN */ + KC_NLCK, KC_TRNS, KC_TRNS, + KC_TRNS, RGB_SPD, RGB_SPI, KC_TRNS, + RGB_TOG, RGB_MOD, RGB_HUD, KC_TRNS, + RGB_SAD, RGB_SAI, RGB_HUI, + RGB_VAD, RGB_VAI, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS) +}; diff --git a/keyboards/novelkeys/nk20/keymaps/default/readme.md b/keyboards/novelkeys/nk20/keymaps/default/readme.md new file mode 100644 index 00000000000..a0e56fb99e1 --- /dev/null +++ b/keyboards/novelkeys/nk20/keymaps/default/readme.md @@ -0,0 +1,9 @@ +# The default keymap for NK20 + +![Layer 0](https://i.imgur.com/ppJr9SO.png) + +Fn Layer: + +![Layer 1](https://i.imgur.com/wtO3GJ5.png) + +Default layer is normal Numpad. diff --git a/keyboards/novelkeys/nk20/keymaps/via/keymap.c b/keyboards/novelkeys/nk20/keymaps/via/keymap.c new file mode 100644 index 00000000000..e647dad0165 --- /dev/null +++ b/keyboards/novelkeys/nk20/keymaps/via/keymap.c @@ -0,0 +1,50 @@ +/* Copyright 2022 Yiancar + * + * 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 + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +[0] = LAYOUT_all( /* Base */ + KC_VOLD, KC_VOLU, KC_MUTE, + MO(1), KC_PSLS, KC_PAST, KC_PMNS, + KC_P7, KC_P8, KC_P9, KC_PPLS, + KC_P4, KC_P5, KC_P6, + KC_P1, KC_P2, KC_P3, KC_PENT, + KC_P0, KC_PDOT), + +[1] = LAYOUT_all( /* FN */ + KC_NLCK, KC_TRNS, KC_TRNS, + KC_TRNS, RGB_SPD, RGB_SPI, KC_TRNS, + RGB_TOG, RGB_MOD, RGB_HUD, KC_TRNS, + RGB_SAD, RGB_SAI, RGB_HUI, + RGB_VAD, RGB_VAI, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS), + +[2] = LAYOUT_all( /* Empty for dynamic keymaps */ + KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS), + +[3] = LAYOUT_all( /* Empty for dynamic keymaps */ + KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS) +}; diff --git a/keyboards/novelkeys/nk20/keymaps/via/readme.md b/keyboards/novelkeys/nk20/keymaps/via/readme.md new file mode 100644 index 00000000000..112a3032ea4 --- /dev/null +++ b/keyboards/novelkeys/nk20/keymaps/via/readme.md @@ -0,0 +1,9 @@ +# The default VIA keymap for NK20. VIA support enabled. + +![Layer 0](https://i.imgur.com/ppJr9SO.png) + +Fn Layer: + +![Layer 1](https://i.imgur.com/wtO3GJ5.png) + +Default layer is normal Numpad diff --git a/keyboards/novelkeys/nk20/keymaps/via/rules.mk b/keyboards/novelkeys/nk20/keymaps/via/rules.mk new file mode 100644 index 00000000000..1e5b99807cb --- /dev/null +++ b/keyboards/novelkeys/nk20/keymaps/via/rules.mk @@ -0,0 +1 @@ +VIA_ENABLE = yes diff --git a/keyboards/novelkeys/nk20/mcuconf.h b/keyboards/novelkeys/nk20/mcuconf.h new file mode 100644 index 00000000000..7cf6a48904d --- /dev/null +++ b/keyboards/novelkeys/nk20/mcuconf.h @@ -0,0 +1,22 @@ +/* Copyright 2022 Yiancar + * + * 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_next + +#undef STM32_PWM_USE_TIM3 +#define STM32_PWM_USE_TIM3 TRUE diff --git a/keyboards/novelkeys/nk20/nk20.c b/keyboards/novelkeys/nk20/nk20.c new file mode 100644 index 00000000000..207e2277dae --- /dev/null +++ b/keyboards/novelkeys/nk20/nk20.c @@ -0,0 +1,40 @@ +/* Copyright 2022 Yiancar + * + * 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 "nk20.h" + +#ifdef RGB_MATRIX_ENABLE +// clang-format off +led_config_t g_led_config = { { + { 0, 1, 2, NO_LED }, + { 6, 5, 4, 3 }, + { 7, 8, 9, 10 }, + { 13, 12, 11, NO_LED }, + { 14, 15, 16, 17 }, + { 19, NO_LED, 18, NO_LED }, +}, { + { 0,0 }, { 75,0 }, {149,0 }, {224,15 }, {149,15 }, { 75,15 }, { 0,15 }, { 0,27 }, { 75,27 }, {149,27 }, + {224,34 }, {149,40 }, { 75,40 }, { 0,40 }, { 0,52 }, { 75,52 }, {149,52 }, {224,58 }, {149,64 }, { 37,64 } +}, { + 1, 1, 1, + 1, 1, 1, 1, + 4, 4, 4, 1, + 4, 4, 4, + 4, 4, 4, 1, + 4, 4 +} }; +// clang-format on +#endif diff --git a/keyboards/novelkeys/nk20/nk20.h b/keyboards/novelkeys/nk20/nk20.h new file mode 100644 index 00000000000..62aa0e69d30 --- /dev/null +++ b/keyboards/novelkeys/nk20/nk20.h @@ -0,0 +1,38 @@ +/* Copyright 2022 Yiancar + * + * 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 + +#define XXX KC_NO + +#include "quantum.h" + +// This a shortcut to help you visually see your layout. + +#define LAYOUT_all( \ + K00, K01, K02, \ + K10, K11, K12, K13, \ + K20, K21, K22, K23, \ + K30, K31, K32, \ + K40, K41, K42, K43, \ + K50, K52 \ +) { \ + { K00, K01, K02, XXX }, \ + { K10, K11, K12, K13 }, \ + { K20, K21, K22, K23 }, \ + { K30, K31, K32, XXX }, \ + { K40, K41, K42, K43 }, \ + { K50, XXX, K52, XXX }, \ +} diff --git a/keyboards/novelkeys/nk20/readme.md b/keyboards/novelkeys/nk20/readme.md new file mode 100644 index 00000000000..7eb04b1359d --- /dev/null +++ b/keyboards/novelkeys/nk20/readme.md @@ -0,0 +1,32 @@ +# NK20 + +This is a standard fixed layout Numpad PCB. It supports VIA and full per-key RGB. + +* Keyboard Maintainer: [Yiancar](https://yiancar-designs.com/) and on [GitHub](https://github.com/yiancar) +* Hardware Supported: A Numpad keyboard with STM32F072CB or APM compatible +* Hardware Availability: https://novelkeys.com/ + +## Instructions + +### Build + +Make example for this keyboard (after setting up your build environment): + + make novelkeys/nk20:default + +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). + +### Reset + +- Unplug +- Hold Escape +- Plug In +- Unplug +- Release Escape + +### Flash + +- Unplug +- Hold Escape +- Plug In +- Flash using QMK Toolbox or dfu-util (`make novelkeys/nk20::dfu-util`) diff --git a/keyboards/novelkeys/nk20/rules.mk b/keyboards/novelkeys/nk20/rules.mk new file mode 100644 index 00000000000..230cc1ec147 --- /dev/null +++ b/keyboards/novelkeys/nk20/rules.mk @@ -0,0 +1,29 @@ +# MCU name +MCU = STM32F072 + +# Bootloader selection +BOOTLOADER = stm32-dfu + +# Wildcard to allow APM32 MCU +DFU_SUFFIX_ARGS = -v FFFF -p FFFF + +# Do not put the microcontroller into power saving mode +# when we get USB suspend event. We want it to keep updating +# backlight effects. +OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE + +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite +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 +NKRO_ENABLE = yes # Enable N-Key Rollover +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow +AUDIO_ENABLE = no # Audio output +RGB_MATRIX_ENABLE = yes # Enable Per-key RGB +RGB_MATRIX_DRIVER = WS2812 # Per-key RGB Drive +WS2812_DRIVER = pwm # Per-key RGB MCU Driver