From 0bada398dfba61c93ee5dbec0aeb92b8af0f45a4 Mon Sep 17 00:00:00 2001 From: nut1414 Date: Thu, 13 May 2021 08:27:16 +0700 Subject: [PATCH] [Keyboard] Add np12 (#12703) Co-authored-by: Ryan --- keyboards/np12/config.h | 45 ++++++++++++++++++ keyboards/np12/info.json | 26 ++++++++++ keyboards/np12/keymaps/default/keymap.c | 60 ++++++++++++++++++++++++ keyboards/np12/keymaps/default/readme.md | 6 +++ keyboards/np12/keymaps/via/keymap.c | 60 ++++++++++++++++++++++++ keyboards/np12/keymaps/via/rules.mk | 1 + keyboards/np12/np12.c | 17 +++++++ keyboards/np12/np12.h | 31 ++++++++++++ keyboards/np12/readme.md | 24 ++++++++++ keyboards/np12/rules.mk | 23 +++++++++ 10 files changed, 293 insertions(+) create mode 100644 keyboards/np12/config.h create mode 100644 keyboards/np12/info.json create mode 100644 keyboards/np12/keymaps/default/keymap.c create mode 100644 keyboards/np12/keymaps/default/readme.md create mode 100644 keyboards/np12/keymaps/via/keymap.c create mode 100644 keyboards/np12/keymaps/via/rules.mk create mode 100644 keyboards/np12/np12.c create mode 100644 keyboards/np12/np12.h create mode 100644 keyboards/np12/readme.md create mode 100644 keyboards/np12/rules.mk diff --git a/keyboards/np12/config.h b/keyboards/np12/config.h new file mode 100644 index 0000000000..b330c29feb --- /dev/null +++ b/keyboards/np12/config.h @@ -0,0 +1,45 @@ + /* Copyright 2021 nut1414 + * + * 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 "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xA4A4 +#define PRODUCT_ID 0x4401 +#define DEVICE_VER 0x0001 +#define MANUFACTURER nut1414 +#define PRODUCT np12 + + + +/* key matrix size */ +#define MATRIX_ROWS 4 +#define MATRIX_COLS 5 + +#define MATRIX_ROW_PINS { D7, E6, B4, F7 } +#define MATRIX_COL_PINS { D1, D0, D4, C6, F6 } +#define UNUSED_PINS + + +/* COL2ROW or ROW2COL */ +#define DIODE_DIRECTION COL2ROW + +#define ENCODERS_PAD_A { F4 } +#define ENCODERS_PAD_B { F5 } + + diff --git a/keyboards/np12/info.json b/keyboards/np12/info.json new file mode 100644 index 0000000000..2bb513d845 --- /dev/null +++ b/keyboards/np12/info.json @@ -0,0 +1,26 @@ +{ + "keyboard_name": "np12", + "url": "https://github.com/nut1414/np12", + "maintainer": "nut1414", + "width": 4, + "height": 4, + "layouts": { + "LAYOUT": { + "layout": [ + { "label": "k34", "x": 3, "y": 0 }, + { "label": "k00", "x": 0, "y": 1 }, + { "label": "k01", "x": 1, "y": 1 }, + { "label": "k02", "x": 2, "y": 1 }, + { "label": "k03", "x": 3, "y": 1 }, + { "label": "k10", "x": 0, "y": 2 }, + { "label": "k11", "x": 1, "y": 2 }, + { "label": "k12", "x": 2, "y": 2 }, + { "label": "k13", "x": 3, "y": 2 }, + { "label": "k20", "x": 0, "y": 3 }, + { "label": "k21", "x": 1, "y": 3 }, + { "label": "k22", "x": 2, "y": 3 }, + { "label": "k23", "x": 3, "y": 3 } + ] + } + } +} \ No newline at end of file diff --git a/keyboards/np12/keymaps/default/keymap.c b/keyboards/np12/keymaps/default/keymap.c new file mode 100644 index 0000000000..4a02b1d3ad --- /dev/null +++ b/keyboards/np12/keymaps/default/keymap.c @@ -0,0 +1,60 @@ + /* Copyright 2021 nut1414 + * + * 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( + KC_MPLY, + KC_9, KC_6, KC_3, KC_PENT, + KC_8, KC_5, KC_2, KC_BSPC, + KC_7, KC_4, KC_1, KC_0), + + [1] = LAYOUT( + 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), + + [2] = LAYOUT( + 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( + 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), + + + +}; + +void encoder_update_user(uint8_t index, bool clockwise) { + if (index == 0) { + if (clockwise) { + tap_code(KC_AUDIO_VOL_UP); + } else { + tap_code(KC_AUDIO_VOL_DOWN); + } + } +} + + diff --git a/keyboards/np12/keymaps/default/readme.md b/keyboards/np12/keymaps/default/readme.md new file mode 100644 index 0000000000..d8c4c20f9e --- /dev/null +++ b/keyboards/np12/keymaps/default/readme.md @@ -0,0 +1,6 @@ +# np12 Layout +![np12 layout](https://i.imgur.com/pxOYYil.png) + +This is the default layout for np12. The top-right key is for the encoder pushbutton. + + diff --git a/keyboards/np12/keymaps/via/keymap.c b/keyboards/np12/keymaps/via/keymap.c new file mode 100644 index 0000000000..4a02b1d3ad --- /dev/null +++ b/keyboards/np12/keymaps/via/keymap.c @@ -0,0 +1,60 @@ + /* Copyright 2021 nut1414 + * + * 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( + KC_MPLY, + KC_9, KC_6, KC_3, KC_PENT, + KC_8, KC_5, KC_2, KC_BSPC, + KC_7, KC_4, KC_1, KC_0), + + [1] = LAYOUT( + 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), + + [2] = LAYOUT( + 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( + 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), + + + +}; + +void encoder_update_user(uint8_t index, bool clockwise) { + if (index == 0) { + if (clockwise) { + tap_code(KC_AUDIO_VOL_UP); + } else { + tap_code(KC_AUDIO_VOL_DOWN); + } + } +} + + diff --git a/keyboards/np12/keymaps/via/rules.mk b/keyboards/np12/keymaps/via/rules.mk new file mode 100644 index 0000000000..1e5b99807c --- /dev/null +++ b/keyboards/np12/keymaps/via/rules.mk @@ -0,0 +1 @@ +VIA_ENABLE = yes diff --git a/keyboards/np12/np12.c b/keyboards/np12/np12.c new file mode 100644 index 0000000000..062bd9a833 --- /dev/null +++ b/keyboards/np12/np12.c @@ -0,0 +1,17 @@ + /* Copyright 2021 nut1414 + * + * 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 "np12.h" diff --git a/keyboards/np12/np12.h b/keyboards/np12/np12.h new file mode 100644 index 0000000000..ee82786d83 --- /dev/null +++ b/keyboards/np12/np12.h @@ -0,0 +1,31 @@ + /* Copyright 2021 nut1414 + * + * 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( \ + k34, \ + k00, k01, k02, k03, \ + k10, k11, k12, k13, \ + k20, k21, k22, k23 \ +) { \ + { k00, k01, k02, k03, KC_NO}, \ + { k10, k11, k12, k13, KC_NO}, \ + { k20, k21, k22, k23, KC_NO}, \ + { KC_NO, KC_NO, KC_NO, KC_NO, k34 } \ +} diff --git a/keyboards/np12/readme.md b/keyboards/np12/readme.md new file mode 100644 index 0000000000..2b33920a61 --- /dev/null +++ b/keyboards/np12/readme.md @@ -0,0 +1,24 @@ +# np12 + +![np12](https://i.imgur.com/gci7qqZh.jpg) + +![np12 pcb](https://i.imgur.com/DIIvW95h.jpg) + +Square-shaped 12 keys keypad with an encoder. + +* Keyboard Maintainer: [nut1414](https://github.com/nut1414) +* Hardware Supported: np12 keypad +* Hardware Availability: Open Source https://github.com/nut1414/np12 + + +Make example for this keypad (after setting up your build environment): + + make np12:default + +Flashing example for this keyboard: + + make np12:default:flash + +To enter bootloader mode, press the reset button located on the left of the encoder. + +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/np12/rules.mk b/keyboards/np12/rules.mk new file mode 100644 index 0000000000..8b8bacdcf5 --- /dev/null +++ b/keyboards/np12/rules.mk @@ -0,0 +1,23 @@ +# MCU name +MCU = atmega32u4 + +# Bootloader selection +BOOTLOADER = caterina + +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = lite # 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 +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +NKRO_ENABLE = no # USB Nkey Rollover +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow +BLUETOOTH_ENABLE = no # Enable Bluetooth +AUDIO_ENABLE = no # Audio output +ENCODER_ENABLE = yes