From 0032cb026b7d4143fd61ed3cb3378eda5bb41292 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 1 Sep 2020 15:30:07 +1000 Subject: [PATCH] [Keyboard] YMDK NP21 refactor (#10181) --- keyboards/ymdk_np21/config.h | 119 +++++++++++++-- keyboards/ymdk_np21/info.json | 140 +++++++++++------- keyboards/ymdk_np21/keymaps/default/keymap.c | 44 +++--- keyboards/ymdk_np21/keymaps/default/readme.md | 50 +++---- keyboards/ymdk_np21/{README.md => readme.md} | 0 keyboards/ymdk_np21/rules.mk | 34 ++--- keyboards/ymdk_np21/ymdk_np21.h | 65 ++++---- 7 files changed, 290 insertions(+), 162 deletions(-) rename keyboards/ymdk_np21/{README.md => readme.md} (100%) diff --git a/keyboards/ymdk_np21/config.h b/keyboards/ymdk_np21/config.h index 379663431..1ea6fb0ce 100644 --- a/keyboards/ymdk_np21/config.h +++ b/keyboards/ymdk_np21/config.h @@ -19,32 +19,121 @@ along with this program. If not, see . #include "config_common.h" -#define VENDOR_ID 0x20A0 -#define PRODUCT_ID 0x422D -#define DEVICE_VER 0x0200 -#define MANUFACTURER YMDK -#define PRODUCT NP21 +/* USB Device descriptor parameter */ +#define VENDOR_ID 0x594D // "YM" +#define PRODUCT_ID 0x5021 // "P" 21 +#define DEVICE_VER 0x0200 +#define MANUFACTURER YMDK +#define PRODUCT NP21 -/* matrix size */ +/* key matrix size */ #define MATRIX_ROWS 4 #define MATRIX_COLS 6 + +/* + * Keyboard Matrix Assignments + * + * Change this to how you wired your keyboard + * COLS: AVR pins used for columns, left to right + * ROWS: AVR pins used for rows, top to bottom + * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) + * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) + * + */ #define MATRIX_ROW_PINS { B0, B1, B2, B3 } #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5 } -/* COL2ROW or ROW2COL */ +/* COL2ROW, ROW2COL */ #define DIODE_DIRECTION COL2ROW #define BACKLIGHT_PIN D4 #define BACKLIGHT_LEVELS 12 #define BACKLIGHT_BREATHING -#define TAPPING_TOGGLE 3 +#define RGBLED_NUM 5 +//#define RGBLIGHT_HUE_STEP 8 +//#define RGBLIGHT_SAT_STEP 8 +//#define RGBLIGHT_VAL_STEP 8 +//#define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */ +//#define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */ +/*== all animations enable ==*/ +#define RGBLIGHT_ANIMATIONS +/*== or choose animations ==*/ +//#define RGBLIGHT_EFFECT_BREATHING +//#define RGBLIGHT_EFFECT_RAINBOW_MOOD +//#define RGBLIGHT_EFFECT_RAINBOW_SWIRL +//#define RGBLIGHT_EFFECT_SNAKE +//#define RGBLIGHT_EFFECT_KNIGHT +//#define RGBLIGHT_EFFECT_CHRISTMAS +//#define RGBLIGHT_EFFECT_STATIC_GRADIENT +//#define RGBLIGHT_EFFECT_RGB_TEST +//#define RGBLIGHT_EFFECT_ALTERNATING +/*== customize breathing effect ==*/ +/*==== (DEFAULT) use fixed table instead of exp() and sin() ====*/ +//#define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256(default) or 128 or 64 +/*==== use exp() and sin() ====*/ +//#define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1 to 2.7 +//#define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255 + +/* 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 + +/* 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 + +/* If defined, GRAVE_ESC will always act as ESC when CTRL is held. + * This is useful 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 + +/* + * 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 + +/* disable these deprecated features by default */ +#define NO_ACTION_MACRO +#define NO_ACTION_FUNCTION + +/* Bootmagic Lite key configuration */ +//#define BOOTMAGIC_LITE_ROW 0 +//#define BOOTMAGIC_LITE_COLUMN 0 #define USB_MAX_POWER_CONSUMPTION 100 - -/* RGB underglow */ -// The RGB_DI_PIN value seems to be shared between all PS2AVRGB boards. -// The same pin is used on the JJ40, at least. -#define RGBLED_NUM 5 -#define RGB_DI_PIN E2 // NOTE: for PS2AVRGB boards, underglow commands are sent via I2C to 0xB0. -#define RGBLIGHT_ANIMATIONS diff --git a/keyboards/ymdk_np21/info.json b/keyboards/ymdk_np21/info.json index b17059a1c..bc5b101c9 100644 --- a/keyboards/ymdk_np21/info.json +++ b/keyboards/ymdk_np21/info.json @@ -6,63 +6,101 @@ "LAYOUT_ortho_6x4": { "width": 4, "height": 6.25, - "key_count": 24, "layout": [ - {"label":"K06", "x":0, "y":0}, - {"label":"K16", "x":1, "y":0}, - {"label":"K26", "x":2, "y":0}, - {"label":"K36", "x":3, "y":0}, - {"label":"K05", "x":0, "y":1.25}, - {"label":"K15", "x":1, "y":1.25}, - {"label":"K25", "x":2, "y":1.25}, - {"label":"K35", "x":3, "y":1.25}, - {"label":"K04", "x":0, "y":2.25}, - {"label":"K14", "x":1, "y":2.25}, - {"label":"K24", "x":2, "y":2.25}, - {"label":"K34", "x":3, "y":2.25}, - {"label":"K03", "x":0, "y":3.25}, - {"label":"K13", "x":1, "y":3.25}, - {"label":"K23", "x":2, "y":3.25}, - {"label":"K33", "x":3, "y":3.25}, - {"label":"K02", "x":0, "y":4.25}, - {"label":"K12", "x":1, "y":4.25}, - {"label":"K22", "x":2, "y":4.25}, - {"label":"K32", "x":3, "y":4.25}, - {"label":"K01", "x":0, "y":5.25}, - {"label":"K11", "x":1, "y":5.25}, - {"label":"K21", "x":2, "y":5.25}, - {"label":"K31", "x":3, "y":5.25} + {"x": 0, "y": 0}, + {"x": 1, "y": 0}, + {"x": 2, "y": 0}, + {"x": 3, "y": 0}, + + {"x": 0, "y": 1.25}, + {"x": 1, "y": 1.25}, + {"x": 2, "y": 1.25}, + {"x": 3, "y": 1.25}, + + {"x": 0, "y": 2.25}, + {"x": 1, "y": 2.25}, + {"x": 2, "y": 2.25}, + {"x": 3, "y": 2.25}, + + {"x": 0, "y": 3.25}, + {"x": 1, "y": 3.25}, + {"x": 2, "y": 3.25}, + {"x": 3, "y": 3.25}, + + {"x": 0, "y": 4.25}, + {"x": 1, "y": 4.25}, + {"x": 2, "y": 4.25}, + {"x": 3, "y": 4.25}, + + {"x": 0, "y": 5.25}, + {"x": 1, "y": 5.25}, + {"x": 2, "y": 5.25}, + {"x": 3, "y": 5.25} ] }, - "LAYOUT": { + "LAYOUT_ortho_4x6": { "width": 6.25, "height": 4, - "key_count": 24, "layout": [ - {"label":"K01", "x":0, "y":0}, - {"label":"K02", "x":1, "y":0}, - {"label":"K03", "x":2, "y":0}, - {"label":"K04", "x":3, "y":0}, - {"label":"K05", "x":4, "y":0}, - {"label":"K06", "x":5.25, "y":0}, - {"label":"K11", "x":0, "y":1}, - {"label":"K12", "x":1, "y":1}, - {"label":"K13", "x":2, "y":1}, - {"label":"K14", "x":3, "y":1}, - {"label":"K15", "x":4, "y":1}, - {"label":"K16", "x":5.25, "y":1}, - {"label":"K21", "x":0, "y":2}, - {"label":"K22", "x":1, "y":2}, - {"label":"K23", "x":2, "y":2}, - {"label":"K24", "x":3, "y":2}, - {"label":"K25", "x":4, "y":2}, - {"label":"K26", "x":5.25, "y":2}, - {"label":"K31", "x":0, "y":3}, - {"label":"K32", "x":1, "y":3}, - {"label":"K33", "x":2, "y":3}, - {"label":"K34", "x":3, "y":3}, - {"label":"K35", "x":4, "y":3}, - {"label":"K36", "x":5.25, "y":3} + {"x": 0, "y": 0}, + {"x": 1, "y": 0}, + {"x": 2, "y": 0}, + {"x": 3, "y": 0}, + {"x": 4, "y": 0}, + {"x": 5.25, "y": 0}, + + {"x": 0, "y": 1}, + {"x": 1, "y": 1}, + {"x": 2, "y": 1}, + {"x": 3, "y": 1}, + {"x": 4, "y": 1}, + {"x": 5.25, "y": 1}, + + {"x": 0, "y": 2}, + {"x": 1, "y": 2}, + {"x": 2, "y": 2}, + {"x": 3, "y": 2}, + {"x": 4, "y": 2}, + {"x": 5.25, "y": 2}, + + {"x": 0, "y": 3}, + {"x": 1, "y": 3}, + {"x": 2, "y": 3}, + {"x": 3, "y": 3}, + {"x": 4, "y": 3}, + {"x": 5.25, "y": 3} + ] + }, + "LAYOUT_numpad_6x4": { + "width": 4, + "height": 6.25, + "layout": [ + {"x": 0, "y": 0}, + {"x": 1, "y": 0}, + {"x": 2, "y": 0}, + {"x": 3, "y": 0}, + + {"x": 0, "y": 1.25}, + {"x": 1, "y": 1.25}, + {"x": 2, "y": 1.25}, + {"x": 3, "y": 1.25}, + + {"x": 0, "y": 2.25}, + {"x": 1, "y": 2.25}, + {"x": 2, "y": 2.25}, + + {"x": 0, "y": 3.25}, + {"x": 1, "y": 3.25}, + {"x": 2, "y": 3.25}, + {"x": 3, "y": 2.25, "h": 2}, + + {"x": 0, "y": 4.25}, + {"x": 1, "y": 4.25}, + {"x": 2, "y": 4.25}, + + {"x": 0, "y": 5.25, "w": 2}, + {"x": 2, "y": 5.25}, + {"x": 3, "y": 4.25, "h": 2} ] } } diff --git a/keyboards/ymdk_np21/keymaps/default/keymap.c b/keyboards/ymdk_np21/keymaps/default/keymap.c index 143f4f61b..e15fb1d6e 100644 --- a/keyboards/ymdk_np21/keymaps/default/keymap.c +++ b/keyboards/ymdk_np21/keymaps/default/keymap.c @@ -1,32 +1,26 @@ #include QMK_KEYBOARD_H -#define _NP 0 -#define _BL 1 - -enum custom_keycodes { - NP = SAFE_RANGE, - BL +enum layer_names { + _NP, + _BL }; const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - /* Qwerty */ - - [_NP] = LAYOUT_ortho_6x4( - KC_ESC, KC_TAB, KC_BSPC, MO(_BL), - KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, - KC_P7, KC_P8, KC_P9, KC_PPLS, - KC_P4, KC_P5, KC_P6, KC_PPLS, - KC_P1, KC_P2, KC_P3, KC_PENT, - KC_P0, KC_DOT, KC_PDOT, KC_PENT - ), - - [_BL] = LAYOUT_ortho_6x4( - _______, _______, _______, _______, - _______, _______, _______, _______, - _______, BL_ON, _______, BL_INC, - _______, BL_TOGG, _______, BL_INC, - _______, BL_OFF, _______, BL_DEC, - BL_BRTG, _______, _______, BL_DEC - ) + [_NP] = LAYOUT_ortho_6x4( + KC_ESC, KC_TAB, KC_BSPC, MO(_BL), + KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, + KC_P7, KC_P8, KC_P9, KC_PPLS, + KC_P4, KC_P5, KC_P6, KC_PPLS, + KC_P1, KC_P2, KC_P3, KC_PENT, + KC_P0, KC_DOT, KC_PDOT, KC_PENT + ), + [_BL] = LAYOUT_ortho_6x4( + _______, _______, _______, _______, + _______, _______, _______, _______, + _______, BL_ON, _______, BL_INC, + _______, BL_TOGG, _______, BL_INC, + _______, BL_OFF, _______, BL_DEC, + BL_BRTG, _______, _______, BL_DEC + ) }; diff --git a/keyboards/ymdk_np21/keymaps/default/readme.md b/keyboards/ymdk_np21/keymaps/default/readme.md index aca4c0cab..3a4730f7e 100644 --- a/keyboards/ymdk_np21/keymaps/default/readme.md +++ b/keyboards/ymdk_np21/keymaps/default/readme.md @@ -1,26 +1,26 @@ -# default +# The default keymap for the YMDK NP21 keypad -The default keymap for the YMDK NP21 keypad. - - Base Layer Function Layer - .-----. .-----. - | USB | | USB | - ,-------------------------------. ,-------------------------------. - | Esc | Tab | Back | Fn | | | | |▒▒▒▒▒▒▒| - | | | Space | | | | | |▒▒▒▒▒▒▒| - |-------+-------+-------+-------| |-------+-------+-------+-------| - | Num | / | * | - | | | | | | - | Lock | | | | | | | | | - |-------+-------+-------+-------| |-------+-------+-------+-------| - | 7 | 8 | 9 | + | | | BL | | BL | - | Home | Up | PgUp | | | | On | | Inc | - |-------+-------+-------+-------| |-------+-------+-------+-------| - | 4 | 5 | 6 | + | | | BL | | BL | - | Left | | Right | | | | Togg | | Inc | - |-------+-------+-------+-------| |-------+-------+-------+-------| - | 1 | 2 | 3 | Ent | | | BL | | BL | - | End | Down | PgDn | | | | Off | | Dec | - |-------+-------+-------+-------| |-------+-------+-------+-------| - | 0 | . | . | Ent | | BL | | | BL | - | Ins | | Del | | | Brthg | | | Dec | - `-------------------------------' `-------------------------------' +``` +Base Layer Function Layer + .-----. .-----. + | USB | | USB | +,-------------------------------. ,-------------------------------. +| Esc | Tab | Back | Fn | | | | |▒▒▒▒▒▒▒| +| | | Space | | | | | |▒▒▒▒▒▒▒| +|-------+-------+-------+-------| |-------+-------+-------+-------| +| Num | / | * | - | | | | | | +| Lock | | | | | | | | | +|-------+-------+-------+-------| |-------+-------+-------+-------| +| 7 | 8 | 9 | + | | | BL | | BL | +| Home | Up | PgUp | | | | On | | Inc | +|-------+-------+-------+-------| |-------+-------+-------+-------| +| 4 | 5 | 6 | + | | | BL | | BL | +| Left | | Right | | | | Togg | | Inc | +|-------+-------+-------+-------| |-------+-------+-------+-------| +| 1 | 2 | 3 | Ent | | | BL | | BL | +| End | Down | PgDn | | | | Off | | Dec | +|-------+-------+-------+-------| |-------+-------+-------+-------| +| 0 | . | . | Ent | | BL | | | BL | +| Ins | | Del | | | Brthg | | | Dec | +`-------------------------------' `-------------------------------' +``` diff --git a/keyboards/ymdk_np21/README.md b/keyboards/ymdk_np21/readme.md similarity index 100% rename from keyboards/ymdk_np21/README.md rename to keyboards/ymdk_np21/readme.md diff --git a/keyboards/ymdk_np21/rules.mk b/keyboards/ymdk_np21/rules.mk index c370c616a..ed7d082f0 100644 --- a/keyboards/ymdk_np21/rules.mk +++ b/keyboards/ymdk_np21/rules.mk @@ -2,28 +2,20 @@ MCU = atmega32a # Bootloader selection -# Teensy halfkay -# Pro Micro caterina -# Atmel DFU atmel-dfu -# LUFA DFU lufa-dfu -# QMK DFU qmk-dfu -# ATmega32A bootloadHID -# ATmega328P USBasp BOOTLOADER = bootloadHID -# build options -BOOTMAGIC_ENABLE = no -MOUSEKEY_ENABLE = no -EXTRAKEY_ENABLE = yes -CONSOLE_ENABLE = no -COMMAND_ENABLE = yes - -BACKLIGHT_ENABLE = yes - -RGBLIGHT_ENABLE = yes +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration +MOUSEKEY_ENABLE = no # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = yes # 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 +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow WS2812_DRIVER = i2c -KEY_LOCK_ENABLE = yes - -# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +LAYOUTS = ortho_6x4 numpad_6x4 diff --git a/keyboards/ymdk_np21/ymdk_np21.h b/keyboards/ymdk_np21/ymdk_np21.h index afd3d38c7..bdc37231e 100644 --- a/keyboards/ymdk_np21/ymdk_np21.h +++ b/keyboards/ymdk_np21/ymdk_np21.h @@ -19,31 +19,46 @@ along with this program. If not, see . #include "quantum.h" +#define XXX KC_NO + #define LAYOUT_ortho_6x4( \ - K06, K16, K26, K36, \ - K05, K15, K25, K35, \ - K04, K14, K24, K34, \ - K03, K13, K23, K33, \ - K02, K12, K22, K32, \ - K01, K11, K21, K31 \ -) \ -{ \ - { K06, K05, K04, K03, K02, K01 }, \ - { K16, K15, K14, K13, K12, K11 }, \ - { K26, K25, K24, K23, K22, K21 }, \ - { K36, K35, K34, K33, K32, K31 } \ + k00, k10, k20, k30, \ + k01, k11, k21, k31, \ + k02, k12, k22, k32, \ + k03, k13, k23, k33, \ + k04, k14, k24, k34, \ + k05, k15, k25, k35 \ +) { \ + { k00, k01, k02, k03, k04, k05 }, \ + { k10, k11, k12, k13, k14, k15 }, \ + { k20, k21, k22, k23, k24, k25 }, \ + { k30, k31, k32, k33, k34, k35 } \ } -#define LAYOUT( \ - K01, K02, K03, K04, K05, K06, \ - K11, K12, K13, K14, K15, K16, \ - K21, K22, K23, K24, K25, K26, \ - K31, K32, K33, K34, K35, K36 \ -) LAYOUT_ortho_6x4( \ - K06, K16, K26, K36, \ - K05, K15, K25, K35, \ - K04, K14, K24, K34, \ - K03, K13, K23, K33, \ - K02, K12, K22, K32, \ - K01, K11, K21, K31 \ -) +#define LAYOUT_ortho_4x6( \ + k05, k04, k03, k02, k01, k00, \ + k15, k14, k13, k12, k11, k10, \ + k25, k24, k23, k22, k21, k20, \ + k35, k34, k33, k32, k31, k30 \ +) { \ + { k00, k01, k02, k03, k04, k05 }, \ + { k10, k11, k12, k13, k14, k15 }, \ + { k20, k21, k22, k23, k24, k25 }, \ + { k30, k31, k32, k33, k34, k35 } \ +} + +#define LAYOUT_numpad_6x4( \ + k00, k10, k20, k30, \ + k01, k11, k21, k31, \ + k02, k12, k22,\ + k03, k13, k23, k33, \ + k04, k14, k24, \ + k05, k25, k35 \ +) { \ + { k00, k01, k02, k03, k04, k05 }, \ + { k10, k11, k12, k13, k14, XXX }, \ + { k20, k21, k22, k23, k24, k25 }, \ + { k30, k31, XXX, k33, XXX, k35 } \ +} + +#define LAYOUT LAYOUT_ortho_4x6