diff options
| author | MechMerlin <30334081+mechmerlin@users.noreply.github.com> | 2018-08-28 16:52:00 -0700 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2018-08-28 16:52:00 -0700 |
| commit | 3916b06168f39233f77a252fbf5f9cfdae3df4fe (patch) | |
| tree | 672677c365c8d0455328b1ff3b0c32e434a7ab97 /keyboards/duck | |
| parent | 444def8411d6ac67203c14ec92f8e33d77330895 (diff) | |
| download | qmk_firmware-3916b06168f39233f77a252fbf5f9cfdae3df4fe.tar.gz qmk_firmware-3916b06168f39233f77a252fbf5f9cfdae3df4fe.zip | |
Putting my ducks in a row: Octagon V1/V2 (#3765)
* Move octagon directory into duck diretory and fix as many compile issues as I can
* fix formatting
* fix layout75 matrix
* edit readme for build instructions
Diffstat (limited to 'keyboards/duck')
21 files changed, 1284 insertions, 1 deletions
diff --git a/keyboards/duck/jetfire/readme.md b/keyboards/duck/jetfire/readme.md index fb5baf975..fe641e622 100644 --- a/keyboards/duck/jetfire/readme.md +++ b/keyboards/duck/jetfire/readme.md | |||
| @@ -13,6 +13,6 @@ To get into bootloader mode, hold the top top most key above the 2 navigation ke | |||
| 13 | 13 | ||
| 14 | Make example for this keyboard (after setting up your build environment): | 14 | Make example for this keyboard (after setting up your build environment): |
| 15 | 15 | ||
| 16 | make jetfire:default | 16 | make duck/jetfire:default |
| 17 | 17 | ||
| 18 | See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information. | 18 | See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information. |
diff --git a/keyboards/duck/octagon/keymaps/default/keymap.c b/keyboards/duck/octagon/keymaps/default/keymap.c new file mode 100644 index 000000000..a2029ba05 --- /dev/null +++ b/keyboards/duck/octagon/keymaps/default/keymap.c | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | /* Copyright 2018 MechMerlin <mechmerlin@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 | #include QMK_KEYBOARD_H | ||
| 17 | |||
| 18 | #define _BL 0 // Base Layer | ||
| 19 | #define _FL 1 // Fn Layer | ||
| 20 | |||
| 21 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 22 | [_BL] = LAYOUT_75_ansi(\ | ||
| 23 | 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_PAUS, KC_DEL, | ||
| 24 | 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_HOME, | ||
| 25 | 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_PGUP, | ||
| 26 | 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_PGDN, | ||
| 27 | 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_UP, KC_END, | ||
| 28 | KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(_FL), KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT), | ||
| 29 | |||
| 30 | [_FL] = LAYOUT_75_ansi(\ | ||
| 31 | KC_TRNS, RGB_TOG, RGB_MOD, RGB_VAI, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
| 32 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
| 33 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
| 34 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
| 35 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
| 36 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), | ||
| 37 | }; \ No newline at end of file | ||
diff --git a/keyboards/duck/octagon/keymaps/default/readme.md b/keyboards/duck/octagon/keymaps/default/readme.md new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/keyboards/duck/octagon/keymaps/default/readme.md | |||
diff --git a/keyboards/duck/octagon/readme.md b/keyboards/duck/octagon/readme.md new file mode 100644 index 000000000..7f5b2f7e6 --- /dev/null +++ b/keyboards/duck/octagon/readme.md | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | # Duck Octagon | ||
| 2 | |||
| 3 | Non official firmware for custom Korean keyboard with 75% key layout made by Duck. | ||
| 4 | |||
| 5 | See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information. | ||
| 6 | |||
| 7 | Newest version is the [Octagon V2](http://duck0113.tistory.com/127) | ||
| 8 | |||
| 9 | Make example for this keyboard (after setting up your build environment): | ||
| 10 | |||
| 11 | make duck/octagon/v2:default | ||
diff --git a/keyboards/duck/octagon/rules.mk b/keyboards/duck/octagon/rules.mk new file mode 100644 index 000000000..46bd457bb --- /dev/null +++ b/keyboards/duck/octagon/rules.mk | |||
| @@ -0,0 +1 @@ | |||
| DEFAULT_FOLDER = duck/octagon/v2 \ No newline at end of file | |||
diff --git a/keyboards/duck/octagon/v1/config.h b/keyboards/duck/octagon/v1/config.h new file mode 100644 index 000000000..fbbc8999b --- /dev/null +++ b/keyboards/duck/octagon/v1/config.h | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2017 MechMerlin <mechmerlin@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 | #ifndef CONFIG_H | ||
| 19 | #define CONFIG_H | ||
| 20 | |||
| 21 | #include "config_common.h" | ||
| 22 | |||
| 23 | /* USB Device descriptor parameter */ | ||
| 24 | #define VENDOR_ID 0xFEED | ||
| 25 | #define PRODUCT_ID 0x6050 | ||
| 26 | #define DEVICE_VER 0x0104 | ||
| 27 | #define MANUFACTURER Duck | ||
| 28 | #define PRODUCT Octagon V1 | ||
| 29 | #define DESCRIPTION Duck Octagon V1 | ||
| 30 | |||
| 31 | /* key matrix size */ | ||
| 32 | #define MATRIX_ROWS 6 | ||
| 33 | #define MATRIX_COLS 16 | ||
| 34 | |||
| 35 | #define DIODE_DIRECTION COL2ROW | ||
| 36 | |||
| 37 | /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ | ||
| 38 | #define DEBOUNCING_DELAY 5 | ||
| 39 | |||
| 40 | /* number of backlight levels */ | ||
| 41 | #define BACKLIGHT_LEVELS 1 | ||
| 42 | |||
| 43 | /* key combination for magic key command */ | ||
| 44 | #define IS_COMMAND() ( \ | ||
| 45 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
| 46 | ) | ||
| 47 | |||
| 48 | #define RGBLIGHT_ANIMATIONS | ||
| 49 | #define RGB_DI_PIN D6 | ||
| 50 | #define RGBLED_NUM 17 | ||
| 51 | |||
| 52 | #define TAPPING_TERM 200 | ||
| 53 | |||
| 54 | #endif | ||
diff --git a/keyboards/duck/octagon/v1/info.json b/keyboards/duck/octagon/v1/info.json new file mode 100644 index 000000000..1feff9519 --- /dev/null +++ b/keyboards/duck/octagon/v1/info.json | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | { | ||
| 2 | "keyboard_name": "Octagon V1", | ||
| 3 | "url": "", | ||
| 4 | "maintainer": "qmk", | ||
| 5 | "width": 16, | ||
| 6 | "height": 6, | ||
| 7 | "layouts": { | ||
| 8 | "LAYOUT": { | ||
| 9 | "layout": [{"label":"Esc", "x":0, "y":0}, {"label":"F1", "x":1, "y":0}, {"label":"F2", "x":2, "y":0}, {"label":"F3", "x":3, "y":0}, {"label":"F4", "x":4, "y":0}, {"label":"F5", "x":5, "y":0}, {"label":"F6", "x":6, "y":0}, {"label":"F7", "x":7, "y":0}, {"label":"F8", "x":8, "y":0}, {"label":"F9", "x":9, "y":0}, {"label":"F10", "x":10, "y":0}, {"label":"F11", "x":11, "y":0}, {"label":"F12", "x":12, "y":0}, {"label":"PrtSc", "x":13, "y":0}, {"label":"Pause", "x":14, "y":0}, {"label":"~", "x":0, "y":1}, {"label":"!", "x":1, "y":1}, {"label":"@", "x":2, "y":1}, {"label":"#", "x":3, "y":1}, {"label":"$", "x":4, "y":1}, {"label":"%", "x":5, "y":1}, {"label":"^", "x":6, "y":1}, {"label":"&", "x":7, "y":1}, {"label":"*", "x":8, "y":1}, {"label":"(", "x":9, "y":1}, {"label":")", "x":10, "y":1}, {"label":"_", "x":11, "y":1}, {"label":"+", "x":12, "y":1}, {"label":"Backspace", "x":13, "y":1, "w":2}, {"label":"Home", "x":15, "y":1}, {"label":"Tab", "x":0, "y":2, "w":1.5}, {"label":"Q", "x":1.5, "y":2}, {"label":"W", "x":2.5, "y":2}, {"label":"E", "x":3.5, "y":2}, {"label":"R", "x":4.5, "y":2}, {"label":"T", "x":5.5, "y":2}, {"label":"Y", "x":6.5, "y":2}, {"label":"U", "x":7.5, "y":2}, {"label":"I", "x":8.5, "y":2}, {"label":"O", "x":9.5, "y":2}, {"label":"P", "x":10.5, "y":2}, {"label":"{", "x":11.5, "y":2}, {"label":"}", "x":12.5, "y":2}, {"label":"|", "x":13.5, "y":2, "w":1.5}, {"label":"Page Up", "x":15, "y":2}, {"label":"Caps Lock", "x":0, "y":3, "w":1.75}, {"label":"A", "x":1.75, "y":3}, {"label":"S", "x":2.75, "y":3}, {"label":"D", "x":3.75, "y":3}, {"label":"F", "x":4.75, "y":3}, {"label":"G", "x":5.75, "y":3}, {"label":"H", "x":6.75, "y":3}, {"label":"J", "x":7.75, "y":3}, {"label":"K", "x":8.75, "y":3}, {"label":"L", "x":9.75, "y":3}, {"label":":", "x":10.75, "y":3}, {"label":"\"", "x":11.75, "y":3}, {"x":12.75, "y":3}, {"label":"Enter", "x":13.75, "y":3, "w":1.25}, {"label":"Page Down", "x":15, "y":3}, {"label":"Shift", "x":0, "y":4, "w":2.25}, {"label":"Z", "x":2.25, "y":4}, {"label":"X", "x":3.25, "y":4}, {"label":"C", "x":4.25, "y":4}, {"label":"V", "x":5.25, "y":4}, {"label":"B", "x":6.25, "y":4}, {"label":"N", "x":7.25, "y":4}, {"label":"M", "x":8.25, "y":4}, {"label":"<", "x":9.25, "y":4}, {"label":">", "x":10.25, "y":4}, {"label":"?", "x":11.25, "y":4}, {"label":"Shift", "x":12.25, "y":4, "w":1.75}, {"label":"\u2191", "x":14, "y":4}, {"label":"End", "x":15, "y":4}, {"label":"Ctrl", "x":0, "y":5, "w":1.25}, {"label":"Win", "x":1.25, "y":5, "w":1.25}, {"label":"Alt", "x":2.5, "y":5, "w":1.25}, {"x":3.75, "y":5, "w":6.25}, {"label":"Alt", "x":10, "y":5}, {"label":"Fn", "x":11, "y":5}, {"label":"Ctrl", "x":12, "y":5}, {"label":"\u2190", "x":13, "y":5}, {"label":"\u2193", "x":14, "y":5}, {"label":"\u2192", "x":15, "y":5}] | ||
| 10 | } | ||
| 11 | } | ||
| 12 | } | ||
diff --git a/keyboards/duck/octagon/v1/matrix.c b/keyboards/duck/octagon/v1/matrix.c new file mode 100644 index 000000000..855534994 --- /dev/null +++ b/keyboards/duck/octagon/v1/matrix.c | |||
| @@ -0,0 +1,227 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2017 MechMerlin <mechmerlin@gmail.com> | ||
| 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 <util/delay.h> | ||
| 18 | #include <avr/io.h> | ||
| 19 | #include <stdio.h> | ||
| 20 | #include "matrix.h" | ||
| 21 | #include "util.h" | ||
| 22 | #include "print.h" | ||
| 23 | #include "debug.h" | ||
| 24 | |||
| 25 | static uint8_t debouncing = DEBOUNCING_DELAY; | ||
| 26 | |||
| 27 | /* matrix state(1:on, 0:off) */ | ||
| 28 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
| 29 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
| 30 | |||
| 31 | static uint8_t read_rows(uint8_t col); | ||
| 32 | static void init_rows(void); | ||
| 33 | static void unselect_cols(void); | ||
| 34 | static void select_col(uint8_t col); | ||
| 35 | |||
| 36 | |||
| 37 | __attribute__ ((weak)) | ||
| 38 | void matrix_init_kb(void) { | ||
| 39 | matrix_init_user(); | ||
| 40 | } | ||
| 41 | |||
| 42 | __attribute__ ((weak)) | ||
| 43 | void matrix_scan_kb(void) { | ||
| 44 | matrix_scan_user(); | ||
| 45 | } | ||
| 46 | |||
| 47 | __attribute__ ((weak)) | ||
| 48 | void matrix_init_user(void) { | ||
| 49 | } | ||
| 50 | |||
| 51 | __attribute__ ((weak)) | ||
| 52 | void matrix_scan_user(void) { | ||
| 53 | } | ||
| 54 | |||
| 55 | void backlight_init_ports(void) | ||
| 56 | { | ||
| 57 | DDRB |= 0b00011111; // PB0 (caps), PB1 (alpha), PB2 (extra), PB3 (modnum), PB4 (caps) | ||
| 58 | DDRD |= 0b11010000; // PD4, (rgb blue), PD6 (rgb red), PD7 (rgb green) | ||
| 59 | DDRE |= 0b01000000; // PE6 (frow) | ||
| 60 | } | ||
| 61 | |||
| 62 | void matrix_init(void) { | ||
| 63 | backlight_init_ports(); | ||
| 64 | unselect_cols(); | ||
| 65 | init_rows(); | ||
| 66 | |||
| 67 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
| 68 | matrix[i] = 0; | ||
| 69 | matrix_debouncing[i] = 0; | ||
| 70 | } | ||
| 71 | |||
| 72 | matrix_init_quantum(); | ||
| 73 | } | ||
| 74 | |||
| 75 | uint8_t matrix_scan(void) { | ||
| 76 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { | ||
| 77 | select_col(col); | ||
| 78 | _delay_us(3); | ||
| 79 | |||
| 80 | uint8_t rows = read_rows(col); | ||
| 81 | |||
| 82 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 83 | bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col); | ||
| 84 | bool curr_bit = rows & (1<<row); | ||
| 85 | if (prev_bit != curr_bit) { | ||
| 86 | matrix_debouncing[row] ^= ((matrix_row_t)1<<col); | ||
| 87 | debouncing = DEBOUNCING_DELAY; | ||
| 88 | } | ||
| 89 | } | ||
| 90 | unselect_cols(); | ||
| 91 | } | ||
| 92 | |||
| 93 | if (debouncing) { | ||
| 94 | if (--debouncing) { | ||
| 95 | _delay_ms(1); | ||
| 96 | } else { | ||
| 97 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 98 | matrix[i] = matrix_debouncing[i]; | ||
| 99 | } | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 103 | matrix_scan_quantum(); | ||
| 104 | return 1; | ||
| 105 | } | ||
| 106 | |||
| 107 | inline matrix_row_t matrix_get_row(uint8_t row) { | ||
| 108 | return matrix[row]; | ||
| 109 | } | ||
| 110 | |||
| 111 | void matrix_print(void) { | ||
| 112 | print("\nr/c 0123456789ABCDEF\n"); | ||
| 113 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 114 | xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row))); | ||
| 115 | } | ||
| 116 | } | ||
| 117 | |||
| 118 | /* Row pin configuration | ||
| 119 | * row: 0 1 2 3 4 5 | ||
| 120 | * pin: PB7 PD0 PD1 PD2 PD3 PD5 | ||
| 121 | * | ||
| 122 | * Esc uses its own pin PE2 | ||
| 123 | */ | ||
| 124 | static void init_rows(void) { | ||
| 125 | DDRD &= ~0b00101111; // PD0, PD1, PD2, PD3, PD5 input | ||
| 126 | PORTD &= ~0b00101111; // PD0, PD1, PD2, PD3, PD5 low | ||
| 127 | |||
| 128 | DDRB &= ~0b10000000; // PB7 input | ||
| 129 | PORTB &= ~0b10000000; // PB7 low | ||
| 130 | |||
| 131 | DDRE &= ~0b00000100; // PE2 input | ||
| 132 | PORTE |= 0b00000100; // PE2 high | ||
| 133 | } | ||
| 134 | |||
| 135 | static uint8_t read_rows(uint8_t col) { | ||
| 136 | if (col == 14) { | ||
| 137 | return PINE&(1<<2) ? 0 : (1<<0); // PE2 (Row 0) | ||
| 138 | } else { | ||
| 139 | return (PIND&(1<<0) ? (1<<0) : 0) | // PD0 (Row 0) | ||
| 140 | (PIND&(1<<1) ? (1<<1) : 0) | // PD1 (Row 1) | ||
| 141 | (PIND&(1<<2) ? (1<<2) : 0) | // PD2 (Row 2) | ||
| 142 | (PIND&(1<<3) ? (1<<3) : 0) | // PD3 (Row 3) | ||
| 143 | (PIND&(1<<5) ? (1<<4) : 0) | // PD5 (Row 4) | ||
| 144 | (PINB&(1<<7) ? (1<<5) : 0); // PB7 (Row 5) | ||
| 145 | } | ||
| 146 | } | ||
| 147 | |||
| 148 | uint8_t read_fwkey(void) | ||
| 149 | { | ||
| 150 | return PINE&(1<<2) ? 0 : (1<<0); | ||
| 151 | } | ||
| 152 | |||
| 153 | static void unselect_cols(void) { | ||
| 154 | DDRB |= 0b01000000; // PB6 (U2) output | ||
| 155 | PORTB &= ~0b01000000; // PB6 (U2) low | ||
| 156 | |||
| 157 | DDRC |= 0b11000000; // PC6 (U1), PC7 (A2) output | ||
| 158 | PORTC &= ~0b11000000; // PC6 (U1), PC7 (A2) low | ||
| 159 | |||
| 160 | DDRF |= 0b00000011; // PF0 (A0), PF1 (A1) output | ||
| 161 | PORTF &= ~0b00000011; // PF0 (A0), PF1 (A1) low | ||
| 162 | } | ||
| 163 | |||
| 164 | static void select_col(uint8_t col) { | ||
| 165 | |||
| 166 | switch (col) { | ||
| 167 | case 0: | ||
| 168 | PORTC |= 0b01000000; // PC6 high | ||
| 169 | break; | ||
| 170 | case 1: | ||
| 171 | PORTC |= 0b01000000; // PC6 high | ||
| 172 | PORTF |= 0b00000001; // PF0 high | ||
| 173 | break; | ||
| 174 | case 2: | ||
| 175 | PORTC |= 0b01000000; // PC6 high | ||
| 176 | PORTF |= 0b00000010; // PF1 high | ||
| 177 | break; | ||
| 178 | case 3: | ||
| 179 | PORTC |= 0b01000000; // PC6 high | ||
| 180 | PORTF |= 0b00000011; // PF0, PF1 high | ||
| 181 | break; | ||
| 182 | case 4: | ||
| 183 | PORTC |= 0b11000000; // PC6, PC7 high | ||
| 184 | break; | ||
| 185 | case 5: | ||
| 186 | PORTC |= 0b11000000; // PC6, PC7 high | ||
| 187 | PORTF |= 0b00000001; // PF0 high | ||
| 188 | break; | ||
| 189 | case 6: | ||
| 190 | PORTC |= 0b11000000; // PC6, PC7 high | ||
| 191 | PORTF |= 0b00000010; // PF1 high | ||
| 192 | break; | ||
| 193 | case 7: | ||
| 194 | PORTC |= 0b11000000; // PC6, PC7 high | ||
| 195 | PORTF |= 0b00000011; // PF0, PF1 high | ||
| 196 | break; | ||
| 197 | case 8: | ||
| 198 | PORTB |= 0b01000000; // PB6 high | ||
| 199 | break; | ||
| 200 | case 9: | ||
| 201 | PORTB |= 0b01000000; // PB6 high | ||
| 202 | PORTF |= 0b00000001; // PF0 high | ||
| 203 | break; | ||
| 204 | case 10: | ||
| 205 | PORTB |= 0b01000000; // PB6 high | ||
| 206 | PORTF |= 0b00000010; // PF1 high | ||
| 207 | break; | ||
| 208 | case 11: | ||
| 209 | PORTB |= 0b01000000; // PB6 high | ||
| 210 | PORTF |= 0b00000011; // PF0, PF1 high | ||
| 211 | break; | ||
| 212 | case 12: | ||
| 213 | PORTB |= 0b01000000; // PB6 high | ||
| 214 | PORTC |= 0b10000000; // PC7 high | ||
| 215 | break; | ||
| 216 | case 13: | ||
| 217 | PORTB |= 0b01000000; // PB6 high | ||
| 218 | PORTF |= 0b00000001; // PF0 high | ||
| 219 | PORTC |= 0b10000000; // PC7 high | ||
| 220 | break; | ||
| 221 | case 15: | ||
| 222 | PORTB |= 0b01000000; // PB6 high | ||
| 223 | PORTF |= 0b00000010; // PF1 high | ||
| 224 | PORTC |= 0b10000000; // PC7 high | ||
| 225 | break; | ||
| 226 | } | ||
| 227 | } | ||
diff --git a/keyboards/duck/octagon/v1/readme.md b/keyboards/duck/octagon/v1/readme.md new file mode 100644 index 000000000..f5cb2d789 --- /dev/null +++ b/keyboards/duck/octagon/v1/readme.md | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | # Duck Octagon V1 | ||
| 2 | |||
| 3 | Non official firmware for custom Korean keyboard with 75% key layout made by Duck. | ||
| 4 | Group buy was run October 2014 via [geekhack](https://geekhack.org/index.php?topic=65036.0) 35 keyboards total. | ||
| 5 | |||
| 6 | Keyboard Maintainer: [MechMerlin](https://github.com/mechmerlin) | ||
| 7 | Hardware Supported: Duck Octagon PCB Ver 1.0, Atmega32u4 | ||
| 8 | Hardware Availability: Wait until GB of the next revision | ||
| 9 | |||
| 10 | Make example for this keyboard (after setting up your build environment): | ||
| 11 | |||
| 12 | make duck/octagon/v1:default | ||
| 13 | |||
| 14 | See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information. | ||
| 15 | |||
| 16 | ## Hardware Notes | ||
| 17 | |||
| 18 | The Duck Octagon V1 PCB consists of: | ||
| 19 | |||
| 20 | ### Microchips | ||
| 21 | 2 74HC237D 3-to-8 line decoders | ||
| 22 | 1 Atmega32u4 microcontroller | ||
| 23 | 2 WS2811 LED controller | ||
| 24 | |||
| 25 | ## Notes | ||
| 26 | Thanks to Ralf Schmitt for previous implementations in his [TMK fork](https://github.com/xauser/tmk_keyboard/tree/xauser/) and few helping words. | ||
| 27 | |||
| 28 | Based heavily on Rasmus Schults [Duck Lightsaver QMK Port](https://github.com/qmk/qmk_firmware/tree/master/keyboards/lightsaver) | ||
diff --git a/keyboards/duck/octagon/v1/rules.mk b/keyboards/duck/octagon/v1/rules.mk new file mode 100644 index 000000000..a08695b50 --- /dev/null +++ b/keyboards/duck/octagon/v1/rules.mk | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | # MCU name | ||
| 2 | MCU = atmega32u4 | ||
| 3 | |||
| 4 | # Processor frequency. | ||
| 5 | # This will define a symbol, F_CPU, in all source code files equal to the | ||
| 6 | # processor frequency in Hz. You can then use this symbol in your source code to | ||
| 7 | # calculate timings. Do NOT tack on a 'UL' at the end, this will be done | ||
| 8 | # automatically to create a 32-bit value in your source code. | ||
| 9 | # | ||
| 10 | # This will be an integer division of F_USB below, as it is sourced by | ||
| 11 | # F_USB after it has run through any CPU prescalers. Note that this value | ||
| 12 | # does not *change* the processor frequency - it should merely be updated to | ||
| 13 | # reflect the processor speed set externally so that the code can use accurate | ||
| 14 | # software delays. | ||
| 15 | F_CPU = 16000000 | ||
| 16 | |||
| 17 | |||
| 18 | # | ||
| 19 | # LUFA specific | ||
| 20 | # | ||
| 21 | # Target architecture (see library "Board Types" documentation). | ||
| 22 | ARCH = AVR8 | ||
| 23 | |||
| 24 | # Input clock frequency. | ||
| 25 | # This will define a symbol, F_USB, in all source code files equal to the | ||
| 26 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
| 27 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
| 28 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
| 29 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
| 30 | # at the end, this will be done automatically to create a 32-bit value in your | ||
| 31 | # source code. | ||
| 32 | # | ||
| 33 | # If no clock division is performed on the input clock inside the AVR (via the | ||
| 34 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
| 35 | F_USB = $(F_CPU) | ||
| 36 | |||
| 37 | # Interrupt driven control endpoint task(+60) | ||
| 38 | #OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
| 39 | |||
| 40 | |||
| 41 | # Boot Section Size in *bytes* | ||
| 42 | # Teensy halfKay 512 | ||
| 43 | # Teensy++ halfKay 1024 | ||
| 44 | # Atmel DFU loader 4096 | ||
| 45 | # LUFA bootloader 4096 | ||
| 46 | # USBaspLoader 2048 | ||
| 47 | OPT_DEFS += -DBOOTLOADER_SIZE=4096 | ||
| 48 | |||
| 49 | |||
| 50 | # Build Options | ||
| 51 | # change yes to no to disable | ||
| 52 | # | ||
| 53 | BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000) | ||
| 54 | MOUSEKEY_ENABLE ?= no # Mouse keys(+4700) | ||
| 55 | EXTRAKEY_ENABLE ?= no # Audio control and System control(+450) | ||
| 56 | CONSOLE_ENABLE ?= no # Console for debug(+400) | ||
| 57 | COMMAND_ENABLE ?= yes # Commands for debug and configuration | ||
| 58 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | ||
| 59 | SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend | ||
| 60 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
| 61 | NKRO_ENABLE ?= yes # USB Nkey Rollover | ||
| 62 | BACKLIGHT_ENABLE ?= yes # Enable keyboard backlight functionality on B7 by default | ||
| 63 | MIDI_ENABLE ?= no # MIDI support (+2400 to 4200, depending on config) | ||
| 64 | UNICODE_ENABLE ?= no # Unicode | ||
| 65 | BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
| 66 | AUDIO_ENABLE ?= no # Audio output on port C6 | ||
| 67 | FAUXCLICKY_ENABLE ?= no # Use buzzer to emulate clicky switches | ||
| 68 | RGBLIGHT_ENABLE = yes | ||
| 69 | |||
| 70 | CUSTOM_MATRIX = yes | ||
| 71 | SRC += matrix.c \ | ||
| 72 | |||
diff --git a/keyboards/duck/octagon/v1/v1.c b/keyboards/duck/octagon/v1/v1.c new file mode 100644 index 000000000..258688229 --- /dev/null +++ b/keyboards/duck/octagon/v1/v1.c | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | /* Copyright 2017 MechMerlin <mechmerlin@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 | #include "v1.h" | ||
| 17 | |||
| 18 | enum BACKLIGHT_AREAS { | ||
| 19 | BACKLIGHT_ALPHA = 0b0000001, | ||
| 20 | BACKLIGHT_EXTRA = 0b0000010, | ||
| 21 | BACKLIGHT_MODNUM = 0b0000100, | ||
| 22 | BACKLIGHT_FROW = 0b0001000, | ||
| 23 | BACKLIGHT_RGB = 0b0010000, | ||
| 24 | BACKLIGHT_RGBRED = 0b0010000, | ||
| 25 | BACKLIGHT_RGBGREEN = 0b0100000, | ||
| 26 | BACKLIGHT_RGBBLUE = 0b1000000, | ||
| 27 | BACKLIGHT_SWITCH = 0b0001111 | ||
| 28 | }; | ||
| 29 | |||
| 30 | uint8_t backlight_os_state = 0; | ||
| 31 | uint32_t backlight_layer_state = 0; | ||
| 32 | |||
| 33 | void backlight_set(uint8_t level) { | ||
| 34 | level & BACKLIGHT_ALPHA ? (PORTB |= 0b00000010) : (PORTB &= ~0b00000010); | ||
| 35 | level & BACKLIGHT_EXTRA ? (PORTB |= 0b00000100) : (PORTB &= ~0b00000100); | ||
| 36 | level & BACKLIGHT_MODNUM ? (PORTB |= 0b00001000) : (PORTB &= ~0b00001000); | ||
| 37 | level & BACKLIGHT_FROW ? (PORTE |= 0b01000000) : (PORTE &= ~0b01000000); | ||
| 38 | level & BACKLIGHT_RGBRED ? (PORTD |= 0b01000000) : (PORTD &= ~0b01000000); | ||
| 39 | level & BACKLIGHT_RGBGREEN ? (PORTD |= 0b10000000) : (PORTD &= ~0b10000000); | ||
| 40 | level & BACKLIGHT_RGBBLUE ? (PORTD |= 0b00010000) : (PORTD &= ~0b00010000); | ||
| 41 | } | ||
| 42 | |||
| 43 | void led_set_kb(uint8_t usb_led) { | ||
| 44 | backlight_os_state & (1<<USB_LED_CAPS_LOCK) ? (PORTB &= ~0b00000001) : (PORTB |= 0b00000001); | ||
| 45 | backlight_os_state & (1<<USB_LED_SCROLL_LOCK) ? (PORTB &= ~0b00010000) : (PORTB |= 0b00010000); | ||
| 46 | } | ||
| 47 | |||
| 48 | bool process_record_kb(uint16_t keycode, keyrecord_t *record) { | ||
| 49 | return process_record_user(keycode, record); | ||
| 50 | } | ||
diff --git a/keyboards/duck/octagon/v1/v1.h b/keyboards/duck/octagon/v1/v1.h new file mode 100644 index 000000000..d89188f22 --- /dev/null +++ b/keyboards/duck/octagon/v1/v1.h | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | /* Copyright 2017 MechMerlin <mechmerlin@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 | #ifndef V1_H | ||
| 17 | #define V1_H | ||
| 18 | |||
| 19 | #include "quantum.h" | ||
| 20 | |||
| 21 | #define LAYOUT( \ | ||
| 22 | K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5P, \ | ||
| 23 | K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4N, K4P, \ | ||
| 24 | K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3P, \ | ||
| 25 | K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K5O, K2N, K2P, \ | ||
| 26 | K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1M, K1N, K1P, \ | ||
| 27 | K0A, K0B, K0C, K0G, K0J, K0K, K0L, K0M, K0N, K0P \ | ||
| 28 | ) { \ | ||
| 29 | { K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P }, \ | ||
| 30 | { K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4N, KC_NO, K4P }, \ | ||
| 31 | { K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, KC_NO, K3P }, \ | ||
| 32 | { K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, KC_NO, K2N, KC_NO, K2P }, \ | ||
| 33 | { K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, KC_NO, K1M, K1N, KC_NO, K1P }, \ | ||
| 34 | { K0A, K0B, K0C, KC_NO, KC_NO, K0G, KC_NO, KC_NO, K0J, K0K, K0L, KC_NO, K0M, K0N, KC_NO, K0P } \ | ||
| 35 | } | ||
| 36 | |||
| 37 | #define LAYOUT_75_ansi( \ | ||
| 38 | K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, \ | ||
| 39 | K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4N, K4P, \ | ||
| 40 | K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3P, \ | ||
| 41 | K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2N, K2P, \ | ||
| 42 | K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1M, K1N, K1P, \ | ||
| 43 | K0A, K0B, K0C, K0G, K0J, K0K, K0L, K0M, K0N, K0P \ | ||
| 44 | ) { \ | ||
| 45 | { K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P }, \ | ||
| 46 | { K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4N, KC_NO, K4P }, \ | ||
| 47 | { K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, KC_NO, K3P }, \ | ||
| 48 | { K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, KC_NO, K2N, KC_NO, K2P }, \ | ||
| 49 | { K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, KC_NO, K1M, K1N, KC_NO, K1P }, \ | ||
| 50 | { K0A, K0B, K0C, KC_NO, KC_NO, K0G, KC_NO, KC_NO, K0J, K0K, K0L, KC_NO, K0M, K0N, KC_NO, K0P } \ | ||
| 51 | } | ||
| 52 | #endif | ||
diff --git a/keyboards/duck/octagon/v2/config.h b/keyboards/duck/octagon/v2/config.h new file mode 100644 index 000000000..c916a30a1 --- /dev/null +++ b/keyboards/duck/octagon/v2/config.h | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2017 MechMerlin <mechmerlin@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 | #ifndef CONFIG_H | ||
| 19 | #define CONFIG_H | ||
| 20 | |||
| 21 | #include "config_common.h" | ||
| 22 | |||
| 23 | /* USB Device descriptor parameter */ | ||
| 24 | #define VENDOR_ID 0xFEED | ||
| 25 | #define PRODUCT_ID 0x6050 | ||
| 26 | #define DEVICE_VER 0x0104 | ||
| 27 | #define MANUFACTURER Duck | ||
| 28 | #define PRODUCT Octagon V2 | ||
| 29 | #define DESCRIPTION Duck Octagon V2 | ||
| 30 | |||
| 31 | /* key matrix size */ | ||
| 32 | #define MATRIX_ROWS 6 | ||
| 33 | #define MATRIX_COLS 17 | ||
| 34 | |||
| 35 | #define DIODE_DIRECTION COL2ROW | ||
| 36 | |||
| 37 | /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ | ||
| 38 | #define DEBOUNCING_DELAY 5 | ||
| 39 | |||
| 40 | /* number of backlight levels */ | ||
| 41 | #define BACKLIGHT_LEVELS 1 | ||
| 42 | |||
| 43 | /* key combination for magic key command */ | ||
| 44 | #define IS_COMMAND() ( \ | ||
| 45 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
| 46 | ) | ||
| 47 | |||
| 48 | #define RGBLIGHT_ANIMATIONS | ||
| 49 | #define RGB_DI_PIN D6 | ||
| 50 | #define RGBLED_NUM 17 | ||
| 51 | |||
| 52 | #define TAPPING_TERM 200 | ||
| 53 | |||
| 54 | #endif | ||
diff --git a/keyboards/duck/octagon/v2/indicator_leds.c b/keyboards/duck/octagon/v2/indicator_leds.c new file mode 100644 index 000000000..c24509f51 --- /dev/null +++ b/keyboards/duck/octagon/v2/indicator_leds.c | |||
| @@ -0,0 +1,133 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2017 MechMerlin <mechmerlin@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 <avr/interrupt.h> | ||
| 18 | #include <avr/io.h> | ||
| 19 | #include <stdbool.h> | ||
| 20 | #include <util/delay.h> | ||
| 21 | #include "indicator_leds.h" | ||
| 22 | |||
| 23 | #define T1H 900 | ||
| 24 | #define T1L 600 | ||
| 25 | #define T0H 400 | ||
| 26 | #define T0L 900 | ||
| 27 | #define RES 6000 | ||
| 28 | |||
| 29 | #define NS_PER_SEC (1000000000L) | ||
| 30 | #define CYCLES_PER_SEC (F_CPU) | ||
| 31 | #define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC) | ||
| 32 | #define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE) | ||
| 33 | |||
| 34 | void send_bit_d4(bool bitVal) { | ||
| 35 | if(bitVal) { | ||
| 36 | asm volatile ( | ||
| 37 | "sbi %[port], %[bit] \n\t" | ||
| 38 | ".rept %[onCycles] \n\t" | ||
| 39 | "nop \n\t" | ||
| 40 | ".endr \n\t" | ||
| 41 | "cbi %[port], %[bit] \n\t" | ||
| 42 | ".rept %[offCycles] \n\t" | ||
| 43 | "nop \n\t" | ||
| 44 | ".endr \n\t" | ||
| 45 | :: | ||
| 46 | [port] "I" (_SFR_IO_ADDR(PORTD)), | ||
| 47 | [bit] "I" (4), | ||
| 48 | [onCycles] "I" (NS_TO_CYCLES(T1H) - 2), | ||
| 49 | [offCycles] "I" (NS_TO_CYCLES(T1L) - 2)); | ||
| 50 | } else { | ||
| 51 | asm volatile ( | ||
| 52 | "sbi %[port], %[bit] \n\t" | ||
| 53 | ".rept %[onCycles] \n\t" | ||
| 54 | "nop \n\t" | ||
| 55 | ".endr \n\t" | ||
| 56 | "cbi %[port], %[bit] \n\t" | ||
| 57 | ".rept %[offCycles] \n\t" | ||
| 58 | "nop \n\t" | ||
| 59 | ".endr \n\t" | ||
| 60 | :: | ||
| 61 | [port] "I" (_SFR_IO_ADDR(PORTD)), | ||
| 62 | [bit] "I" (4), | ||
| 63 | [onCycles] "I" (NS_TO_CYCLES(T0H) - 2), | ||
| 64 | [offCycles] "I" (NS_TO_CYCLES(T0L) - 2)); | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 | void send_bit_d6(bool bitVal) | ||
| 69 | { | ||
| 70 | if(bitVal) { | ||
| 71 | asm volatile ( | ||
| 72 | "sbi %[port], %[bit] \n\t" | ||
| 73 | ".rept %[onCycles] \n\t" | ||
| 74 | "nop \n\t" | ||
| 75 | ".endr \n\t" | ||
| 76 | "cbi %[port], %[bit] \n\t" | ||
| 77 | ".rept %[offCycles] \n\t" | ||
| 78 | "nop \n\t" | ||
| 79 | ".endr \n\t" | ||
| 80 | :: | ||
| 81 | [port] "I" (_SFR_IO_ADDR(PORTD)), | ||
| 82 | [bit] "I" (6), | ||
| 83 | [onCycles] "I" (NS_TO_CYCLES(T1H) - 2), | ||
| 84 | [offCycles] "I" (NS_TO_CYCLES(T1L) - 2)); | ||
| 85 | } else { | ||
| 86 | asm volatile ( | ||
| 87 | "sbi %[port], %[bit] \n\t" | ||
| 88 | ".rept %[onCycles] \n\t" | ||
| 89 | "nop \n\t" | ||
| 90 | ".endr \n\t" | ||
| 91 | "cbi %[port], %[bit] \n\t" | ||
| 92 | ".rept %[offCycles] \n\t" | ||
| 93 | "nop \n\t" | ||
| 94 | ".endr \n\t" | ||
| 95 | :: | ||
| 96 | [port] "I" (_SFR_IO_ADDR(PORTD)), | ||
| 97 | [bit] "I" (6), | ||
| 98 | [onCycles] "I" (NS_TO_CYCLES(T0H) - 2), | ||
| 99 | [offCycles] "I" (NS_TO_CYCLES(T0L) - 2)); | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 103 | void show(void) { | ||
| 104 | _delay_us((RES / 1000UL) + 1); | ||
| 105 | } | ||
| 106 | |||
| 107 | void send_value(uint8_t byte, enum Device device) { | ||
| 108 | for(uint8_t b = 0; b < 8; b++) { | ||
| 109 | if(device == Device_STATUSLED) { | ||
| 110 | send_bit_d4(byte & 0b10000000); | ||
| 111 | } | ||
| 112 | if(device == Device_PCBRGB) { | ||
| 113 | send_bit_d6(byte & 0b10000000); | ||
| 114 | } | ||
| 115 | byte <<= 1; | ||
| 116 | } | ||
| 117 | } | ||
| 118 | |||
| 119 | void send_color(uint8_t r, uint8_t g, uint8_t b, enum Device device) { | ||
| 120 | send_value(g, device); | ||
| 121 | send_value(r, device); | ||
| 122 | send_value(b, device); | ||
| 123 | } | ||
| 124 | |||
| 125 | // Port from backlight_set_state | ||
| 126 | void indicator_leds_set(bool leds[8]) { | ||
| 127 | cli(); | ||
| 128 | send_color(leds[1] ? 255 : 0, leds[2] ? 255 : 0, leds[0] ? 255 : 0, Device_STATUSLED); | ||
| 129 | send_color(leds[4] ? 255 : 0, leds[3] ? 255 : 0, leds[5] ? 255 : 0, Device_STATUSLED); | ||
| 130 | leds[6] ? (PORTD &= ~0b10000000) : (PORTD |= 0b10000000); | ||
| 131 | sei(); | ||
| 132 | show(); | ||
| 133 | } | ||
diff --git a/keyboards/duck/octagon/v2/indicator_leds.h b/keyboards/duck/octagon/v2/indicator_leds.h new file mode 100644 index 000000000..9bb2c8ced --- /dev/null +++ b/keyboards/duck/octagon/v2/indicator_leds.h | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | enum Device { | ||
| 2 | Device_PCBRGB, | ||
| 3 | Device_STATUSLED | ||
| 4 | }; | ||
| 5 | |||
| 6 | void indicator_leds_set(bool leds[8]); | ||
| 7 | void backlight_toggle_rgb(bool enabled); | ||
| 8 | void backlight_set_rgb(uint8_t cfg[17][3]); | ||
| 9 | void backlight_init_ports(void); | ||
| 10 | void send_color(uint8_t r, uint8_t g, uint8_t b, enum Device device); | ||
| 11 | void show(void); \ No newline at end of file | ||
diff --git a/keyboards/duck/octagon/v2/info.json b/keyboards/duck/octagon/v2/info.json new file mode 100644 index 000000000..7bc0c6ef9 --- /dev/null +++ b/keyboards/duck/octagon/v2/info.json | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | { | ||
| 2 | "keyboard_name": "Octagon V2", | ||
| 3 | "url": "", | ||
| 4 | "maintainer": "qmk", | ||
| 5 | "width": 16, | ||
| 6 | "height": 6, | ||
| 7 | "layouts": { | ||
| 8 | "LAYOUT": { | ||
| 9 | "layout": [{"label":"Esc", "x":0, "y":0}, {"label":"F1", "x":1, "y":0}, {"label":"F2", "x":2, "y":0}, {"label":"F3", "x":3, "y":0}, {"label":"F4", "x":4, "y":0}, {"label":"F5", "x":5, "y":0}, {"label":"F6", "x":6, "y":0}, {"label":"F7", "x":7, "y":0}, {"label":"F8", "x":8, "y":0}, {"label":"F9", "x":9, "y":0}, {"label":"F10", "x":10, "y":0}, {"label":"F11", "x":11, "y":0}, {"label":"F12", "x":12, "y":0}, {"label":"PrtSc", "x":13, "y":0}, {"label":"Pause", "x":14, "y":0}, {"label":"Delete", "x":15, "y":0}, {"label":"~", "x":0, "y":1}, {"label":"!", "x":1, "y":1}, {"label":"@", "x":2, "y":1}, {"label":"#", "x":3, "y":1}, {"label":"$", "x":4, "y":1}, {"label":"%", "x":5, "y":1}, {"label":"^", "x":6, "y":1}, {"label":"&", "x":7, "y":1}, {"label":"*", "x":8, "y":1}, {"label":"(", "x":9, "y":1}, {"label":")", "x":10, "y":1}, {"label":"_", "x":11, "y":1}, {"label":"+", "x":12, "y":1}, {"label":"Backspace", "x":13, "y":1, "w":2}, {"label":"Home", "x":15, "y":1}, {"label":"Tab", "x":0, "y":2, "w":1.5}, {"label":"Q", "x":1.5, "y":2}, {"label":"W", "x":2.5, "y":2}, {"label":"E", "x":3.5, "y":2}, {"label":"R", "x":4.5, "y":2}, {"label":"T", "x":5.5, "y":2}, {"label":"Y", "x":6.5, "y":2}, {"label":"U", "x":7.5, "y":2}, {"label":"I", "x":8.5, "y":2}, {"label":"O", "x":9.5, "y":2}, {"label":"P", "x":10.5, "y":2}, {"label":"{", "x":11.5, "y":2}, {"label":"}", "x":12.5, "y":2}, {"label":"|", "x":13.5, "y":2, "w":1.5}, {"label":"Page Up", "x":15, "y":2}, {"label":"Caps Lock", "x":0, "y":3, "w":1.75}, {"label":"A", "x":1.75, "y":3}, {"label":"S", "x":2.75, "y":3}, {"label":"D", "x":3.75, "y":3}, {"label":"F", "x":4.75, "y":3}, {"label":"G", "x":5.75, "y":3}, {"label":"H", "x":6.75, "y":3}, {"label":"J", "x":7.75, "y":3}, {"label":"K", "x":8.75, "y":3}, {"label":"L", "x":9.75, "y":3}, {"label":":", "x":10.75, "y":3}, {"label":"\"", "x":11.75, "y":3}, {"x":12.75, "y":3}, {"label":"Enter", "x":13.75, "y":3, "w":1.25}, {"label":"Page Down", "x":15, "y":3}, {"label":"Shift", "x":0, "y":4, "w":1.25}, {"x":1.25, "y":4}, {"label":"Z", "x":2.25, "y":4}, {"label":"X", "x":3.25, "y":4}, {"label":"C", "x":4.25, "y":4}, {"label":"V", "x":5.25, "y":4}, {"label":"B", "x":6.25, "y":4}, {"label":"N", "x":7.25, "y":4}, {"label":"M", "x":8.25, "y":4}, {"label":"<", "x":9.25, "y":4}, {"label":">", "x":10.25, "y":4}, {"label":"?", "x":11.25, "y":4}, {"label":"Shift", "x":12.25, "y":4, "w":1.75}, {"label":"\u2191", "x":14, "y":4}, {"label":"End", "x":15, "y":4}, {"label":"Ctrl", "x":0, "y":5, "w":1.25}, {"label":"Win", "x":1.25, "y":5, "w":1.25}, {"label":"Alt", "x":2.5, "y":5, "w":1.25}, {"x":3.75, "y":5, "w":6.25}, {"label":"Alt", "x":10, "y":5}, {"label":"Fn", "x":11, "y":5}, {"label":"Ctrl", "x":12, "y":5}, {"label":"\u2190", "x":13, "y":5}, {"label":"\u2193", "x":14, "y":5}, {"label":"\u2192", "x":15, "y":5}] | ||
| 10 | } | ||
| 11 | } | ||
| 12 | } | ||
diff --git a/keyboards/duck/octagon/v2/matrix.c b/keyboards/duck/octagon/v2/matrix.c new file mode 100644 index 000000000..a63a37640 --- /dev/null +++ b/keyboards/duck/octagon/v2/matrix.c | |||
| @@ -0,0 +1,258 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2017 MechMerlin <mechmerlin@gmail.com> | ||
| 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 <util/delay.h> | ||
| 18 | #include <avr/io.h> | ||
| 19 | #include <stdio.h> | ||
| 20 | #include "matrix.h" | ||
| 21 | #include "util.h" | ||
| 22 | #include "print.h" | ||
| 23 | #include "debug.h" | ||
| 24 | |||
| 25 | static uint8_t debouncing = DEBOUNCING_DELAY; | ||
| 26 | |||
| 27 | /* matrix state(1:on, 0:off) */ | ||
| 28 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
| 29 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
| 30 | |||
| 31 | static uint8_t read_rows(uint8_t col); | ||
| 32 | static void init_rows(void); | ||
| 33 | static void unselect_cols(void); | ||
| 34 | static void select_col(uint8_t col); | ||
| 35 | |||
| 36 | |||
| 37 | __attribute__ ((weak)) | ||
| 38 | void matrix_init_kb(void) { | ||
| 39 | matrix_init_user(); | ||
| 40 | } | ||
| 41 | |||
| 42 | __attribute__ ((weak)) | ||
| 43 | void matrix_scan_kb(void) { | ||
| 44 | matrix_scan_user(); | ||
| 45 | } | ||
| 46 | |||
| 47 | __attribute__ ((weak)) | ||
| 48 | void matrix_init_user(void) { | ||
| 49 | } | ||
| 50 | |||
| 51 | __attribute__ ((weak)) | ||
| 52 | void matrix_scan_user(void) { | ||
| 53 | } | ||
| 54 | |||
| 55 | void backlight_init_ports(void) | ||
| 56 | { | ||
| 57 | DDRD |= 0b11010000; | ||
| 58 | PORTD &= ~0b01010000; | ||
| 59 | PORTD |= 0b10000000; | ||
| 60 | DDRB |= 0b00011111; | ||
| 61 | PORTB &= ~0b00001110; | ||
| 62 | PORTB |= 0b00010001; | ||
| 63 | DDRE |= 0b01000000; | ||
| 64 | PORTE &= ~0b01000000; | ||
| 65 | } | ||
| 66 | |||
| 67 | void matrix_init(void) { | ||
| 68 | backlight_init_ports(); | ||
| 69 | unselect_cols(); | ||
| 70 | init_rows(); | ||
| 71 | |||
| 72 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
| 73 | matrix[i] = 0; | ||
| 74 | matrix_debouncing[i] = 0; | ||
| 75 | } | ||
| 76 | |||
| 77 | matrix_init_quantum(); | ||
| 78 | } | ||
| 79 | |||
| 80 | uint8_t matrix_scan(void) { | ||
| 81 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { | ||
| 82 | select_col(col); | ||
| 83 | _delay_us(3); | ||
| 84 | |||
| 85 | uint8_t rows = read_rows(col); | ||
| 86 | |||
| 87 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 88 | bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col); | ||
| 89 | bool curr_bit = rows & (1<<row); | ||
| 90 | if (prev_bit != curr_bit) { | ||
| 91 | matrix_debouncing[row] ^= ((matrix_row_t)1<<col); | ||
| 92 | debouncing = DEBOUNCING_DELAY; | ||
| 93 | } | ||
| 94 | } | ||
| 95 | unselect_cols(); | ||
| 96 | } | ||
| 97 | |||
| 98 | if (debouncing) { | ||
| 99 | if (--debouncing) { | ||
| 100 | _delay_ms(1); | ||
| 101 | } else { | ||
| 102 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 103 | matrix[i] = matrix_debouncing[i]; | ||
| 104 | } | ||
| 105 | } | ||
| 106 | } | ||
| 107 | |||
| 108 | matrix_scan_quantum(); | ||
| 109 | return 1; | ||
| 110 | } | ||
| 111 | |||
| 112 | inline matrix_row_t matrix_get_row(uint8_t row) { | ||
| 113 | return matrix[row]; | ||
| 114 | } | ||
| 115 | |||
| 116 | void matrix_print(void) { | ||
| 117 | print("\nr/c 0123456789ABCDEF\n"); | ||
| 118 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 119 | xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row))); | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 123 | /* Row pin configuration | ||
| 124 | * row: 0 1 2 3 4 5 | ||
| 125 | * pin: PB7 PD0 PD1 PD2 PD3 PD5 | ||
| 126 | * | ||
| 127 | * Esc uses its own pin PE2 | ||
| 128 | */ | ||
| 129 | static void init_rows(void) { | ||
| 130 | DDRD &= ~0b00101111; | ||
| 131 | PORTD &= ~0b00101111; | ||
| 132 | |||
| 133 | DDRB &= ~0b10000000; | ||
| 134 | PORTB &= ~0b10000000; | ||
| 135 | |||
| 136 | DDRE &= ~0b00000100; | ||
| 137 | PORTE |= 0b00000100; | ||
| 138 | } | ||
| 139 | |||
| 140 | static uint8_t read_rows(uint8_t col) { | ||
| 141 | if (col == 16) { | ||
| 142 | return PINE&(1<<2) ? 0 : (1<<0); | ||
| 143 | } else { | ||
| 144 | return (PIND&(1<<0) ? (1<<0) : 0) | | ||
| 145 | (PIND&(1<<1) ? (1<<1) : 0) | | ||
| 146 | (PIND&(1<<2) ? (1<<2) : 0) | | ||
| 147 | (PIND&(1<<3) ? (1<<3) : 0) | | ||
| 148 | (PIND&(1<<5) ? (1<<4) : 0) | | ||
| 149 | (PINB&(1<<7) ? (1<<5) : 0); | ||
| 150 | } | ||
| 151 | } | ||
| 152 | |||
| 153 | uint8_t read_fwkey(void) | ||
| 154 | { | ||
| 155 | return PINE&(1<<2) ? 0 : (1<<0); | ||
| 156 | } | ||
| 157 | |||
| 158 | /* Columns 0 - 15 | ||
| 159 | * These columns uses two 74HC237D 3 to 8 bit demultiplexers. | ||
| 160 | * col / pin: PC6 PB6 PF0 PF1 PC7 | ||
| 161 | * 0: 1 0 0 0 0 | ||
| 162 | * 1: 1 0 1 0 0 | ||
| 163 | * 2: 1 0 0 1 0 | ||
| 164 | * 3: 1 0 1 1 0 | ||
| 165 | * 4: 1 0 0 0 1 | ||
| 166 | * 5: 1 0 1 0 1 | ||
| 167 | * 6: 1 0 0 1 1 | ||
| 168 | * 7: 1 0 1 1 1 | ||
| 169 | * 8: 0 1 0 0 0 | ||
| 170 | * 9: 0 1 1 0 0 | ||
| 171 | * 10: 0 1 0 1 0 | ||
| 172 | * 11: 0 1 1 1 0 | ||
| 173 | * 12: 0 1 0 0 1 | ||
| 174 | * 13: 0 1 1 0 1 | ||
| 175 | * 14: 0 1 0 1 1 | ||
| 176 | * 15: 0 1 1 1 1 | ||
| 177 | * | ||
| 178 | */ | ||
| 179 | static void unselect_cols(void) { | ||
| 180 | DDRB |= 0b01000000; | ||
| 181 | PORTB &= ~0b01000000; | ||
| 182 | |||
| 183 | DDRC |= 0b11000000; | ||
| 184 | PORTC &= ~0b11000000; | ||
| 185 | |||
| 186 | DDRF |= 0b00000011; | ||
| 187 | PORTF &= ~0b00000011; | ||
| 188 | } | ||
| 189 | |||
| 190 | static void select_col(uint8_t col) { | ||
| 191 | |||
| 192 | switch (col) { | ||
| 193 | case 0: | ||
| 194 | PORTC |= 0b01000000; | ||
| 195 | break; | ||
| 196 | case 1: | ||
| 197 | PORTC |= 0b01000000; | ||
| 198 | PORTF |= 0b00000001; | ||
| 199 | break; | ||
| 200 | case 2: | ||
| 201 | PORTC |= 0b01000000; | ||
| 202 | PORTF |= 0b00000010; | ||
| 203 | break; | ||
| 204 | case 3: | ||
| 205 | PORTC |= 0b01000000; | ||
| 206 | PORTF |= 0b00000011; | ||
| 207 | break; | ||
| 208 | case 4: | ||
| 209 | PORTC |= 0b11000000; | ||
| 210 | break; | ||
| 211 | case 5: | ||
| 212 | PORTC |= 0b11000000; | ||
| 213 | PORTF |= 0b00000001; | ||
| 214 | break; | ||
| 215 | case 6: | ||
| 216 | PORTC |= 0b11000000; | ||
| 217 | PORTF |= 0b00000010; | ||
| 218 | break; | ||
| 219 | case 7: | ||
| 220 | PORTC |= 0b11000000; | ||
| 221 | PORTF |= 0b00000011; | ||
| 222 | break; | ||
| 223 | case 8: | ||
| 224 | PORTB |= 0b01000000; | ||
| 225 | break; | ||
| 226 | case 9: | ||
| 227 | PORTB |= 0b01000000; | ||
| 228 | PORTF |= 0b00000001; | ||
| 229 | break; | ||
| 230 | case 10: | ||
| 231 | PORTB |= 0b01000000; | ||
| 232 | PORTF |= 0b00000010; | ||
| 233 | break; | ||
| 234 | case 11: | ||
| 235 | PORTB |= 0b01000000; | ||
| 236 | PORTF |= 0b00000011; | ||
| 237 | break; | ||
| 238 | case 12: | ||
| 239 | PORTB |= 0b01000000; | ||
| 240 | PORTC |= 0b10000000; | ||
| 241 | break; | ||
| 242 | case 13: | ||
| 243 | PORTB |= 0b01000000; | ||
| 244 | PORTF |= 0b00000001; | ||
| 245 | PORTC |= 0b10000000; | ||
| 246 | break; | ||
| 247 | case 14: | ||
| 248 | PORTB |= 0b01000000; | ||
| 249 | PORTF |= 0b00000010; | ||
| 250 | PORTC |= 0b10000000; | ||
| 251 | break; | ||
| 252 | case 15: | ||
| 253 | PORTB |= 0b01000000; | ||
| 254 | PORTF |= 0b00000011; | ||
| 255 | PORTC |= 0b10000000; | ||
| 256 | break; | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/keyboards/duck/octagon/v2/readme.md b/keyboards/duck/octagon/v2/readme.md new file mode 100644 index 000000000..125f09f9c --- /dev/null +++ b/keyboards/duck/octagon/v2/readme.md | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | # Duck Octagon V2 | ||
| 2 | |||
| 3 | Non official firmware for custom Korean keyboard with 75% key layout made by Duck. | ||
| 4 | Group buy was run January 2016 via [geekhack](https://geekhack.org/index.php?topic=78549.0) with 2 rounds, 100 keyboards total. | ||
| 5 | |||
| 6 | Keyboard Maintainer: [MechMerlin](https://github.com/mechmerlin) | ||
| 7 | Hardware Supported: Duck Octagon PCB Ver 2.0, Atmega32u4 | ||
| 8 | Hardware Availability: Wait until GB of the next revision | ||
| 9 | |||
| 10 | Make example for this keyboard (after setting up your build environment): | ||
| 11 | |||
| 12 | make octagon/v2:default | ||
| 13 | |||
| 14 | See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information. | ||
| 15 | |||
| 16 | ## Hardware Notes | ||
| 17 | |||
| 18 | The Duck Octagon V2 PCB consists of: | ||
| 19 | |||
| 20 | ### Microchips | ||
| 21 | 2 74HC237D 3-to-8 line decoders | ||
| 22 | 1 Atmega32u4 microcontroller | ||
| 23 | 2 WS2811 LED controller | ||
| 24 | |||
| 25 | ## Notes | ||
| 26 | Thanks to Ralf Schmitt for previous implementations in his [TMK fork](https://github.com/xauser/tmk_keyboard/tree/xauser/) and few helping words. | ||
| 27 | |||
| 28 | Based heavily on Rasmus Schults [Duck Lightsaver QMK Port](https://github.com/qmk/qmk_firmware/tree/master/keyboards/lightsaver) | ||
diff --git a/keyboards/duck/octagon/v2/rules.mk b/keyboards/duck/octagon/v2/rules.mk new file mode 100644 index 000000000..37f3938d9 --- /dev/null +++ b/keyboards/duck/octagon/v2/rules.mk | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | # MCU name | ||
| 2 | MCU = atmega32u4 | ||
| 3 | |||
| 4 | # Processor frequency. | ||
| 5 | # This will define a symbol, F_CPU, in all source code files equal to the | ||
| 6 | # processor frequency in Hz. You can then use this symbol in your source code to | ||
| 7 | # calculate timings. Do NOT tack on a 'UL' at the end, this will be done | ||
| 8 | # automatically to create a 32-bit value in your source code. | ||
| 9 | # | ||
| 10 | # This will be an integer division of F_USB below, as it is sourced by | ||
| 11 | # F_USB after it has run through any CPU prescalers. Note that this value | ||
| 12 | # does not *change* the processor frequency - it should merely be updated to | ||
| 13 | # reflect the processor speed set externally so that the code can use accurate | ||
| 14 | # software delays. | ||
| 15 | F_CPU = 16000000 | ||
| 16 | |||
| 17 | |||
| 18 | # | ||
| 19 | # LUFA specific | ||
| 20 | # | ||
| 21 | # Target architecture (see library "Board Types" documentation). | ||
| 22 | ARCH = AVR8 | ||
| 23 | |||
| 24 | # Input clock frequency. | ||
| 25 | # This will define a symbol, F_USB, in all source code files equal to the | ||
| 26 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
| 27 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
| 28 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
| 29 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
| 30 | # at the end, this will be done automatically to create a 32-bit value in your | ||
| 31 | # source code. | ||
| 32 | # | ||
| 33 | # If no clock division is performed on the input clock inside the AVR (via the | ||
| 34 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
| 35 | F_USB = $(F_CPU) | ||
| 36 | |||
| 37 | # Interrupt driven control endpoint task(+60) | ||
| 38 | #OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
| 39 | |||
| 40 | |||
| 41 | # Boot Section Size in *bytes* | ||
| 42 | # Teensy halfKay 512 | ||
| 43 | # Teensy++ halfKay 1024 | ||
| 44 | # Atmel DFU loader 4096 | ||
| 45 | # LUFA bootloader 4096 | ||
| 46 | # USBaspLoader 2048 | ||
| 47 | OPT_DEFS += -DBOOTLOADER_SIZE=4096 | ||
| 48 | |||
| 49 | |||
| 50 | # Build Options | ||
| 51 | # change yes to no to disable | ||
| 52 | # | ||
| 53 | BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000) | ||
| 54 | MOUSEKEY_ENABLE ?= no # Mouse keys(+4700) | ||
| 55 | EXTRAKEY_ENABLE ?= no # Audio control and System control(+450) | ||
| 56 | CONSOLE_ENABLE ?= no # Console for debug(+400) | ||
| 57 | COMMAND_ENABLE ?= yes # Commands for debug and configuration | ||
| 58 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | ||
| 59 | SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend | ||
| 60 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
| 61 | NKRO_ENABLE ?= yes # USB Nkey Rollover | ||
| 62 | BACKLIGHT_ENABLE ?= yes # Enable keyboard backlight functionality on B7 by default | ||
| 63 | MIDI_ENABLE ?= no # MIDI support (+2400 to 4200, depending on config) | ||
| 64 | UNICODE_ENABLE ?= no # Unicode | ||
| 65 | BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
| 66 | AUDIO_ENABLE ?= no # Audio output on port C6 | ||
| 67 | FAUXCLICKY_ENABLE ?= no # Use buzzer to emulate clicky switches | ||
| 68 | RGBLIGHT_ENABLE = yes | ||
| 69 | |||
| 70 | CUSTOM_MATRIX = yes | ||
| 71 | SRC += indicator_leds.c \ | ||
| 72 | matrix.c | ||
| 73 | |||
| 74 | LAYOUTS = 75_ansi | ||
diff --git a/keyboards/duck/octagon/v2/v2.c b/keyboards/duck/octagon/v2/v2.c new file mode 100644 index 000000000..52653b37e --- /dev/null +++ b/keyboards/duck/octagon/v2/v2.c | |||
| @@ -0,0 +1,117 @@ | |||
| 1 | /* Copyright 2017 MechMerlin <mechmerlin@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 | #include "v2.h" | ||
| 17 | #include "indicator_leds.h" | ||
| 18 | |||
| 19 | enum BACKLIGHT_AREAS { | ||
| 20 | BACKLIGHT_ALPHA = 0b0000001, | ||
| 21 | BACKLIGHT_EXTRA = 0b0000010, | ||
| 22 | BACKLIGHT_MODNUM = 0b0000100, | ||
| 23 | BACKLIGHT_FROW = 0b0001000, | ||
| 24 | BACKLIGHT_RGB = 0b0010000, | ||
| 25 | BACKLIGHT_SWITCH = 0b0001111 | ||
| 26 | }; | ||
| 27 | |||
| 28 | uint8_t backlight_rgb_r = 255; | ||
| 29 | uint8_t backlight_rgb_g = 0; | ||
| 30 | uint8_t backlight_rgb_b = 0; | ||
| 31 | uint8_t backlight_os_state = 0; | ||
| 32 | uint32_t backlight_layer_state = 0; | ||
| 33 | |||
| 34 | void backlight_toggle_rgb(bool enabled) | ||
| 35 | { | ||
| 36 | if(enabled) { | ||
| 37 | uint8_t rgb[17][3] = { | ||
| 38 | {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
| 39 | {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
| 40 | {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
| 41 | {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
| 42 | {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
| 43 | {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
| 44 | {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
| 45 | {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
| 46 | {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
| 47 | {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
| 48 | {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
| 49 | {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
| 50 | {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
| 51 | {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
| 52 | {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
| 53 | {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
| 54 | {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b} | ||
| 55 | }; | ||
| 56 | backlight_set_rgb(rgb); | ||
| 57 | } else { | ||
| 58 | uint8_t rgb[17][3] = { | ||
| 59 | {0, 0, 0}, | ||
| 60 | {0, 0, 0}, | ||
| 61 | {0, 0, 0}, | ||
| 62 | {0, 0, 0}, | ||
| 63 | {0, 0, 0}, | ||
| 64 | {0, 0, 0}, | ||
| 65 | {0, 0, 0}, | ||
| 66 | {0, 0, 0}, | ||
| 67 | {0, 0, 0}, | ||
| 68 | {0, 0, 0}, | ||
| 69 | {0, 0, 0}, | ||
| 70 | {0, 0, 0}, | ||
| 71 | {0, 0, 0}, | ||
| 72 | {0, 0, 0}, | ||
| 73 | {0, 0, 0}, | ||
| 74 | {0, 0, 0}, | ||
| 75 | {0, 0, 0} | ||
| 76 | }; | ||
| 77 | backlight_set_rgb(rgb); | ||
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | void backlight_set_rgb(uint8_t cfg[17][3]) | ||
| 82 | { | ||
| 83 | cli(); | ||
| 84 | for(uint8_t i = 0; i < 17; ++i) { | ||
| 85 | send_color(cfg[i][0], cfg[i][1], cfg[i][2], Device_PCBRGB); | ||
| 86 | } | ||
| 87 | sei(); | ||
| 88 | show(); | ||
| 89 | } | ||
| 90 | |||
| 91 | void backlight_set(uint8_t level) { | ||
| 92 | level & BACKLIGHT_ALPHA ? (PORTB |= 0b00000010) : (PORTB &= ~0b00000010); | ||
| 93 | level & BACKLIGHT_EXTRA ? (PORTB |= 0b00000100) : (PORTB &= ~0b00000100); | ||
| 94 | level & BACKLIGHT_MODNUM ? (PORTB |= 0b00001000) : (PORTB &= ~0b00001000); | ||
| 95 | level & BACKLIGHT_FROW ? (PORTE |= 0b01000000) : (PORTE &= ~0b01000000); | ||
| 96 | level & BACKLIGHT_RGB ? backlight_toggle_rgb(true) : backlight_toggle_rgb(false); | ||
| 97 | } | ||
| 98 | |||
| 99 | // Port from backlight_update_state | ||
| 100 | void led_set_kb(uint8_t usb_led) { | ||
| 101 | bool status[7] = { | ||
| 102 | backlight_os_state & (1<<USB_LED_CAPS_LOCK), | ||
| 103 | backlight_os_state & (1<<USB_LED_SCROLL_LOCK), | ||
| 104 | backlight_os_state & (1<<USB_LED_NUM_LOCK), | ||
| 105 | backlight_layer_state & (1<<1), | ||
| 106 | backlight_layer_state & (1<<2), | ||
| 107 | backlight_layer_state & (1<<3), | ||
| 108 | backlight_layer_state & (1<<4) | ||
| 109 | }; | ||
| 110 | indicator_leds_set(status); | ||
| 111 | backlight_os_state & (1<<USB_LED_CAPS_LOCK) ? (PORTB &= ~0b00000001) : (PORTB |= 0b00000001); | ||
| 112 | backlight_os_state & (1<<USB_LED_SCROLL_LOCK) ? (PORTB &= ~0b00010000) : (PORTB |= 0b00010000); | ||
| 113 | } | ||
| 114 | |||
| 115 | bool process_record_kb(uint16_t keycode, keyrecord_t *record) { | ||
| 116 | return process_record_user(keycode, record); | ||
| 117 | } | ||
diff --git a/keyboards/duck/octagon/v2/v2.h b/keyboards/duck/octagon/v2/v2.h new file mode 100644 index 000000000..1487b3640 --- /dev/null +++ b/keyboards/duck/octagon/v2/v2.h | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | /* Copyright 2017 MechMerlin <mechmerlin@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 | #ifndef V2_H | ||
| 17 | #define V2_H | ||
| 18 | |||
| 19 | #include "quantum.h" | ||
| 20 | |||
| 21 | #define LAYOUT( \ | ||
| 22 | K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5Q, \ | ||
| 23 | K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4O, K4P, \ | ||
| 24 | K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3O, K3P, \ | ||
| 25 | K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, K2O, K2P, \ | ||
| 26 | K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1M, K1N, K1O, K1P, \ | ||
| 27 | K0A, K0B, K0C, K0J, K0K, K0L, K0M, K0N, K0O, K0P \ | ||
| 28 | ) { \ | ||
| 29 | { K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, KC_NO, K5Q }, \ | ||
| 30 | { K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, KC_NO, K4O, K4P, KC_NO }, \ | ||
| 31 | { K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, KC_NO, K3O, K3P, KC_NO }, \ | ||
| 32 | { K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, KC_NO, K2O, K2P, KC_NO }, \ | ||
| 33 | { K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, KC_NO, K1M, K1N, K1O, K1P, KC_NO }, \ | ||
| 34 | { K0A, K0B, K0C, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K0J, KC_NO, K0K, K0L, K0M, K0N, K0O, K0P, KC_NO } \ | ||
| 35 | } | ||
| 36 | |||
| 37 | #define LAYOUT_75_ansi( \ | ||
| 38 | K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5Q, \ | ||
| 39 | K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4O, K4P, \ | ||
| 40 | K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3O, K3P, \ | ||
| 41 | K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2O, K2P, \ | ||
| 42 | K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1M, K1N, K1O, K1P, \ | ||
| 43 | K0A, K0B, K0C, K0J, K0K, K0L, K0M, K0N, K0O, K0P \ | ||
| 44 | ) { \ | ||
| 45 | { K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, KC_NO, K5Q }, \ | ||
| 46 | { K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, KC_NO, K4O, K4P, KC_NO }, \ | ||
| 47 | { K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, KC_NO, K3O, K3P, KC_NO }, \ | ||
| 48 | { K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, KC_NO, KC_NO, K2O, K2P, KC_NO }, \ | ||
| 49 | { K1A, KC_NO, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, KC_NO, K1M, K1N, K1O, K1P, KC_NO }, \ | ||
| 50 | { K0A, K0B, K0C, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K0J, KC_NO, K0K, K0L, K0M, K0N, K0O, K0P, KC_NO } \ | ||
| 51 | } | ||
| 52 | #endif | ||
