diff options
author | QMK Bot <hello@qmk.fm> | 2021-09-21 21:08:27 +0000 |
---|---|---|
committer | QMK Bot <hello@qmk.fm> | 2021-09-21 21:08:27 +0000 |
commit | e5e66b6b777941f8fb636106a282f7e659585355 (patch) | |
tree | f168dd91afe23d862e5a518b4b971f240f96234b /keyboards | |
parent | cbdaf686ffd989ec1d6c9a720ee0772c002ad181 (diff) | |
parent | 8d32ddd8e948136a992ab3c10d13c7dbf9e1e119 (diff) |
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'keyboards')
-rw-r--r-- | keyboards/gboards/combos/colemakdhm-vim-helpers.def | 9 | ||||
-rw-r--r-- | keyboards/gboards/gergoplex/config.h | 52 | ||||
-rw-r--r-- | keyboards/gboards/gergoplex/gergoplex.c | 68 | ||||
-rw-r--r-- | keyboards/gboards/gergoplex/gergoplex.h | 56 | ||||
-rw-r--r-- | keyboards/gboards/gergoplex/keymaps/colemak-dhm/combos.def | 10 | ||||
-rw-r--r-- | keyboards/gboards/gergoplex/keymaps/colemak-dhm/gergoplex.def | 11 | ||||
-rw-r--r-- | keyboards/gboards/gergoplex/keymaps/colemak-dhm/keymap.c | 99 | ||||
-rw-r--r-- | keyboards/gboards/gergoplex/keymaps/colemak-dhm/rules.mk | 17 | ||||
-rw-r--r-- | keyboards/gboards/gergoplex/keymaps/default/combos.def | 11 | ||||
-rw-r--r-- | keyboards/gboards/gergoplex/keymaps/default/gergoplex.def | 10 | ||||
-rw-r--r-- | keyboards/gboards/gergoplex/keymaps/default/keymap.c | 113 | ||||
-rw-r--r-- | keyboards/gboards/gergoplex/keymaps/default/rules.mk | 17 | ||||
-rw-r--r-- | keyboards/gboards/gergoplex/matrix.c | 241 | ||||
-rw-r--r-- | keyboards/gboards/gergoplex/readme.md | 43 | ||||
-rw-r--r-- | keyboards/gboards/gergoplex/rules.mk | 18 |
15 files changed, 775 insertions, 0 deletions
diff --git a/keyboards/gboards/combos/colemakdhm-vim-helpers.def b/keyboards/gboards/combos/colemakdhm-vim-helpers.def new file mode 100644 index 0000000000..f4950be05b --- /dev/null +++ b/keyboards/gboards/combos/colemakdhm-vim-helpers.def @@ -0,0 +1,9 @@ +// Vim-Mode combos + +COMB(wfEsc, KC_ESC, KC_W, KC_F) +COMB(rsBspc, KC_BSPC, KC_R, KC_S) +COMB(stTab, KC_TAB, KC_S, KC_T) +COMB(cdEnt, KC_ENT, KC_C, KC_D) +COMB(luEsc, KC_ESC, KC_L, KC_U) +COMB(neCol, KC_COLN, KC_N, KC_E) +COMB(mkEnt, KC_ENT, KC_M, KC_K) diff --git a/keyboards/gboards/gergoplex/config.h b/keyboards/gboards/gergoplex/config.h new file mode 100644 index 0000000000..a6d8d6b1be --- /dev/null +++ b/keyboards/gboards/gergoplex/config.h @@ -0,0 +1,52 @@ +/* +Copyright 2012 Jun Wako <wakojun@gmail.com> +Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com> + +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 <http://www.gnu.org/licenses/>. +*/ + +// Copy and worked on with love from the EZ team + +#pragma once +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0x6B0A +#define PRODUCT_ID 0x0002 +#define DEVICE_VER 0x0001 +#define MANUFACTURER g Heavy Industries +#define PRODUCT GergoPlex + +/* key matrix size */ +#define MATRIX_ROWS 10 +#define MATRIX_ROWS_PER_SIDE (MATRIX_ROWS / 2) +#define MATRIX_COLS 4 + +/* + * 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 + */ +#define MATRIX_ROW_PINS { F6, F5, F4, F1 } +#define MATRIX_COL_PINS { B1, B2, B3, D2, D3 } +#define UNUSED_PINS +#define IGNORE_MOD_TAP_INTERRUPT +#define COMBO_ALLOW_ACTION_KEYS +#define COMBO_VARIABLE_LEN + +#define IS_COMMAND() (get_mods() == (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) || get_mods() == (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT))) + +#define DEBOUNCE 5 diff --git a/keyboards/gboards/gergoplex/gergoplex.c b/keyboards/gboards/gergoplex/gergoplex.c new file mode 100644 index 0000000000..1e44583895 --- /dev/null +++ b/keyboards/gboards/gergoplex/gergoplex.c @@ -0,0 +1,68 @@ +/* Copyright 2021 Jane Bernhardt + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#include "gergoplex.h" + +bool i2c_initialized = 0; +i2c_status_t mcp23018_status = 0x20; + +void matrix_init_kb(void) { + matrix_init_user(); +} + +uint8_t init_mcp23018(void) { + print("starting init"); + mcp23018_status = 0x20; + + // I2C subsystem + + if (i2c_initialized == 0) { + i2c_init(); // on pins D(1,0) + i2c_initialized = true; + _delay_ms(1000); + } + + // set pin direction + // - unused : input : 1 + // - input : input : 1 + // - driving : output : 0 + mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT); + if (mcp23018_status) goto out; + mcp23018_status = i2c_write(IODIRA, I2C_TIMEOUT); + if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0b11000001, I2C_TIMEOUT); + if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0b11111111, I2C_TIMEOUT); + if (mcp23018_status) goto out; + i2c_stop(); + + // set pull-up + // - unused : on : 1 + // - input : on : 1 + // - driving : off : 0 + mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT); + if (mcp23018_status) goto out; + mcp23018_status = i2c_write(GPPUA, I2C_TIMEOUT); + if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0b11000001, I2C_TIMEOUT); + if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0b11111111, I2C_TIMEOUT); + if (mcp23018_status) goto out; + +out: + i2c_stop(); + return mcp23018_status; +} diff --git a/keyboards/gboards/gergoplex/gergoplex.h b/keyboards/gboards/gergoplex/gergoplex.h new file mode 100644 index 0000000000..507072a376 --- /dev/null +++ b/keyboards/gboards/gergoplex/gergoplex.h @@ -0,0 +1,56 @@ +/* Copyright 2021 Jane Bernhardt + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#pragma once + +#include "quantum.h" +#include "i2c_master.h" + +extern i2c_status_t mcp23018_status; +#define I2C_TIMEOUT 1000 +#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) +#define CPU_16MHz 0x00 + +// I2C aliases and register addresses (see "mcp23018.md") +#define I2C_ADDR 0x20 // 0b0100000 +#define I2C_ADDR_WRITE ((I2C_ADDR << 1) | I2C_WRITE) +#define I2C_ADDR_READ ((I2C_ADDR << 1) | I2C_READ) +#define IODIRA 0x00 // i/o direction register +#define IODIRB 0x01 +#define GPPUA 0x0C // GPIO pull-up resistor register +#define GPIOA 0x12 // general purpose i/o port register (write modifies OLAT) +#define OLATA 0x14 // output latch register + +uint8_t init_mcp23018(void); + +#define LAYOUT_split_3x5_3( \ + L00, L01, L02, L03, L04, R00, R01, R02, R03, R04, \ + L10, L11, L12, L13, L14, R10, R11, R12, R13, R14, \ + L20, L21, L22, L23, L24, R20, R21, R22, R23, R24, \ + L30, L31, L32, R30, R31, R32 \ + ) \ + { \ + {L04, L14, L24, KC_NO}, \ + {L03, L13, L23, L32}, \ + {L02, L12, L22, L31}, \ + {L01, L11, L21, L30}, \ + {L00, L10, L20, KC_NO}, \ + {R00, R10, R20, KC_NO}, \ + {R01, R11, R21, R30}, \ + {R02, R12, R22, R31}, \ + {R03, R13, R23, R32}, \ + {R04, R14, R24, KC_NO}, \ + } diff --git a/keyboards/gboards/gergoplex/keymaps/colemak-dhm/combos.def b/keyboards/gboards/gergoplex/keymaps/colemak-dhm/combos.def new file mode 100644 index 0000000000..2aac5cb4ff --- /dev/null +++ b/keyboards/gboards/gergoplex/keymaps/colemak-dhm/combos.def @@ -0,0 +1,10 @@ +// List any combo dictionaries you want loaded to your device below! + +// User includes +#include "gergoplex.def" + +// QMK wide includes +#include "combos/colemakdhm-vim-helpers.def" + +// Word completion +// #include "combos/eng-combos.def" diff --git a/keyboards/gboards/gergoplex/keymaps/colemak-dhm/gergoplex.def b/keyboards/gboards/gergoplex/keymaps/colemak-dhm/gergoplex.def new file mode 100644 index 0000000000..7ed0122c4b --- /dev/null +++ b/keyboards/gboards/gergoplex/keymaps/colemak-dhm/gergoplex.def @@ -0,0 +1,11 @@ +// Gergoplex colemak-dhm specfic combos +COMB(osBacksl, KC_BSLS, KC_Y, KC_SCLN) +COMB(mnLess, KC_LT, KC_M, KC_N) +COMB(eiGreat, KC_GT, KC_E, KC_I) +COMB(xcDash, KC_MINS, KC_X, KC_C) +COMB(hcUnds, KC_UNDS, KC_H, KC_COMM) +COMB(khQuot, KC_QUOT, KC_K, KC_H) +COMB(gvClic, KC_BTN1, KC_G, KC_V) +COMB(tdClic, KC_BTN2, KC_T, KC_D) + +SUBS(pasta, "I would just like to interject for a moment.", KC_H, KC_J, KC_K, KC_L) diff --git a/keyboards/gboards/gergoplex/keymaps/colemak-dhm/keymap.c b/keyboards/gboards/gergoplex/keymaps/colemak-dhm/keymap.c new file mode 100644 index 0000000000..ec2c17f8bc --- /dev/null +++ b/keyboards/gboards/gergoplex/keymaps/colemak-dhm/keymap.c @@ -0,0 +1,99 @@ +/* Good on you for modifying your layout! if you don't have + * time to read the QMK docs, a list of keycodes can be found at + * https://github.com/qmk/qmk_firmware/blob/master/docs/keycodes.md + */ + +#include "gergoplex.h" +#include "g/keymap_combo.h" + +enum { + _ALPHA, // default (Colemak DHm) + _SPECIAL, // special characters + _NUMBERS // numbers/function/motion +}; + +// alpha hold modifiers +#define KC_CTL_A MT(MOD_LCTL, KC_A) // Tap for A, hold for Control +#define KC_CTL_O MT(MOD_RCTL, KC_O) // Tap for colon, hold for Control +#define KC_SFT_Z MT(MOD_LSFT, KC_Z) // Tap for Z, hold for Shift +#define KC_SFT_SL MT(MOD_RSFT, KC_SLSH) // Tap for slash, hold for Shift + +// thumb modifiers/toggles +#define KC_GUI_ESC MT(MOD_LGUI, KC_ESC) // Tap for Esc, hold for GUI (Meta, Command, Win) +#define KC_ALT_ENT MT(MOD_LALT, KC_ENT) // Tap for Enter, hold for Alt (Option) +#define KC_SPE_SPC LT(_SPECIAL, KC_SPC) // Tap for Space, hold for Special layer +#define KC_NUM_SPC LT(_NUMBERS, KC_SPC) // Tap for Space, hold for Numbers layer +#define KC_SFT_TAB MT(MOD_RSFT, KC_TAB) // Tap for Tab, hold for Right Shift + + /* Combomap + * + * ,-------------------------------. ,-------------------------------. + * | | ESC | | | | | ESC | \ | + * |-------+-----+-----+-----+-----| |-----+-----+-----+-----+-------| + * | | BSPC TAB | | | < : > | | + * |-------+-----+-----+-RMB-+-LMB-| |ENTER+-----+-----+-----+-------| + * | | - ENTER | | | ' _ | | | + * `-------------------------------' `-------------------------------' + * .-----------------. .-----------------. + * | | | | | | | | + * '-----------------' '-----------------' + */ + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Keymap 0: Alpha layer / Colemak DHm + * + * ,-------------------------------. ,-------------------------------. + * | Q | W | F | P | B | | J | L | U | Y | ; | + * |-------+-----+-----+-----+-----| |-----+-----+-----+-----+-------| + * | CTRL A| R | S | T | G | | M | N | E | I | O | + * |-------+-----+-----+-----+-----| |-----+-----+-----+-----+-------| + * | SHFT Z| X | C | D | V | | K | H | < | > |SHFT / | + * `-------------------------------' `-------------------------------' + * .------------------------------. .----------------------. + * | ESC META | ENT ALT | SPC SPE | | SPC NUM | SHFT | TAB | + * '------------------------------' '----------------------' + */ + [_ALPHA] = LAYOUT_split_3x5_3( + KC_Q, KC_W, KC_F, KC_P, KC_B, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, + KC_CTL_A, KC_R, KC_S, KC_T, KC_G, KC_M, KC_N, KC_E, KC_I, KC_CTL_O, + KC_SFT_Z, KC_X, KC_C, KC_D, KC_V, KC_K, KC_H, KC_COMMA, KC_DOT, KC_SFT_SL, + KC_GUI_ESC, KC_ALT_ENT, KC_SPE_SPC, KC_NUM_SPC, KC_LSFT, KC_SFT_TAB), + + /* Keymap 1: Special characters layer + * + * ,-------------------------------. ,-------------------------------. + * | ! | @ | { | } | | | | ` | ~ | | | \ | + * |-------+-----+-----+-----+-----| |-----+-----+-----+-----+-------| + * | # | $ | ( | ) | RMB | | + | - | / | * | ' | + * |-------+-----+-----+-----+-----| |-----+-----+-----+-----+-------| + * | % | ^ | [ | ] | LMB | | & | = | , | . | - | + * `-------------------------------' `-------------------------------' + * .-------------------------. .-----------------. + * | ComboToggle | ; | = | | = | ; | DEL | + * '-------------------------' '-----------------' + */ + [_SPECIAL] = LAYOUT_split_3x5_3( + KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, KC_GRV, KC_TILD, KC_TRNS, KC_TRNS, KC_BSLS, + KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_BTN2, KC_PLUS, KC_MINS, KC_SLSH, KC_ASTR, KC_QUOT, + KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_BTN1, KC_AMPR, KC_EQL, KC_COMM, KC_DOT, KC_MINS, + CMB_TOG, KC_SCLN, KC_EQL, KC_EQL, KC_SCLN, KC_DEL), + + /* Keymap 2: Numbers/Function/Motion layer + * + * ,-------------------------------. ,-------------------------------. + * | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | + * |-------+-----+-----+-----+-----| |-----+-----+-----+-----+-------| + * | F1 | F2 | F3 | F4 | F5 | | LFT | DWN | UP | RGT | VOLUP | + * |-------+-----+-----+-----+-----| |-----+-----+-----+-----+-------| + * | F6 | F7 | F8 | F9 | F10 | | MLFT| MDWN| MUP | MRGT| VOLDN | + * `-------------------------------' `-------------------------------' + * .-----------------. .-----------------. + * | F11 | F12 | | | | PLY | SKP | + * '-----------------' '-----------------' + */ + [_NUMBERS] = LAYOUT_split_3x5_3( + KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, + KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_VOLU, + KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, KC_VOLD, + KC_F11, KC_F12, KC_TRNS, KC_TRNS, KC_MPLY, KC_MNXT) +}; diff --git a/keyboards/gboards/gergoplex/keymaps/colemak-dhm/rules.mk b/keyboards/gboards/gergoplex/keymaps/colemak-dhm/rules.mk new file mode 100644 index 0000000000..e882b8008d --- /dev/null +++ b/keyboards/gboards/gergoplex/keymaps/colemak-dhm/rules.mk @@ -0,0 +1,17 @@ +#---------------------------------------------------------------------------- +# make gboards/gergoplex:default:flash +# Make sure you have dfu-programmer installed! +#---------------------------------------------------------------------------- + +#Debug options +VERBOSE = no +DEBUG_MATRIX_SCAN_RATE = no +DEBUG_MATRIX = no +CONSOLE_ENABLE = no + +#Combos! +VPATH += keyboards/gboards/ + +ifeq ($(strip $(DEBUG_MATRIX)), yes) + OPT_DEFS += -DDEBUG_MATRIX +endif diff --git a/keyboards/gboards/gergoplex/keymaps/default/combos.def b/keyboards/gboards/gergoplex/keymaps/default/combos.def new file mode 100644 index 0000000000..97ea961e6e --- /dev/null +++ b/keyboards/gboards/gergoplex/keymaps/default/combos.def @@ -0,0 +1,11 @@ +// List any combo dictionaries you want loaded to your device below! + +// QMK wide includes +#include "combos/germ-vim-helpers.def" +#include "combos/germ-mouse-keys.def" + +// User includes +#include "gergoplex.def" + +// Word completion +// #include "combos/eng-combos.def" diff --git a/keyboards/gboards/gergoplex/keymaps/default/gergoplex.def b/keyboards/gboards/gergoplex/keymaps/default/gergoplex.def new file mode 100644 index 0000000000..6e50571b5b --- /dev/null +++ b/keyboards/gboards/gergoplex/keymaps/default/gergoplex.def @@ -0,0 +1,10 @@ +// Gergoplex specfic combos + +COMB(opBacksl, KC_BSLS, KC_O, KC_P) +COMB(hjLess, KC_LT, KC_H, KC_J) +COMB(klGreat, KC_GT, KC_K, KC_L) +COMB(xcDash, KC_MINS, KC_X, KC_C) +COMB(mcUnds, KC_UNDS, KC_M, KC_COMM) +COMB(nmQuot, KC_QUOT, KC_N, KC_M) + +SUBS(pasta, "I'd just like to interject for a moment.", KC_H, KC_J, KC_K, KC_L) diff --git a/keyboards/gboards/gergoplex/keymaps/default/keymap.c b/keyboards/gboards/gergoplex/keymaps/default/keymap.c new file mode 100644 index 0000000000..c632751204 --- /dev/null +++ b/keyboards/gboards/gergoplex/keymaps/default/keymap.c @@ -0,0 +1,113 @@ +/* Copyright 2021 Jane Bernhardt + * + * 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 <http://www.gnu.org/licenses/>. + */ + +/* Good on you for modifying your layout! if you don't have + * time to read the QMK docs, a list of keycodes can be found at + * https://github.com/qmk/qmk_firmware/blob/master/docs/keycodes.md + */ + +#include QMK_KEYBOARD_H +#include "g/keymap_combo.h" + +enum { + _ALPHA, // default + _SPECIAL, // special characters + _NUMBERS // numbers/function/motion +}; + +#define KC_CTL_A MT(MOD_LCTL, KC_A) // Tap for A, hold for Control +#define KC_CTL_CL MT(MOD_LCTL, KC_SCLN) // Tap for colon, hold for Control +#define KC_SFT_Z MT(MOD_RSFT, KC_Z) // Tap for Z, hold for Shift +#define KC_SFT_SL MT(MOD_RSFT, KC_SLSH) // Tap for slash, hold for Shift + +#define KC_GUI_ESC MT(MOD_LGUI, KC_ESC) // Tap for Esc, hold for GUI (Meta, Command, Win) +#define KC_ALT_ENT MT(MOD_LALT, KC_ENT) // Tap for Enter, hold for Alt (Option) +#define KC_SPE_SPC LT(_SPECIAL, KC_SPC) // Tap for Space, hold for Special layer +#define KC_NUM_SPC LT(_NUMBERS, KC_SPC) // Tap for Space, hold for Numbers layer +#define KC_SFT_TAB MT(MOD_RSFT, KC_TAB) // Tap for Tab, hold for Right Shift + + /* Combomap + * + * ,-------------------------------. ,-------------------------------. + * | | ESC | | | | | ESC | \ | + * |-------+-----+-----+-----+-----| |-----+-----+-----+-----+-------| + * | | BSPC TAB | | | < : > | | + * |-------+-----+-----+-RMB-+-LMB-| |ENTER+-----+-----+-----+-------| + * | | - ENTER | | | ' _ | | | + * `-------------------------------' `-------------------------------' + * .-----------------. .-----------------. + * | | | | | | | | + * '-----------------' '-----------------' + */ + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Keymap 0: Alpha layer + * + * ,-------------------------------. ,-------------------------------. + * | Q | W | E | R | T | | Y | U | I | O | P | + * |-------+-----+-----+-----+-----| |-----+-----+-----+-----+-------| + * | CTRL A| S | D | F | G | | H | J | K | L |CTRL ; | + * |-------+-----+-----+-----+-----| |-----+-----+-----+-----+-------| + * | SHFT Z| X | C | V | B | | N | M | < | > |SHFT / | + * `-------------------------------' `-------------------------------' + * .------------------------------. .----------------------. + * | ESC META | ENT ALT | SPC SPE | | SPC NUM | SHFT | TAB | + * '------------------------------' '----------------------' + */ + [_ALPHA] = LAYOUT_split_3x5_3( + KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, + KC_CTL_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_CTL_CL, + KC_SFT_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMMA, KC_DOT, KC_SFT_SL, + KC_GUI_ESC, KC_ALT_ENT, KC_SPE_SPC, KC_NUM_SPC, KC_LSFT, KC_SFT_TAB), + + /* Keymap 1: Special characters layer + * + * ,-------------------------------. ,-------------------------------. + * | ! | @ | { | } | | | | ` | ~ | | | \ | + * |-------+-----+-----+-----+-----| |-----+-----+-----+-----+-------| + * | # | $ | ( | ) | RMB | | + | - | / | * | ' | + * |-------+-----+-----+-----+-----| |-----+-----+-----+-----+-------| + * | % | ^ | [ | ] | LMB | | & | = | , | . | - | + * `-------------------------------' `-------------------------------' + * .-------------------------. .-----------------. + * | ComboToggle | ; | = | | = | ; | DEL | + * '-------------------------' '-----------------' + */ + [_SPECIAL] = LAYOUT_split_3x5_3( + KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, KC_GRV, KC_TILD, KC_TRNS, KC_TRNS, KC_BSLS, + KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_BTN2, KC_PLUS, KC_MINS, KC_SLSH, KC_ASTR, KC_QUOT, + KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_BTN1, KC_AMPR, KC_EQL, KC_COMM, KC_DOT, KC_MINS, + CMB_TOG, KC_SCLN, KC_EQL, KC_EQL, KC_SCLN, KC_DEL), + + /* Keymap 2: Numbers/Function/Motion layer + * + * ,-------------------------------. ,-------------------------------. + * | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | + * |-------+-----+-----+-----+-----| |-----+-----+-----+-----+-------| + * | F1 | F2 | F3 | F4 | F5 | | LFT | DWN | UP | RGT | VOLUP | + * |-------+-----+-----+-----+-----| |-----+-----+-----+-----+-------| + * | F6 | F7 | F8 | F9 | F10 | | MLFT| MDWN| MUP | MRGT| VOLDN | + * `-------------------------------' `-------------------------------' + * .-----------------. .-----------------. + * | F11 | F12 | | | | PLY | SKP | + * '-----------------' '-----------------' + */ + [_NUMBERS] = LAYOUT_split_3x5_3( + KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, + KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_VOLU, + KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, KC_VOLD, + KC_F11, KC_F12, KC_TRNS, KC_TRNS, KC_MPLY, KC_MNXT) +}; diff --git a/keyboards/gboards/gergoplex/keymaps/default/rules.mk b/keyboards/gboards/gergoplex/keymaps/default/rules.mk new file mode 100644 index 0000000000..e882b8008d --- /dev/null +++ b/keyboards/gboards/gergoplex/keymaps/default/rules.mk @@ -0,0 +1,17 @@ +#---------------------------------------------------------------------------- +# make gboards/gergoplex:default:flash +# Make sure you have dfu-programmer installed! +#---------------------------------------------------------------------------- + +#Debug options +VERBOSE = no +DEBUG_MATRIX_SCAN_RATE = no +DEBUG_MATRIX = no +CONSOLE_ENABLE = no + +#Combos! +VPATH += keyboards/gboards/ + +ifeq ($(strip $(DEBUG_MATRIX)), yes) + OPT_DEFS += -DDEBUG_MATRIX +endif diff --git a/keyboards/gboards/gergoplex/matrix.c b/keyboards/gboards/gergoplex/matrix.c new file mode 100644 index 0000000000..716390241a --- /dev/null +++ b/keyboards/gboards/gergoplex/matrix.c @@ -0,0 +1,241 @@ +/* + +Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com> + +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 <http://www.gnu.org/licenses/>. +*/ + +#include "matrix.h" +#include <stdint.h> +#include <stdbool.h> +#include <avr/io.h> +#include "wait.h" +#include "action_layer.h" +#include "print.h" +#include "debug.h" +#include "util.h" +#include "debounce.h" +#include "gergoplex.h" + +#ifdef BALLER +# include <avr/interrupt.h> +# include "pointing_device.h" +#endif + +#ifndef DEBOUNCE +# define DEBOUNCE 5 +#endif + +// ATmega pin defs +#define ROW1 (1 << 6) +#define ROW2 (1 << 5) +#define ROW3 (1 << 4) +#define ROW4 (1 << 1) + +/* matrix state(1:on, 0:off) */ +static matrix_row_t matrix[MATRIX_ROWS]; +/* + * matrix state(1:on, 0:off) + * contains the raw values without debounce filtering of the last read cycle. + */ +static matrix_row_t raw_matrix[MATRIX_ROWS]; + +static const pin_t row_pins[MATRIX_COLS] = MATRIX_ROW_PINS; +// Right-hand side only pins, the left side is controlled my MCP +static const pin_t col_pins[MATRIX_ROWS_PER_SIDE] = MATRIX_COL_PINS; + +// Debouncing: store for each key the number of scans until it's eligible to +// change. When scanning the matrix, ignore any changes in keys that have +// already changed in the last DEBOUNCE scans. + +static matrix_row_t read_cols(uint8_t row); +static void init_cols(void); +static void unselect_rows(void); +static void select_row(uint8_t row); + +static uint8_t mcp23018_reset_loop; + +__attribute__((weak)) void matrix_init_user(void) {} +__attribute__((weak)) void matrix_scan_user(void) {} +__attribute__((weak)) void matrix_scan_kb(void) { matrix_scan_user(); } + +void matrix_init(void) { + // initialize row and col + mcp23018_status = init_mcp23018(); + unselect_rows(); + init_cols(); + + // initialize matrix state: all keys off + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + matrix[i] = 0; + raw_matrix[i] = 0; + } + + debounce_init(MATRIX_ROWS); + matrix_init_quantum(); +} +void matrix_power_up(void) { + mcp23018_status = init_mcp23018(); + + unselect_rows(); + init_cols(); + + // initialize matrix state: all keys off + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + matrix[i] = 0; + } +} + +// Reads and stores a row, returning +// whether a change occurred. +static inline bool store_raw_matrix_row(uint8_t index) { + matrix_row_t temp = read_cols(index); + if (raw_matrix[index] != temp) { + raw_matrix[index] = temp; + return true; + } + return false; +} +uint8_t matrix_scan(void) { + if (mcp23018_status) { // if there was an error + if (++mcp23018_reset_loop == 0) { + // if (++mcp23018_reset_loop >= 1300) { + // since mcp23018_reset_loop is 8 bit - we'll try to reset once in 255 matrix scans + // this will be approx bit more frequent than once per second + print("trying to reset mcp23018\n"); + mcp23018_status = init_mcp23018(); + if (mcp23018_status) { + print("left side not responding\n"); + } else { + print("left side attached\n"); + } + } + } + + bool changed = false; + for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) { + // select rows from left and right hands + uint8_t left_index = i; + uint8_t right_index = i + MATRIX_ROWS_PER_SIDE; + select_row(left_index); + select_row(right_index); + + // we don't need a 30us delay anymore, because selecting a + // left-hand row requires more than 30us for i2c. + + changed |= store_raw_matrix_row(left_index); + changed |= store_raw_matrix_row(right_index); + + unselect_rows(); + } + + debounce(raw_matrix, matrix, MATRIX_ROWS, changed); + matrix_scan_quantum(); + +#ifdef DEBUG_MATRIX + for (uint8_t c = 0; c < MATRIX_COLS; c++) + for (uint8_t r = 0; r < MATRIX_ROWS; r++) + if (matrix_is_on(r, c)) xprintf("r:%d c:%d \n", r, c); +#endif + + return 1; +} + +bool matrix_is_modified(void) // deprecated and evidently not called. +{ + return true; +} + +inline bool matrix_is_on(uint8_t row, uint8_t col) { return (matrix[row] & ((matrix_row_t)1 << col)); } +inline matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; } + +void matrix_print(void) { + print("\nr/c 0123456789ABCDEF\n"); + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + print_hex8(row); + print(": "); + print_bin_reverse16(matrix_get_row(row)); + print("\n"); + } +} +uint8_t matrix_key_count(void) { + uint8_t count = 0; + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + count += bitpop16(matrix[i]); + } + return count; +} + +// Remember this means ROWS +static void init_cols(void) { + for (uint8_t row = 0; row < MATRIX_COLS; row++) { + setPinInputHigh(row_pins[row]); + } +} + +static matrix_row_t read_cols(uint8_t row) { + if (row < 5) { + if (mcp23018_status) { // if there was an error + return 0; + } else { + uint8_t data = 0; + mcp23018_status = i2c_start(I2C_ADDR_READ, I2C_TIMEOUT); + if (mcp23018_status) goto out; + mcp23018_status = i2c_read_nack(I2C_TIMEOUT); + if (mcp23018_status < 0) goto out; + data = ~((uint8_t)mcp23018_status); + mcp23018_status = I2C_STATUS_SUCCESS; + out: + i2c_stop(); + +#ifdef DEBUG_MATRIX + if (data != 0x00) xprintf("I2C: %d\n", data); +#endif + return data; + } + } else { + return ~((((PINF & ROW4) >> 1) | ((PINF & (ROW1 | ROW2 | ROW3)) >> 3)) & 0xF); + } +} + +// Row pin configuration +static void unselect_rows(void) { + // no need to unselect on mcp23018, because the select step sets all + // the other row bits high, and it's not changing to a different direction + + for (uint8_t col = 0; col < MATRIX_ROWS_PER_SIDE; col++) { + setPinInput(col_pins[col]); + writePinLow(col_pins[col]); + } +} + +static void select_row(uint8_t row) { + if (row < 5) { + // select on mcp23018 + if (mcp23018_status) { // do nothing on error + } else { // set active row low : 0 // set other rows hi-Z : 1 + mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT); + if (mcp23018_status) goto out; + mcp23018_status = i2c_write(GPIOA, I2C_TIMEOUT); + if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0xFF & ~(1 << (row + 1)), I2C_TIMEOUT); + if (mcp23018_status) goto out; + out: + i2c_stop(); + } + } else { + setPinOutput(col_pins[row - MATRIX_ROWS_PER_SIDE]); + writePinLow(col_pins[row - MATRIX_ROWS_PER_SIDE]); + } +} diff --git a/keyboards/gboards/gergoplex/readme.md b/keyboards/gboards/gergoplex/readme.md new file mode 100644 index 0000000000..7728d90d41 --- /dev/null +++ b/keyboards/gboards/gergoplex/readme.md @@ -0,0 +1,43 @@ +# GergoPlex + +![GergoPlex](https://assets.bigcartel.com/product_images/248890490/IMG_20191114_1406385-01-01.jpeg) + +A compact 30% (5x3+3) Split Keyboard from g Heavy Industries + +* Keyboard Maintainer: [Jane Bernhardt](https://github.com/germ) +* Hardware Supported: GergoPlex (Kit, Partial, Ready) +* Hardware Availability: [gboards.ca](http://gboards.ca) + +## Firmware building + +Build using the following command (after setting up your build environment): + +``` +make gboards/gergoplex: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). + +Switch `default` with `colemak-dhm` if you prefer to use [Colemak Mod-DH layout](https://colemakmods.github.io/mod-dh/). |