diff options
| author | Richard Titmuss <richard.titmuss@gmail.com> | 2020-09-20 02:48:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-19 17:48:43 -0700 |
| commit | e1437c1859b088c4da7ffb517f8034723172cd82 (patch) | |
| tree | 9150a41bc34fea8937b2684138e826ead3f04fd2 /keyboards/torn | |
| parent | 741856dd57735dcd143987eb954ecc4a5ca2fc96 (diff) | |
| download | qmk_firmware-e1437c1859b088c4da7ffb517f8034723172cd82.tar.gz qmk_firmware-e1437c1859b088c4da7ffb517f8034723172cd82.zip | |
[Keyboard] Add Torn keyboard (#10207)
* Add Torn keyboard
* Apply suggestions from code review
Co-authored-by: Nick Brassel <nick@tzarc.org>
* Remove via json file
* Add mcp23081_pin_t
* Apply suggestions from code review
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
* Apply suggestions from code review
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
* Apply suggestions from code review
Co-authored-by: Drashna Jaelre <drashna@live.com>
* Apply suggestions from code review
Co-authored-by: Ryan <fauxpark@gmail.com>
Co-authored-by: Richard Titmuss <richardt@spotify.com>
Co-authored-by: Nick Brassel <nick@tzarc.org>
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
Co-authored-by: Drashna Jaelre <drashna@live.com>
Co-authored-by: Ryan <fauxpark@gmail.com>
Diffstat (limited to 'keyboards/torn')
| -rw-r--r-- | keyboards/torn/config.h | 68 | ||||
| -rw-r--r-- | keyboards/torn/info.json | 57 | ||||
| -rw-r--r-- | keyboards/torn/keymaps/default/keymap.c | 119 | ||||
| -rw-r--r-- | keyboards/torn/keymaps/via/keymap.c | 119 | ||||
| -rw-r--r-- | keyboards/torn/keymaps/via/rules.mk | 2 | ||||
| -rw-r--r-- | keyboards/torn/matrix.c | 113 | ||||
| -rw-r--r-- | keyboards/torn/mcp23018.c | 63 | ||||
| -rw-r--r-- | keyboards/torn/mcp23018.h | 32 | ||||
| -rw-r--r-- | keyboards/torn/readme.md | 21 | ||||
| -rw-r--r-- | keyboards/torn/rules.mk | 27 | ||||
| -rw-r--r-- | keyboards/torn/torn.c | 50 | ||||
| -rw-r--r-- | keyboards/torn/torn.h | 41 | ||||
| -rw-r--r-- | keyboards/torn/torn_encoder.c | 86 | ||||
| -rw-r--r-- | keyboards/torn/torn_oled.c | 63 |
14 files changed, 861 insertions, 0 deletions
diff --git a/keyboards/torn/config.h b/keyboards/torn/config.h new file mode 100644 index 000000000..6cd6c2808 --- /dev/null +++ b/keyboards/torn/config.h | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2020 Richard Titmuss <richard.titmuss@gmail.com> | ||
| 3 | * | ||
| 4 | * This program is free software: you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation, either version 2 of the License, or | ||
| 7 | * (at your option) any later version. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #pragma once | ||
| 19 | |||
| 20 | #include "config_common.h" | ||
| 21 | |||
| 22 | /* USB Device descriptor parameter */ | ||
| 23 | /* VID & PID from vusb project, see tmk_core/protocol/vusb/USB-IDs-for-free.txt"*/ | ||
| 24 | #define VENDOR_ID 0x7274 | ||
| 25 | #define PRODUCT_ID 0x0001 | ||
| 26 | #define DEVICE_VER 0x0000 | ||
| 27 | #define MANUFACTURER richard.titmuss | ||
| 28 | #define PRODUCT Torn | ||
| 29 | |||
| 30 | /* key matrix size */ | ||
| 31 | #define MATRIX_ROWS 4 | ||
| 32 | #define MATRIX_COLS 12 | ||
| 33 | |||
| 34 | /* | ||
| 35 | * Keyboard Matrix Assignments | ||
| 36 | * | ||
| 37 | * Change this to how you wired your keyboard | ||
| 38 | * COLS: AVR pins used for columns, left to right | ||
| 39 | * ROWS: AVR pins used for rows, top to bottom | ||
| 40 | * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) | ||
| 41 | * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) | ||
| 42 | * | ||
| 43 | */ | ||
| 44 | #define MATRIX_ROW_PINS \ | ||
| 45 | { D4, D1, D0, D5 } | ||
| 46 | #define MATRIX_COL_PINS \ | ||
| 47 | { B3, B4, B5, B0, D7, D6 } | ||
| 48 | #define UNUSED_PINS | ||
| 49 | |||
| 50 | #define SECONDARY_ROW_PINS \ | ||
| 51 | { (1 << 5), (1 << 6), (1 << 7), (1 << 4) } | ||
| 52 | #define SECONDARY_COL_PINS \ | ||
| 53 | { (1 << 3), (1 << 2), (1 << 1), (1 << 0), (1 << 15), (1 << 14) } | ||
| 54 | |||
| 55 | /* COL2ROW, ROW2COL*/ | ||
| 56 | #define DIODE_DIRECTION COL2ROW | ||
| 57 | |||
| 58 | #define ENCODERS_PAD_A \ | ||
| 59 | { B2 } | ||
| 60 | #define ENCODERS_PAD_B \ | ||
| 61 | { B1 } | ||
| 62 | |||
| 63 | #define USB_MAX_POWER_CONSUMPTION 100 | ||
| 64 | |||
| 65 | /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ | ||
| 66 | #define DEBOUNCE 5 | ||
| 67 | |||
| 68 | #define OLED_TIMEOUT 60000 | ||
diff --git a/keyboards/torn/info.json b/keyboards/torn/info.json new file mode 100644 index 000000000..340eb7359 --- /dev/null +++ b/keyboards/torn/info.json | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | { | ||
| 2 | "keyboard_name": "Torn / Split Through Hole", | ||
| 3 | "url": "https://github.com/rtitmuss/torn", | ||
| 4 | "maintainer": "rtitmuss", | ||
| 5 | "width": 15, | ||
| 6 | "height": 4.55, | ||
| 7 | "layouts": { | ||
| 8 | "LAYOUT_split_3x6_4": { | ||
| 9 | "layout": [ | ||
| 10 | {"label":"SW1", "x":0, "y":0.375}, | ||
| 11 | {"label":"SW2", "x":1, "y":0.375}, | ||
| 12 | {"label":"SW3", "x":2, "y":0.125}, | ||
| 13 | {"label":"SW4", "x":3, "y":0}, | ||
| 14 | {"label":"SW5", "x":4, "y":0.125}, | ||
| 15 | {"label":"SW6", "x":5, "y":0.25}, | ||
| 16 | {"label":"SW23", "x":9, "y":0.25}, | ||
| 17 | {"label":"SW24", "x":10, "y":0.125}, | ||
| 18 | {"label":"SW25", "x":11, "y":0}, | ||
| 19 | {"label":"SW26", "x":12, "y":0.125}, | ||
| 20 | {"label":"SW27", "x":13, "y":0.375}, | ||
| 21 | {"label":"SW28", "x":14, "y":0.375}, | ||
| 22 | {"label":"SW7", "x":0, "y":1.375}, | ||
| 23 | {"label":"SW8", "x":1, "y":1.375}, | ||
| 24 | {"label":"SW9", "x":2, "y":1.125}, | ||
| 25 | {"label":"SW10", "x":3, "y":1}, | ||
| 26 | {"label":"SW11", "x":4, "y":1.125}, | ||
| 27 | {"label":"SW12", "x":5, "y":1.25}, | ||
| 28 | {"label":"SW29", "x":9, "y":1.25}, | ||
| 29 | {"label":"SW30", "x":10, "y":1.125}, | ||
| 30 | {"label":"SW31", "x":11, "y":1}, | ||
| 31 | {"label":"SW32", "x":12, "y":1.125}, | ||
| 32 | {"label":"SW33", "x":13, "y":1.375}, | ||
| 33 | {"label":"SW34", "x":14, "y":1.375}, | ||
| 34 | {"label":"SW13", "x":0, "y":2.375}, | ||
| 35 | {"label":"SW14", "x":1, "y":2.375}, | ||
| 36 | {"label":"SW15", "x":2, "y":2.125}, | ||
| 37 | {"label":"SW16", "x":3, "y":2}, | ||
| 38 | {"label":"SW17", "x":4, "y":2.125}, | ||
| 39 | {"label":"SW18", "x":5, "y":2.25}, | ||
| 40 | {"label":"SW35", "x":9, "y":2.25}, | ||
| 41 | {"label":"SW36", "x":10, "y":2.125}, | ||
| 42 | {"label":"SW37", "x":11, "y":2}, | ||
| 43 | {"label":"SW38", "x":12, "y":2.125}, | ||
| 44 | {"label":"SW39", "x":13, "y":2.375}, | ||
| 45 | {"label":"SW40", "x":14, "y":2.375}, | ||
| 46 | {"label":"SW19", "x":3, "y":3.1}, | ||
| 47 | {"label":"SW20", "x":4, "y":3.25}, | ||
| 48 | {"label":"SW21", "x":5, "y":3.40}, | ||
| 49 | {"label":"SW22", "x":6, "y":3.55}, | ||
| 50 | {"label":"SW41", "x":8, "y":3.55}, | ||
| 51 | {"label":"SW42", "x":9, "y":3.40}, | ||
| 52 | {"label":"SW43", "x":10, "y":3.25}, | ||
| 53 | {"label":"SW44", "x":11, "y":3.1} | ||
| 54 | ] | ||
| 55 | } | ||
| 56 | } | ||
| 57 | } | ||
diff --git a/keyboards/torn/keymaps/default/keymap.c b/keyboards/torn/keymaps/default/keymap.c new file mode 100644 index 000000000..7c91325bd --- /dev/null +++ b/keyboards/torn/keymaps/default/keymap.c | |||
| @@ -0,0 +1,119 @@ | |||
| 1 | /* Copyright 2020 Richard Titmuss (richard.titmuss@gmail.com) | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include QMK_KEYBOARD_H | ||
| 18 | |||
| 19 | enum torn_layers { _QWERTY, _LOWER, _RAISE, _ADJUST }; | ||
| 20 | |||
| 21 | #define S_BSPC LSFT_T(KC_BSPC) | ||
| 22 | #define R_DEL LT(_RAISE, KC_DEL) | ||
| 23 | #define G_ENT LGUI_T(KC_ENT) | ||
| 24 | #define L_SPC LT(_LOWER, KC_SPC) | ||
| 25 | |||
| 26 | // clang-format off | ||
| 27 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 28 | |||
| 29 | /* Qwerty | ||
| 30 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 31 | * | Tab | Q | W | E | R | T | | Y | U | I | O | P | ' | | ||
| 32 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 33 | * | ` | A | S | D | F | G | | H | J | K | L | ; | [ | | ||
| 34 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 35 | * | \ | Z | X | C | V | B | | N | M | , | . | / | ] | | ||
| 36 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 37 | * | ____ | Ctrl | Bksp | Del | |Enter |Space | Alt | ____ | | ||
| 38 | * | | |Shift |Raise | | Gui |Lower | | | | ||
| 39 | * `---------------------------' `---------------------------' | ||
| 40 | */ | ||
| 41 | [_QWERTY] = LAYOUT_split_3x6_4( | ||
| 42 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_QUOT, | ||
| 43 | KC_GRV, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_LBRC, | ||
| 44 | KC_BSLS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RBRC , | ||
| 45 | _______, KC_LCTL, S_BSPC, R_DEL, G_ENT, L_SPC, KC_RALT, _______ | ||
| 46 | ), | ||
| 47 | |||
| 48 | /* Lower | ||
| 49 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 50 | * | Esc | ! | @ | # | $ | % | | ^ | & | * | ( | ) | | | ||
| 51 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 52 | * | = | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | - | | ||
| 53 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 54 | * | _ | | | | | | | | | , | . | / | + | | ||
| 55 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 56 | * | ____ | Ctrl | Bksp | Del | |Enter |Space | Alt | ____ | | ||
| 57 | * | | |Shift |Raise | | Gui |Lower | | | | ||
| 58 | * `---------------------------' `---------------------------' | ||
| 59 | */ | ||
| 60 | [_LOWER] = LAYOUT_split_3x6_4( | ||
| 61 | KC_ESC, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, | ||
| 62 | KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_PMNS, | ||
| 63 | KC_UNDS, _______, _______, _______, _______, _______, _______, _______, KC_COMM, KC_DOT, KC_SLSH, KC_PPLS, | ||
| 64 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS | ||
| 65 | ), | ||
| 66 | |||
| 67 | /* Raise | ||
| 68 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 69 | * | | F1 | F2 | F3 | F4 | F5 | | | & | * | ( | ) | | | ||
| 70 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 71 | * | | F6 | F7 | F8 | F9 | F10 | | Home | Left | Down | Right| End | PgUp | | ||
| 72 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 73 | * | | F11 | F12 | | | | | | | | | | PgDn | | ||
| 74 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 75 | * | ____ | Ctrl | Bksp | Del | |Enter |Space | Alt | ____ | | ||
| 76 | * | | |Shift |Raise | | Gui |Lower | | | | ||
| 77 | * `---------------------------' `---------------------------' | ||
| 78 | */ | ||
| 79 | [_RAISE] = LAYOUT_split_3x6_4( | ||
| 80 | _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______, S(A(KC_LEFT)), KC_UP, S(A(KC_RGHT)), _______, _______, | ||
| 81 | _______, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_HOME, KC_LEFT, KC_DOWN, KC_RGHT, KC_END, KC_PGUP, | ||
| 82 | _______, KC_F11, KC_F12, _______, _______, _______, A(KC_BSPC), A(KC_LEFT), S(KC_DOWN), A(KC_RGHT), _______, KC_PGDN , | ||
| 83 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS | ||
| 84 | ), | ||
| 85 | |||
| 86 | /* Adjust (Lower + Raise) | ||
| 87 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 88 | * | | | | | | | | | | | | | | | ||
| 89 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 90 | * | | | | | | | | | | | | | | | ||
| 91 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 92 | * | | | | | | | | | | | | | | | ||
| 93 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 94 | * | ____ | Ctrl | Bksp | Del | |Enter |Space | Alt | ____ | | ||
| 95 | * | | |Shift |Raise | | Gui |Lower | | | | ||
| 96 | * `---------------------------' `---------------------------' | ||
| 97 | */ | ||
| 98 | [_ADJUST] = LAYOUT_split_3x6_4( | ||
| 99 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 100 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 101 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 102 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS | ||
| 103 | ) | ||
| 104 | |||
| 105 | }; | ||
| 106 | |||
| 107 | const uint16_t PROGMEM encoder_keymaps[][2][2] = { | ||
| 108 | [_QWERTY] = { { C(S(KC_TAB)), C(KC_TAB) }, { KC_PGDN, KC_PGUP } }, | ||
| 109 | [_LOWER] = { { C(KC_LEFT), C(KC_RGHT) }, { KC__VOLDOWN, KC__VOLUP } }, | ||
| 110 | [_RAISE] = { { KC_TRNS, KC_TRNS }, { G(KC_TAB), G(S(KC_TAB)) } }, | ||
| 111 | [_ADJUST] = { { KC_TRNS, KC_TRNS }, { KC_TRNS, KC_TRNS } }, | ||
| 112 | }; | ||
| 113 | // clang-format on | ||
| 114 | |||
| 115 | layer_state_t layer_state_set_user(layer_state_t state) { | ||
| 116 | torn_set_led(0, IS_LAYER_ON_STATE(state, _RAISE)); | ||
| 117 | torn_set_led(1, IS_LAYER_ON_STATE(state, _LOWER)); | ||
| 118 | return state; | ||
| 119 | } | ||
diff --git a/keyboards/torn/keymaps/via/keymap.c b/keyboards/torn/keymaps/via/keymap.c new file mode 100644 index 000000000..7c91325bd --- /dev/null +++ b/keyboards/torn/keymaps/via/keymap.c | |||
| @@ -0,0 +1,119 @@ | |||
| 1 | /* Copyright 2020 Richard Titmuss (richard.titmuss@gmail.com) | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include QMK_KEYBOARD_H | ||
| 18 | |||
| 19 | enum torn_layers { _QWERTY, _LOWER, _RAISE, _ADJUST }; | ||
| 20 | |||
| 21 | #define S_BSPC LSFT_T(KC_BSPC) | ||
| 22 | #define R_DEL LT(_RAISE, KC_DEL) | ||
| 23 | #define G_ENT LGUI_T(KC_ENT) | ||
| 24 | #define L_SPC LT(_LOWER, KC_SPC) | ||
| 25 | |||
| 26 | // clang-format off | ||
| 27 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 28 | |||
| 29 | /* Qwerty | ||
| 30 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 31 | * | Tab | Q | W | E | R | T | | Y | U | I | O | P | ' | | ||
| 32 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 33 | * | ` | A | S | D | F | G | | H | J | K | L | ; | [ | | ||
| 34 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 35 | * | \ | Z | X | C | V | B | | N | M | , | . | / | ] | | ||
| 36 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 37 | * | ____ | Ctrl | Bksp | Del | |Enter |Space | Alt | ____ | | ||
| 38 | * | | |Shift |Raise | | Gui |Lower | | | | ||
| 39 | * `---------------------------' `---------------------------' | ||
| 40 | */ | ||
| 41 | [_QWERTY] = LAYOUT_split_3x6_4( | ||
| 42 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_QUOT, | ||
| 43 | KC_GRV, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_LBRC, | ||
| 44 | KC_BSLS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RBRC , | ||
| 45 | _______, KC_LCTL, S_BSPC, R_DEL, G_ENT, L_SPC, KC_RALT, _______ | ||
| 46 | ), | ||
| 47 | |||
| 48 | /* Lower | ||
| 49 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 50 | * | Esc | ! | @ | # | $ | % | | ^ | & | * | ( | ) | | | ||
| 51 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 52 | * | = | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | - | | ||
| 53 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 54 | * | _ | | | | | | | | | , | . | / | + | | ||
| 55 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 56 | * | ____ | Ctrl | Bksp | Del | |Enter |Space | Alt | ____ | | ||
| 57 | * | | |Shift |Raise | | Gui |Lower | | | | ||
| 58 | * `---------------------------' `---------------------------' | ||
| 59 | */ | ||
| 60 | [_LOWER] = LAYOUT_split_3x6_4( | ||
| 61 | KC_ESC, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, | ||
| 62 | KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_PMNS, | ||
| 63 | KC_UNDS, _______, _______, _______, _______, _______, _______, _______, KC_COMM, KC_DOT, KC_SLSH, KC_PPLS, | ||
| 64 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS | ||
| 65 | ), | ||
| 66 | |||
| 67 | /* Raise | ||
| 68 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 69 | * | | F1 | F2 | F3 | F4 | F5 | | | & | * | ( | ) | | | ||
| 70 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 71 | * | | F6 | F7 | F8 | F9 | F10 | | Home | Left | Down | Right| End | PgUp | | ||
| 72 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 73 | * | | F11 | F12 | | | | | | | | | | PgDn | | ||
| 74 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 75 | * | ____ | Ctrl | Bksp | Del | |Enter |Space | Alt | ____ | | ||
| 76 | * | | |Shift |Raise | | Gui |Lower | | | | ||
| 77 | * `---------------------------' `---------------------------' | ||
| 78 | */ | ||
| 79 | [_RAISE] = LAYOUT_split_3x6_4( | ||
| 80 | _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______, S(A(KC_LEFT)), KC_UP, S(A(KC_RGHT)), _______, _______, | ||
| 81 | _______, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_HOME, KC_LEFT, KC_DOWN, KC_RGHT, KC_END, KC_PGUP, | ||
| 82 | _______, KC_F11, KC_F12, _______, _______, _______, A(KC_BSPC), A(KC_LEFT), S(KC_DOWN), A(KC_RGHT), _______, KC_PGDN , | ||
| 83 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS | ||
| 84 | ), | ||
| 85 | |||
| 86 | /* Adjust (Lower + Raise) | ||
| 87 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 88 | * | | | | | | | | | | | | | | | ||
| 89 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 90 | * | | | | | | | | | | | | | | | ||
| 91 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 92 | * | | | | | | | | | | | | | | | ||
| 93 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 94 | * | ____ | Ctrl | Bksp | Del | |Enter |Space | Alt | ____ | | ||
| 95 | * | | |Shift |Raise | | Gui |Lower | | | | ||
| 96 | * `---------------------------' `---------------------------' | ||
| 97 | */ | ||
| 98 | [_ADJUST] = LAYOUT_split_3x6_4( | ||
| 99 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 100 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 101 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 102 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS | ||
| 103 | ) | ||
| 104 | |||
| 105 | }; | ||
| 106 | |||
| 107 | const uint16_t PROGMEM encoder_keymaps[][2][2] = { | ||
| 108 | [_QWERTY] = { { C(S(KC_TAB)), C(KC_TAB) }, { KC_PGDN, KC_PGUP } }, | ||
| 109 | [_LOWER] = { { C(KC_LEFT), C(KC_RGHT) }, { KC__VOLDOWN, KC__VOLUP } }, | ||
| 110 | [_RAISE] = { { KC_TRNS, KC_TRNS }, { G(KC_TAB), G(S(KC_TAB)) } }, | ||
| 111 | [_ADJUST] = { { KC_TRNS, KC_TRNS }, { KC_TRNS, KC_TRNS } }, | ||
| 112 | }; | ||
| 113 | // clang-format on | ||
| 114 | |||
| 115 | layer_state_t layer_state_set_user(layer_state_t state) { | ||
| 116 | torn_set_led(0, IS_LAYER_ON_STATE(state, _RAISE)); | ||
| 117 | torn_set_led(1, IS_LAYER_ON_STATE(state, _LOWER)); | ||
| 118 | return state; | ||
| 119 | } | ||
diff --git a/keyboards/torn/keymaps/via/rules.mk b/keyboards/torn/keymaps/via/rules.mk new file mode 100644 index 000000000..36b7ba9cb --- /dev/null +++ b/keyboards/torn/keymaps/via/rules.mk | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | VIA_ENABLE = yes | ||
| 2 | LTO_ENABLE = yes | ||
diff --git a/keyboards/torn/matrix.c b/keyboards/torn/matrix.c new file mode 100644 index 000000000..dd7fa1e2e --- /dev/null +++ b/keyboards/torn/matrix.c | |||
| @@ -0,0 +1,113 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2020 Richard Titmuss (richard.titmuss@gmail.com) | ||
| 3 | * Copyright 2012-2018 Jun Wako, Jack Humbert, Yiancar | ||
| 4 | * | ||
| 5 | * This program is free software: you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation, either version 2 of the License, or | ||
| 8 | * (at your option) any later version. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include QMK_KEYBOARD_H | ||
| 20 | #include "mcp23018.h" | ||
| 21 | |||
| 22 | #define SPLIT_MATRIX_COLS (MATRIX_COLS / 2) | ||
| 23 | #define SECONDARY_ROW_OFFSET (MATRIX_ROWS / 2) | ||
| 24 | |||
| 25 | typedef uint16_t mcp23018_pin_t; | ||
| 26 | |||
| 27 | static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; | ||
| 28 | static const pin_t col_pins[SPLIT_MATRIX_COLS] = MATRIX_COL_PINS; | ||
| 29 | static const mcp23018_pin_t secondary_row_pins[MATRIX_ROWS] = SECONDARY_ROW_PINS; | ||
| 30 | static const mcp23018_pin_t secondary_col_pins[SPLIT_MATRIX_COLS] = SECONDARY_COL_PINS; | ||
| 31 | |||
| 32 | static void select_row(uint8_t row) { | ||
| 33 | setPinOutput(row_pins[row]); | ||
| 34 | writePinLow(row_pins[row]); | ||
| 35 | } | ||
| 36 | |||
| 37 | static void unselect_row(uint8_t row) { setPinInputHigh(row_pins[row]); } | ||
| 38 | |||
| 39 | static void unselect_rows(void) { | ||
| 40 | for (uint8_t x = 0; x < MATRIX_ROWS; x++) { | ||
| 41 | setPinInputHigh(row_pins[x]); | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | static void select_secondary_row(uint8_t row) { | ||
| 46 | uint8_t gpioa = 0xFF & ~secondary_row_pins[row]; | ||
| 47 | mcp23018_writeReg(GPIOA, &gpioa, 1); | ||
| 48 | } | ||
| 49 | |||
| 50 | static void init_pins(void) { | ||
| 51 | unselect_rows(); | ||
| 52 | for (uint8_t x = 0; x < SPLIT_MATRIX_COLS; x++) { | ||
| 53 | setPinInputHigh(col_pins[x]); | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | static matrix_row_t read_cols(void) { | ||
| 58 | matrix_row_t state = 0; | ||
| 59 | |||
| 60 | // For each col... | ||
| 61 | for (uint8_t col_index = 0; col_index < SPLIT_MATRIX_COLS; col_index++) { | ||
| 62 | // Select the col pin to read (active low) | ||
| 63 | uint8_t pin_state = readPin(col_pins[col_index]); | ||
| 64 | |||
| 65 | // Populate the matrix row with the state of the col pin | ||
| 66 | state |= pin_state ? 0 : (MATRIX_ROW_SHIFTER << col_index); | ||
| 67 | } | ||
| 68 | |||
| 69 | return state; | ||
| 70 | } | ||
| 71 | |||
| 72 | static matrix_row_t read_secondary_cols(void) { | ||
| 73 | matrix_row_t state = 0; | ||
| 74 | |||
| 75 | uint8_t mcp23018_pin_state[2]; | ||
| 76 | if (mcp23018_readReg(GPIOA, mcp23018_pin_state, 2)) { | ||
| 77 | return 0; | ||
| 78 | } | ||
| 79 | |||
| 80 | uint16_t pins = mcp23018_pin_state[0] | (mcp23018_pin_state[1] << 8); | ||
| 81 | |||
| 82 | for (uint8_t col_index = 0; col_index < SPLIT_MATRIX_COLS; col_index++) { | ||
| 83 | uint16_t pin_state = pins & (secondary_col_pins[col_index]); | ||
| 84 | state |= pin_state ? 0 : (MATRIX_ROW_SHIFTER << col_index); | ||
| 85 | } | ||
| 86 | |||
| 87 | return state; | ||
| 88 | } | ||
| 89 | |||
| 90 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { | ||
| 91 | matrix_row_t last_row_value = current_matrix[current_row]; | ||
| 92 | |||
| 93 | select_row(current_row); | ||
| 94 | select_secondary_row(current_row); | ||
| 95 | |||
| 96 | current_matrix[current_row] = read_cols() | (read_secondary_cols() << 6); | ||
| 97 | |||
| 98 | unselect_row(current_row); | ||
| 99 | |||
| 100 | return (last_row_value != current_matrix[current_row]); | ||
| 101 | } | ||
| 102 | |||
| 103 | void matrix_init_custom(void) { init_pins(); } | ||
| 104 | |||
| 105 | bool matrix_scan_custom(matrix_row_t current_matrix[]) { | ||
| 106 | bool changed = false; | ||
| 107 | |||
| 108 | for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { | ||
| 109 | changed |= read_cols_on_row(current_matrix, current_row); | ||
| 110 | } | ||
| 111 | |||
| 112 | return changed; | ||
| 113 | } | ||
diff --git a/keyboards/torn/mcp23018.c b/keyboards/torn/mcp23018.c new file mode 100644 index 000000000..c180f1dae --- /dev/null +++ b/keyboards/torn/mcp23018.c | |||
| @@ -0,0 +1,63 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2020 Richard Titmuss (richard.titmuss@gmail.com) | ||
| 3 | * Copyright 2012-2018 Jun Wako, Jack Humbert, Yiancar | ||
| 4 | * | ||
| 5 | * This program is free software: you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation, either version 2 of the License, or | ||
| 8 | * (at your option) any later version. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include QMK_KEYBOARD_H | ||
| 20 | #include "i2c_master.h" | ||
| 21 | #include "mcp23018.h" | ||
| 22 | |||
| 23 | #define MCP23018_ADDR 0b0100000 | ||
| 24 | |||
| 25 | #define MCP23018_TIMEOUT 100 | ||
| 26 | |||
| 27 | static i2c_status_t mcp23018_status = I2C_STATUS_ERROR; | ||
| 28 | |||
| 29 | void msp23018_init(void) { | ||
| 30 | mcp23018_status = I2C_STATUS_SUCCESS; | ||
| 31 | |||
| 32 | // Set pin direction | ||
| 33 | uint8_t iodir[] = {0b00001111, 0b11111111}; | ||
| 34 | mcp23018_writeReg(IODIRA, iodir, 2); | ||
| 35 | |||
| 36 | // Set pull-up | ||
| 37 | uint8_t gppu[] = {0b00001111, 0b11111000}; | ||
| 38 | mcp23018_writeReg(GPPUA, gppu, 2); | ||
| 39 | |||
| 40 | // LEDs output high | ||
| 41 | uint8_t gpio[] = {0b00000000, 0b00000111}; | ||
| 42 | mcp23018_writeReg(GPIOA, gpio, 2); | ||
| 43 | } | ||
| 44 | |||
| 45 | bool mcp23018_reset_required(void) { return mcp23018_status != I2C_STATUS_SUCCESS; } | ||
| 46 | |||
| 47 | i2c_status_t mcp23018_writeReg(uint8_t regaddr, const uint8_t* data, uint16_t length) { | ||
| 48 | if (mcp23018_status) { | ||
| 49 | return mcp23018_status; | ||
| 50 | } | ||
| 51 | |||
| 52 | mcp23018_status = i2c_writeReg((MCP23018_ADDR << 1), regaddr, data, length, MCP23018_TIMEOUT); | ||
| 53 | return mcp23018_status; | ||
| 54 | } | ||
| 55 | |||
| 56 | i2c_status_t mcp23018_readReg(uint8_t regaddr, uint8_t* data, uint16_t length) { | ||
| 57 | if (mcp23018_status) { | ||
| 58 | return mcp23018_status; | ||
| 59 | } | ||
| 60 | |||
| 61 | mcp23018_status = i2c_readReg((MCP23018_ADDR << 1), regaddr, data, length, MCP23018_TIMEOUT); | ||
| 62 | return mcp23018_status; | ||
| 63 | } | ||
diff --git a/keyboards/torn/mcp23018.h b/keyboards/torn/mcp23018.h new file mode 100644 index 000000000..17ecaa5a7 --- /dev/null +++ b/keyboards/torn/mcp23018.h | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2020 Richard Titmuss (richard.titmuss@gmail.com) | ||
| 3 | * | ||
| 4 | * This program is free software: you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation, either version 2 of the License, or | ||
| 7 | * (at your option) any later version. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #pragma once | ||
| 19 | |||
| 20 | #define IODIRA 0x00 | ||
| 21 | #define IODIRB 0x01 | ||
| 22 | #define GPPUA 0x0C | ||
| 23 | #define GPPUB 0x0D | ||
| 24 | #define GPIOA 0x12 | ||
| 25 | #define GPIOB 0x13 | ||
| 26 | |||
| 27 | typedef int16_t mcp23018_status_t; | ||
| 28 | |||
| 29 | void msp23018_init(void); | ||
| 30 | bool mcp23018_reset_required(void); | ||
| 31 | mcp23018_status_t mcp23018_writeReg(uint8_t regaddr, const uint8_t* data, uint16_t length); | ||
| 32 | mcp23018_status_t mcp23018_readReg(uint8_t regaddr, uint8_t* data, uint16_t length); | ||
diff --git a/keyboards/torn/readme.md b/keyboards/torn/readme.md new file mode 100644 index 000000000..ffe9a2d9c --- /dev/null +++ b/keyboards/torn/readme.md | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | # TORN// Split Through Hole | ||
| 2 | |||
| 3 |  | ||
| 4 | |||
| 5 | The split keyboard kit made by through hole components only. | ||
| 6 | |||
| 7 | The design has been inspired by the Corne, Plaid and Discipline keyboards. | ||
| 8 | |||
| 9 | * Keyboard Maintainer: [rtitmuss](https://github.com/rtitmuss) | ||
| 10 | * Hardware Supported: TORN, atmega328p | ||
| 11 | * Hardware Availability: [GitHub](https://github.com/rtitmuss/torn) | ||
| 12 | |||
| 13 | Make example for this keyboard (after setting up your build environment): | ||
| 14 | |||
| 15 | make torn:default | ||
| 16 | |||
| 17 | Flashing example for this keyboard: | ||
| 18 | |||
| 19 | make torn:default:flash | ||
| 20 | |||
| 21 | 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/torn/rules.mk b/keyboards/torn/rules.mk new file mode 100644 index 000000000..caf544d13 --- /dev/null +++ b/keyboards/torn/rules.mk | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | # MCU name | ||
| 2 | MCU = atmega328p | ||
| 3 | |||
| 4 | # Bootloader selection | ||
| 5 | BOOTLOADER = USBasp | ||
| 6 | |||
| 7 | # Build Options | ||
| 8 | # change yes to no to disable | ||
| 9 | # | ||
| 10 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration | ||
| 11 | MOUSEKEY_ENABLE = no # Mouse keys | ||
| 12 | EXTRAKEY_ENABLE = no # Audio control and System control | ||
| 13 | CONSOLE_ENABLE = no # Console for debug | ||
| 14 | COMMAND_ENABLE = no # Commands for debug and configuration | ||
| 15 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | ||
| 16 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | ||
| 17 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality | ||
| 18 | RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow | ||
| 19 | ENCODER_ENABLE = yes # Enable rotary encoder | ||
| 20 | OLED_DRIVER_ENABLE = yes | ||
| 21 | CUSTOM_MATRIX = lite | ||
| 22 | |||
| 23 | SRC += matrix.c \ | ||
| 24 | mcp23018.c \ | ||
| 25 | torn_encoder.c \ | ||
| 26 | torn_oled.c | ||
| 27 | QUANTUM_LIB_SRC += i2c_master.c | ||
diff --git a/keyboards/torn/torn.c b/keyboards/torn/torn.c new file mode 100644 index 000000000..ef5060e60 --- /dev/null +++ b/keyboards/torn/torn.c | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2020 Richard Titmuss <richard.titmuss@gmail.com> | ||
| 3 | * | ||
| 4 | * This program is free software: you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation, either version 2 of the License, or | ||
| 7 | * (at your option) any later version. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | #include "torn.h" | ||
| 18 | #include "i2c_master.h" | ||
| 19 | #include "mcp23018.h" | ||
| 20 | |||
| 21 | static uint8_t led_state[3] = {1, 1, 1}; | ||
| 22 | |||
| 23 | void matrix_init_kb(void) { | ||
| 24 | // put your keyboard start-up code here | ||
| 25 | // runs once when the firmware starts up | ||
| 26 | i2c_init(); | ||
| 27 | |||
| 28 | matrix_init_user(); | ||
| 29 | } | ||
| 30 | |||
| 31 | void matrix_scan_kb(void) { | ||
| 32 | // put your looping keyboard code here | ||
| 33 | // runs every cycle (a lot) | ||
| 34 | if (mcp23018_reset_required()) { | ||
| 35 | msp23018_init(); | ||
| 36 | secondary_encoder_init(); | ||
| 37 | // torn_set_led(2, 1); | ||
| 38 | } | ||
| 39 | |||
| 40 | matrix_scan_user(); | ||
| 41 | secondary_encoder_read(); | ||
| 42 | } | ||
| 43 | |||
| 44 | void torn_set_led(uint8_t led, bool state) { | ||
| 45 | led_state[led] = !state; | ||
| 46 | |||
| 47 | // toggle leds by setting the pin direction | ||
| 48 | uint8_t iodir = 0b11111000 | led_state[0] << 2 | led_state[1] << 1 | led_state[2]; | ||
| 49 | mcp23018_writeReg(IODIRB, &iodir, 1); | ||
| 50 | } | ||
diff --git a/keyboards/torn/torn.h b/keyboards/torn/torn.h new file mode 100644 index 000000000..c25b5c2a0 --- /dev/null +++ b/keyboards/torn/torn.h | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2020 Richard Titmuss <richard.titmuss@gmail.com> | ||
| 3 | * | ||
| 4 | * This program is free software: you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation, either version 2 of the License, or | ||
| 7 | * (at your option) any later version. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #pragma once | ||
| 19 | |||
| 20 | #include "quantum.h" | ||
| 21 | |||
| 22 | #define ___ KC_NO | ||
| 23 | |||
| 24 | // clang-format off | ||
| 25 | #define LAYOUT_split_3x6_4( \ | ||
| 26 | k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \ | ||
| 27 | k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, \ | ||
| 28 | k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, \ | ||
| 29 | k32, k33, k34, k35, k36, k37, k38, k39 \ | ||
| 30 | ) { \ | ||
| 31 | { k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b }, \ | ||
| 32 | { k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b }, \ | ||
| 33 | { k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b }, \ | ||
| 34 | { ___, ___, k32, k33, k34, k35, k36, k37, k38, k39, ___, ___ } \ | ||
| 35 | } | ||
| 36 | // clang-format on | ||
| 37 | |||
| 38 | void torn_set_led(uint8_t led, bool on); | ||
| 39 | |||
| 40 | void secondary_encoder_read(void); | ||
| 41 | void secondary_encoder_init(void); | ||
diff --git a/keyboards/torn/torn_encoder.c b/keyboards/torn/torn_encoder.c new file mode 100644 index 000000000..ef9b0873f --- /dev/null +++ b/keyboards/torn/torn_encoder.c | |||
| @@ -0,0 +1,86 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2020 Richard Titmuss <richard.titmuss@gmail.com> | ||
| 3 | * Copyright 2018 Jack Humbert <jack.humb@gmail.com> | ||
| 4 | * | ||
| 5 | * This program is free software: you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation, either version 2 of the License, or | ||
| 8 | * (at your option) any later version. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include "torn.h" | ||
| 20 | #include "mcp23018.h" | ||
| 21 | |||
| 22 | #ifndef ENCODER_RESOLUTION | ||
| 23 | # define ENCODER_RESOLUTION 4 | ||
| 24 | #endif | ||
| 25 | |||
| 26 | #define ENCODER_CLOCKWISE true | ||
| 27 | #define ENCODER_COUNTER_CLOCKWISE false | ||
| 28 | |||
| 29 | static int8_t encoder_LUT[] = {0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0}; | ||
| 30 | |||
| 31 | static uint8_t encoder_state = 0; | ||
| 32 | static int8_t encoder_pulses = 0; | ||
| 33 | |||
| 34 | extern const uint16_t PROGMEM encoder_keymaps[][2][2]; | ||
| 35 | |||
| 36 | /** | ||
| 37 | * Tap on encoder updates using the encoder keymap | ||
| 38 | */ | ||
| 39 | void encoder_update_kb(uint8_t index, bool clockwise) { | ||
| 40 | int layer = get_highest_layer(layer_state); | ||
| 41 | |||
| 42 | uint16_t code; | ||
| 43 | do { | ||
| 44 | code = pgm_read_word(&encoder_keymaps[layer--][index][clockwise]); | ||
| 45 | } while (code == KC_TRNS); | ||
| 46 | |||
| 47 | tap_code16(code); | ||
| 48 | } | ||
| 49 | |||
| 50 | static bool encoder_read_state(uint8_t *state) { | ||
| 51 | uint8_t mcp23018_pin_state; | ||
| 52 | mcp23018_status_t status = mcp23018_readReg(GPIOB, &mcp23018_pin_state, 1); | ||
| 53 | if (status == 0) { | ||
| 54 | *state = (mcp23018_pin_state & 0b110000) >> 4; | ||
| 55 | return true; | ||
| 56 | } | ||
| 57 | return false; | ||
| 58 | } | ||
| 59 | |||
| 60 | static void encoder_update(int8_t index, uint8_t state) { | ||
| 61 | encoder_pulses += encoder_LUT[state & 0xF]; | ||
| 62 | if (encoder_pulses >= ENCODER_RESOLUTION) { | ||
| 63 | encoder_update_kb(index, ENCODER_CLOCKWISE); | ||
| 64 | } | ||
| 65 | if (encoder_pulses <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise | ||
| 66 | encoder_update_kb(index, ENCODER_COUNTER_CLOCKWISE); | ||
| 67 | } | ||
| 68 | encoder_pulses %= ENCODER_RESOLUTION; | ||
| 69 | } | ||
| 70 | |||
| 71 | /** | ||
| 72 | * Read the secondary encoder over i2c | ||
| 73 | */ | ||
| 74 | void secondary_encoder_read(void) { | ||
| 75 | uint8_t state; | ||
| 76 | if (encoder_read_state(&state)) { | ||
| 77 | encoder_state <<= 2; | ||
| 78 | encoder_state |= state; | ||
| 79 | encoder_update(1, encoder_state); | ||
| 80 | } | ||
| 81 | } | ||
| 82 | |||
| 83 | /** | ||
| 84 | * Initialize the secondary encoder over i2c | ||
| 85 | */ | ||
| 86 | void secondary_encoder_init(void) { encoder_read_state(&encoder_state); } | ||
diff --git a/keyboards/torn/torn_oled.c b/keyboards/torn/torn_oled.c new file mode 100644 index 000000000..834abf96c --- /dev/null +++ b/keyboards/torn/torn_oled.c | |||
| @@ -0,0 +1,63 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2020 Richard Titmuss <richard.titmuss@gmail.com> | ||
| 3 | * | ||
| 4 | * This program is free software: you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation, either version 2 of the License, or | ||
| 7 | * (at your option) any later version. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | #include QMK_KEYBOARD_H | ||
| 18 | |||
| 19 | #ifdef OLED_DRIVER_ENABLE | ||
| 20 | |||
| 21 | // clang-format off | ||
| 22 | __attribute__((weak)) | ||
| 23 | void oled_task_user(void) { | ||
| 24 | static const char PROGMEM torn_logo[] = { | ||
| 25 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xf8, 0x98, 0x98, 0x98, 0x98, 0x98, 0x18, 0x18, 0x98, | ||
| 26 | 0x98, 0x98, 0x98, 0x98, 0xf8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 27 | 0x00, 0x00, 0x00, 0x80, 0xc0, 0x60, 0x30, 0x30, 0x18, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, | ||
| 28 | 0x18, 0x30, 0x30, 0x60, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 29 | 0x00, 0x00, 0x00, 0x00, 0xf8, 0xf8, 0x18, 0x18, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x18, 0x38, | ||
| 30 | 0x70, 0xe0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 31 | 0xf8, 0xf8, 0x38, 0x70, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 32 | 0xf8, 0xf8, 0x18, 0x18, 0xf8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0xff, 0xff, 0x00, 0x00, 0xff, | ||
| 34 | 0xff, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 35 | 0xf8, 0xfe, 0x07, 0x01, 0xf0, 0xfc, 0x0e, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, | ||
| 36 | 0x03, 0x03, 0x0e, 0xfc, 0xf0, 0x01, 0x07, 0xfe, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 37 | 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xc1, 0xc1, 0xc1, 0x63, 0x3f, 0x1c, | ||
| 38 | 0xc0, 0xe1, 0x7f, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 39 | 0xff, 0xff, 0x00, 0x00, 0xf8, 0xf1, 0xe3, 0xc7, 0x8e, 0x1c, 0x38, 0x70, 0xe0, 0xc0, 0x80, 0x00, | ||
| 40 | 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 41 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, | ||
| 42 | 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 43 | 0x0f, 0x3f, 0x70, 0xc0, 0x87, 0x1f, 0x38, 0x60, 0x60, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, | ||
| 44 | 0x60, 0x60, 0x38, 0x1f, 0x87, 0xc0, 0xf0, 0x7f, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 45 | 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xfe, 0xfe, 0x0e, 0x3c, 0x78, 0xe2, 0xc7, 0x1f, | ||
| 46 | 0x39, 0xe0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 47 | 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x01, 0x03, 0x07, 0x0e, 0x1c, 0x38, 0x71, 0xe3, 0xc7, | ||
| 48 | 0x8f, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0c, 0x0c, 0x0f, | ||
| 50 | 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 51 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x06, 0x06, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, | ||
| 52 | 0x0c, 0x06, 0x06, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 53 | 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0c, 0x0c, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0f, | ||
| 54 | 0x0c, 0x0c, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 55 | 0x0f, 0x0f, 0x0c, 0x0c, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, | ||
| 56 | 0x03, 0x07, 0x0e, 0x0c, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | ||
| 57 | }; | ||
| 58 | |||
| 59 | oled_write_raw_P(torn_logo, sizeof(torn_logo)); | ||
| 60 | } | ||
| 61 | // clang-format on | ||
| 62 | |||
| 63 | #endif | ||
