From 8070b1ba8862f1a98bafd0b0dc0889f7659ea456 Mon Sep 17 00:00:00 2001 From: yulei Date: Fri, 2 Oct 2020 07:07:14 +0800 Subject: [PATCH] Added replacement pcb for the matrix cain keyboard (#10436) * added replacement pcb for the matrix cain keyboard * update usb descriptor * fixed led polarity * Update keyboards/matrix/cain/cain.c Co-authored-by: Joel Challis * Update keyboards/matrix/cain/rules.mk Co-authored-by: Ryan * Apply suggestions from code review Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com> * rename from cain to cain_re * Update keyboards/matrix/cain_re/readme.md Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com> Co-authored-by: Joel Challis Co-authored-by: Ryan Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com> --- keyboards/matrix/cain_re/cain_re.c | 40 +++++++++++++ keyboards/matrix/cain_re/cain_re.h | 40 +++++++++++++ keyboards/matrix/cain_re/config.h | 58 +++++++++++++++++++ keyboards/matrix/cain_re/info.json | 12 ++++ .../matrix/cain_re/keymaps/default/keymap.c | 40 +++++++++++++ keyboards/matrix/cain_re/readme.md | 15 +++++ keyboards/matrix/cain_re/rules.mk | 22 +++++++ 7 files changed, 227 insertions(+) create mode 100644 keyboards/matrix/cain_re/cain_re.c create mode 100644 keyboards/matrix/cain_re/cain_re.h create mode 100644 keyboards/matrix/cain_re/config.h create mode 100644 keyboards/matrix/cain_re/info.json create mode 100644 keyboards/matrix/cain_re/keymaps/default/keymap.c create mode 100644 keyboards/matrix/cain_re/readme.md create mode 100644 keyboards/matrix/cain_re/rules.mk diff --git a/keyboards/matrix/cain_re/cain_re.c b/keyboards/matrix/cain_re/cain_re.c new file mode 100644 index 0000000000..e8d0a2b803 --- /dev/null +++ b/keyboards/matrix/cain_re/cain_re.c @@ -0,0 +1,40 @@ +/** + * cain_re.c + * + Copyright 2020 astro + + 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 "cain_re.h" + +void matrix_init_kb(void) +{ + setPinOutput(NUM_PIN); + setPinOutput(CAPS_PIN); + setPinOutput(SCROLL_PIN); + + matrix_init_user(); +} + +bool led_update_kb(led_t led_state) +{ + bool res = led_update_user(led_state); + if (res) { + writePin(NUM_PIN, led_state.num_lock); + writePin(CAPS_PIN, led_state.caps_lock); + writePin(SCROLL_PIN, led_state.scroll_lock); + } + return res; +} diff --git a/keyboards/matrix/cain_re/cain_re.h b/keyboards/matrix/cain_re/cain_re.h new file mode 100644 index 0000000000..0228177e11 --- /dev/null +++ b/keyboards/matrix/cain_re/cain_re.h @@ -0,0 +1,40 @@ +/** + * cain_re.h + * + Copyright 2020 astro + + 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_all( \ + k000, k001, k002, k003, k004, k005, k006, k007, k008, k009, k010, k011, k012, k013, k014, k015, \ + k100, k101, k102, k103, k104, k105, k106, k107, k108, k109, k110, k111, k112, k113, k114, k115, k116, k117, k118, k119, k120, \ + k200, k201, k202, k203, k204, k205, k206, k207, k208, k209, k210, k211, k212, k213, k214, k215, k216, k217, k218, k219, k220, \ + k300, k301, k302, k303, k304, k305, k306, k307, k308, k309, k310, k311, k312, k313, k314, k315, k316, \ + k400, k401, k402, k403, k404, k405, k406, k407, k408, k409, k410, k411, k412, k413, k414, k415, k416, \ + k500, k501, k502, k503, k504, k505, k506, k507, k508, k509, k510, k511, k512, k513 \ +) { \ + { k000, k001, k002, k003, k004, k005, k006, k007, k008, k009, k010, k011}, \ + { k100, k101, k102, k103, k104, k105, k106, k107, k108, k109, k110, k111}, \ + { k200, k201, k202, k203, k204, k205, k206, k207, k208, k209, k210, k211}, \ + { k300, k301, k302, k303, k304, k305, k306, k307, k308, k309, k310, k311}, \ + { k400, k401, k402, k403, k404, k405, k406, k407, k408, k409, k410, k411}, \ + { k012, k113, k112, k212, k213, k312, k412, k413, k414, k415, k316, k315}, \ + { k114, k115, k116, k117, k217, k216, k215, k214, k313, k314, k416, KC_NO}, \ + { k013, k014, k015, k120, k119, k118, k218, k219, k220, k511, k512, k513}, \ + { k500, k501, k502, k503, k504, k505, k506, k507, k508, k509, k510, KC_NO} \ +} diff --git a/keyboards/matrix/cain_re/config.h b/keyboards/matrix/cain_re/config.h new file mode 100644 index 0000000000..6bacf1c949 --- /dev/null +++ b/keyboards/matrix/cain_re/config.h @@ -0,0 +1,58 @@ +/** + * config.h + * + Copyright 2020 astro + + 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 0x4D58 // MX +#define PRODUCT_ID 0x0106 // cain +#define DEVICE_VER 0x0001 +#define MANUFACTURER Matrix LAB +#define PRODUCT Matrix Cain Keyboard + +/* key matrix size */ +#define MATRIX_ROWS 9 +#define MATRIX_COLS 12 + +/* key matrix pins */ +#define MATRIX_ROW_PINS { F0, C7, C6, D5, D2, D4, D7, B7, D1 } +#define MATRIX_COL_PINS { F1, F4, F5, F6, B5, B6, B3, B2, B1, D0, B4, D6} +#define UNUSED_PINS + +/* COL2ROW or ROW2COL */ +#define DIODE_DIRECTION COL2ROW + +#define RGB_DI_PIN E6 + +#ifdef RGB_DI_PIN +#define RGBLIGHT_ANIMATIONS + +#define RGBLED_NUM 14 +#define RGBLIGHT_HUE_STEP 8 +#define RGBLIGHT_SAT_STEP 8 +#define RGBLIGHT_VAL_STEP 8 +#define RGBLIGHT_SLEEP +#define RGBLIGHT_LED_MAP { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 1, 2, 3 } +#endif + +#define CAPS_PIN D3 +#define NUM_PIN F7 +#define SCROLL_PIN B0 diff --git a/keyboards/matrix/cain_re/info.json b/keyboards/matrix/cain_re/info.json new file mode 100644 index 0000000000..3f65b7de77 --- /dev/null +++ b/keyboards/matrix/cain_re/info.json @@ -0,0 +1,12 @@ +{ + "keyboard_name": "Matrix Cain Keyboard", + "url": "", + "maintainer": "qmk", + "width": 23, + "height": 6.5, + "layouts": { + "LAYOUT_all": { + "layout": [{"label":"Esc", "x":0, "y":0}, {"label":"F1", "x":2, "y":0}, {"label":"F2", "x":3, "y":0}, {"label":"F3", "x":4, "y":0}, {"label":"F4", "x":5, "y":0}, {"label":"F5", "x":6.5, "y":0}, {"label":"F6", "x":7.5, "y":0}, {"label":"F7", "x":8.5, "y":0}, {"label":"F8", "x":9.5, "y":0}, {"label":"F9", "x":11, "y":0}, {"label":"F10", "x":12, "y":0}, {"label":"F11", "x":13, "y":0}, {"label":"F12", "x":14, "y":0}, {"label":"PrtSc", "x":20, "y":0}, {"label":"Scroll Lock", "x":21, "y":0}, {"label":"Pause", "x":22, "y":0}, {"label":"~", "x":0, "y":1.5}, {"label":"!", "x":1, "y":1.5}, {"label":"@", "x":2, "y":1.5}, {"label":"#", "x":3, "y":1.5}, {"label":"$", "x":4, "y":1.5}, {"label":"%", "x":5, "y":1.5}, {"label":"^", "x":6, "y":1.5}, {"label":"&", "x":7, "y":1.5}, {"label":"*", "x":8, "y":1.5}, {"label":"(", "x":9, "y":1.5}, {"label":")", "x":10, "y":1.5}, {"label":"_", "x":11, "y":1.5}, {"label":"+", "x":12, "y":1.5}, {"label":"Backspace", "x":13, "y":1.5, "w":2}, {"label":"Num Lock", "x":15.5, "y":1.5}, {"label":"/", "x":16.5, "y":1.5}, {"label":"*", "x":17.5, "y":1.5}, {"label":"-", "x":18.5, "y":1.5}, {"label":"Insert", "x":20, "y":1.5}, {"label":"Home", "x":21, "y":1.5}, {"label":"PgUp", "x":22, "y":1.5}, {"label":"Tab", "x":0, "y":2.5, "w":1.5}, {"label":"Q", "x":1.5, "y":2.5}, {"label":"W", "x":2.5, "y":2.5}, {"label":"E", "x":3.5, "y":2.5}, {"label":"R", "x":4.5, "y":2.5}, {"label":"T", "x":5.5, "y":2.5}, {"label":"Y", "x":6.5, "y":2.5}, {"label":"U", "x":7.5, "y":2.5}, {"label":"I", "x":8.5, "y":2.5}, {"label":"O", "x":9.5, "y":2.5}, {"label":"P", "x":10.5, "y":2.5}, {"label":"{", "x":11.5, "y":2.5}, {"label":"}", "x":12.5, "y":2.5}, {"label":"|", "x":13.5, "y":2.5, "w":1.5}, {"label":"7", "x":15.5, "y":2.5}, {"label":"8", "x":16.5, "y":2.5}, {"label":"9", "x":17.5, "y":2.5}, {"label":"+", "x":18.5, "y":2.5}, {"label":"Delete", "x":20, "y":2.5}, {"label":"End", "x":21, "y":2.5}, {"label":"PgDn", "x":22, "y":2.5}, {"label":"Caps Lock", "x":0, "y":3.5, "w":1.75}, {"label":"A", "x":1.75, "y":3.5}, {"label":"S", "x":2.75, "y":3.5}, {"label":"D", "x":3.75, "y":3.5}, {"label":"F", "x":4.75, "y":3.5}, {"label":"G", "x":5.75, "y":3.5}, {"label":"H", "x":6.75, "y":3.5}, {"label":"J", "x":7.75, "y":3.5}, {"label":"K", "x":8.75, "y":3.5}, {"label":"L", "x":9.75, "y":3.5}, {"label":":", "x":10.75, "y":3.5}, {"label":"\"", "x":11.75, "y":3.5}, {"label":"Enter", "x":12.75, "y":3.5, "w":2.25}, {"label":"4", "x":15.5, "y":3.5}, {"label":"5", "x":16.5, "y":3.5}, {"label":"6", "x":17.5, "y":3.5}, {"label":"+", "x":18.5, "y":3.5}, {"label":"Shift", "x":0, "y":4.5, "w":2.25}, {"label":"Z", "x":2.25, "y":4.5}, {"label":"X", "x":3.25, "y":4.5}, {"label":"C", "x":4.25, "y":4.5}, {"label":"V", "x":5.25, "y":4.5}, {"label":"B", "x":6.25, "y":4.5}, {"label":"N", "x":7.25, "y":4.5}, {"label":"M", "x":8.25, "y":4.5}, {"label":"<", "x":9.25, "y":4.5}, {"label":">", "x":10.25, "y":4.5}, {"label":"?", "x":11.25, "y":4.5}, {"label":"Shift", "x":12.25, "y":4.5, "w":2.75}, {"label":"1", "x":15.5, "y":4.5}, {"label":"2", "x":16.5, "y":4.5}, {"label":"3", "x":17.5, "y":4.5}, {"label":"Enter", "x":18.5, "y":4.5}, {"label":"\u2191", "x":21, "y":4.5}, {"label":"Ctrl", "x":0, "y":5.5, "w":1.5}, {"label":"Win", "x":1.5, "y":5.5}, {"label":"Alt", "x":2.5, "y":5.5, "w":1.5}, {"x":4, "y":5.5, "w":7}, {"label":"Alt", "x":11, "y":5.5, "w":1.5}, {"label":"Win", "x":12.5, "y":5.5}, {"label":"Ctrl", "x":13.5, "y":5.5, "w":1.5}, {"label":"0", "x":15.5, "y":5.5}, {"label":"0", "x":16.5, "y":5.5}, {"label":".", "x":17.5, "y":5.5}, {"label":"Enter", "x":18.5, "y":5.5}, {"label":"\u2190", "x":20, "y":5.5}, {"label":"\u2193", "x":21, "y":5.5}, {"label":"\u2192", "x":22, "y":5.5}] + } + } +} diff --git a/keyboards/matrix/cain_re/keymaps/default/keymap.c b/keyboards/matrix/cain_re/keymaps/default/keymap.c new file mode 100644 index 0000000000..1f2d3b4e25 --- /dev/null +++ b/keyboards/matrix/cain_re/keymaps/default/keymap.c @@ -0,0 +1,40 @@ +/** + * keymap.c + * + Copyright 2020 astro + + 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( + KC_ESC, 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_PSCR, KC_SLCK, LT(1,KC_PAUS), + + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, KC_INS, KC_HOME, KC_PGUP, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_P7, KC_P8, KC_P9, KC_PPLS, KC_DEL, KC_END, KC_PGDN, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_P4, KC_P5, KC_P6, KC_PPLS, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_P1, KC_P2, KC_P3, KC_PENT, KC_UP, + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_RCTL, KC_P0, KC_P0, KC_PDOT, KC_PENT, KC_LEFT, KC_DOWN, KC_RGHT), + + [1]=LAYOUT_all( + KC_MUTE, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,_______,_______,_______,_______, _______, _______, + KC_NLCK, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______, _______, _______, _______, _______, _______,_______,_______,_______,_______, _______, _______, + RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,_______,_______,_______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,_______,_______,_______, KC_VOLU, + _______, _______, _______, KC_MPLY, _______, _______, _______, _______,_______,_______,_______, KC_MPRV, KC_VOLD, KC_MNXT), +}; diff --git a/keyboards/matrix/cain_re/readme.md b/keyboards/matrix/cain_re/readme.md new file mode 100644 index 0000000000..13c86ea54a --- /dev/null +++ b/keyboards/matrix/cain_re/readme.md @@ -0,0 +1,15 @@ +# Matrix Cain replacement PCB + +This was the replacement PCB for the Matrix Cain keyboard. + +This firmware **DOES NOT** support the original PCB shipped with the Cain keyboard. + +* Keyboard Maintainer: [astro](https://github.com/yulei) +* Hardware Supported: Matrix Cain keyboard +* Hardware Availability: Matrix Lab + +Make example for this keyboard (after setting up your build environment): + + make matrix/cain_re: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). diff --git a/keyboards/matrix/cain_re/rules.mk b/keyboards/matrix/cain_re/rules.mk new file mode 100644 index 0000000000..9bbb324e7c --- /dev/null +++ b/keyboards/matrix/cain_re/rules.mk @@ -0,0 +1,22 @@ +# MCU name +MCU = atmega32u4 + +# Bootloader selection +BOOTLOADER = atmel-dfu + +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = full # 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 = yes # USB Nkey Rollover +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow +BLUETOOTH_ENABLE = no # Enable Bluetooth +AUDIO_ENABLE = no # Audio output