diff options
| -rw-r--r-- | keyboards/octagon_v2/config.h | 54 | ||||
| -rw-r--r-- | keyboards/octagon_v2/indicator_leds.c | 133 | ||||
| -rw-r--r-- | keyboards/octagon_v2/indicator_leds.h | 11 | ||||
| -rw-r--r-- | keyboards/octagon_v2/keymaps/default/keymap.c | 39 | ||||
| -rw-r--r-- | keyboards/octagon_v2/keymaps/default/readme.md | 8 | ||||
| -rw-r--r-- | keyboards/octagon_v2/matrix.c | 267 | ||||
| -rw-r--r-- | keyboards/octagon_v2/octagon_v2.c | 117 | ||||
| -rw-r--r-- | keyboards/octagon_v2/octagon_v2.h | 36 | ||||
| -rw-r--r-- | keyboards/octagon_v2/readme.md | 28 | ||||
| -rw-r--r-- | keyboards/octagon_v2/rules.mk | 72 |
10 files changed, 765 insertions, 0 deletions
diff --git a/keyboards/octagon_v2/config.h b/keyboards/octagon_v2/config.h new file mode 100644 index 000000000..c916a30a1 --- /dev/null +++ b/keyboards/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/octagon_v2/indicator_leds.c b/keyboards/octagon_v2/indicator_leds.c new file mode 100644 index 000000000..c24509f51 --- /dev/null +++ b/keyboards/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/octagon_v2/indicator_leds.h b/keyboards/octagon_v2/indicator_leds.h new file mode 100644 index 000000000..9bb2c8ced --- /dev/null +++ b/keyboards/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/octagon_v2/keymaps/default/keymap.c b/keyboards/octagon_v2/keymaps/default/keymap.c new file mode 100644 index 000000000..123da6069 --- /dev/null +++ b/keyboards/octagon_v2/keymaps/default/keymap.c | |||
| @@ -0,0 +1,39 @@ | |||
| 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 "octagon_v2.h" | ||
| 17 | |||
| 18 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 19 | /* layer 0: qwerty */ | ||
| 20 | [0] = KEYMAP(\ | ||
| 21 | 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, | ||
| 22 | 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, | ||
| 23 | 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, | ||
| 24 | 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_NO, KC_ENT, KC_PGDN, | ||
| 25 | KC_LSFT, KC_NO, 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, | ||
| 26 | KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(1), KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT), | ||
| 27 | |||
| 28 | [1] = KEYMAP(\ | ||
| 29 | 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, | ||
| 30 | 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, | ||
| 31 | 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, | ||
| 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_NO, KC_TRNS, KC_TRNS, | ||
| 33 | KC_TRNS, KC_NO, 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, | ||
| 34 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS) | ||
| 35 | }; | ||
| 36 | |||
| 37 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { | ||
| 38 | return MACRO_NONE; | ||
| 39 | }; | ||
diff --git a/keyboards/octagon_v2/keymaps/default/readme.md b/keyboards/octagon_v2/keymaps/default/readme.md new file mode 100644 index 000000000..456fc3ecb --- /dev/null +++ b/keyboards/octagon_v2/keymaps/default/readme.md | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | # Default Octagon Layout | ||
| 2 | |||
| 3 | This is the default implement layout for Duck Octagon V2. | ||
| 4 | |||
| 5 | |||
| 6 | ## Features | ||
| 7 | |||
| 8 | * Default QWERTY layer | ||
diff --git a/keyboards/octagon_v2/matrix.c b/keyboards/octagon_v2/matrix.c new file mode 100644 index 000000000..e113e5077 --- /dev/null +++ b/keyboards/octagon_v2/matrix.c | |||
| @@ -0,0 +1,267 @@ | |||
| 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 | __attribute__ ((weak)) | ||
| 37 | void matrix_init_quantum(void) { | ||
| 38 | matrix_init_kb(); | ||
| 39 | } | ||
| 40 | |||
| 41 | __attribute__ ((weak)) | ||
| 42 | void matrix_scan_quantum(void) { | ||
| 43 | matrix_scan_kb(); | ||
| 44 | } | ||
| 45 | |||
| 46 | __attribute__ ((weak)) | ||
| 47 | void matrix_init_kb(void) { | ||
| 48 | matrix_init_user(); | ||
| 49 | } | ||
| 50 | |||
| 51 | __attribute__ ((weak)) | ||
| 52 | void matrix_scan_kb(void) { | ||
| 53 | matrix_scan_user(); | ||
| 54 | } | ||
| 55 | |||
| 56 | __attribute__ ((weak)) | ||
| 57 | void matrix_init_user(void) { | ||
| 58 | } | ||
| 59 | |||
| 60 | __attribute__ ((weak)) | ||
| 61 | void matrix_scan_user(void) { | ||
| 62 | } | ||
| 63 | |||
| 64 | void backlight_init_ports(void) | ||
| 65 | { | ||
| 66 | DDRD |= 0b11010000; | ||
| 67 | PORTD &= ~0b01010000; | ||
| 68 | PORTD |= 0b10000000; | ||
| 69 | DDRB |= 0b00011111; | ||
| 70 | PORTB &= ~0b00001110; | ||
| 71 | PORTB |= 0b00010001; | ||
| 72 | DDRE |= 0b01000000; | ||
| 73 | PORTE &= ~0b01000000; | ||
| 74 | } | ||
| 75 | |||
| 76 | void matrix_init(void) { | ||
| 77 | backlight_init_ports(); | ||
| 78 | unselect_cols(); | ||
| 79 | init_rows(); | ||
| 80 | |||
| 81 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
| 82 | matrix[i] = 0; | ||
| 83 | matrix_debouncing[i] = 0; | ||
| 84 | } | ||
| 85 | |||
| 86 | matrix_init_quantum(); | ||
| 87 | } | ||
| 88 | |||
| 89 | uint8_t matrix_scan(void) { | ||
| 90 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { | ||
| 91 | select_col(col); | ||
| 92 | _delay_us(3); | ||
| 93 | |||
| 94 | uint8_t rows = read_rows(col); | ||
| 95 | |||
| 96 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 97 | bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col); | ||
| 98 | bool curr_bit = rows & (1<<row); | ||
| 99 | if (prev_bit != curr_bit) { | ||
| 100 | matrix_debouncing[row] ^= ((matrix_row_t)1<<col); | ||
| 101 | debouncing = DEBOUNCING_DELAY; | ||
| 102 | } | ||
| 103 | } | ||
| 104 | unselect_cols(); | ||
| 105 | } | ||
| 106 | |||
| 107 | if (debouncing) { | ||
| 108 | if (--debouncing) { | ||
| 109 | _delay_ms(1); | ||
| 110 | } else { | ||
| 111 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 112 | matrix[i] = matrix_debouncing[i]; | ||
| 113 | } | ||
| 114 | } | ||
| 115 | } | ||
| 116 | |||
| 117 | matrix_scan_quantum(); | ||
| 118 | return 1; | ||
| 119 | } | ||
| 120 | |||
| 121 | inline matrix_row_t matrix_get_row(uint8_t row) { | ||
| 122 | return matrix[row]; | ||
| 123 | } | ||
| 124 | |||
| 125 | void matrix_print(void) { | ||
| 126 | print("\nr/c 0123456789ABCDEF\n"); | ||
| 127 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 128 | xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row))); | ||
| 129 | } | ||
| 130 | } | ||
| 131 | |||
| 132 | /* Row pin configuration | ||
| 133 | * row: 0 1 2 3 4 5 | ||
| 134 | * pin: PB7 PD0 PD1 PD2 PD3 PD5 | ||
| 135 | * | ||
| 136 | * Esc uses its own pin PE2 | ||
| 137 | */ | ||
| 138 | static void init_rows(void) { | ||
| 139 | DDRD &= ~0b00101111; | ||
| 140 | PORTD &= ~0b00101111; | ||
| 141 | |||
| 142 | DDRB &= ~0b10000000; | ||
| 143 | PORTB &= ~0b10000000; | ||
| 144 | |||
| 145 | DDRE &= ~0b00000100; | ||
| 146 | PORTE |= 0b00000100; | ||
| 147 | } | ||
| 148 | |||
| 149 | static uint8_t read_rows(uint8_t col) { | ||
| 150 | if (col == 16) { | ||
| 151 | return PINE&(1<<2) ? 0 : (1<<0); | ||
| 152 | } else { | ||
| 153 | return (PIND&(1<<0) ? (1<<0) : 0) | | ||
| 154 | (PIND&(1<<1) ? (1<<1) : 0) | | ||
| 155 | (PIND&(1<<2) ? (1<<2) : 0) | | ||
| 156 | (PIND&(1<<3) ? (1<<3) : 0) | | ||
| 157 | (PIND&(1<<5) ? (1<<4) : 0) | | ||
| 158 | (PINB&(1<<7) ? (1<<5) : 0); | ||
| 159 | } | ||
| 160 | } | ||
| 161 | |||
| 162 | uint8_t read_fwkey(void) | ||
| 163 | { | ||
| 164 | return PINE&(1<<2) ? 0 : (1<<0); | ||
| 165 | } | ||
| 166 | |||
| 167 | /* Columns 0 - 15 | ||
| 168 | * These columns uses two 74HC237D 3 to 8 bit demultiplexers. | ||
| 169 | * col / pin: PC6 PB6 PF0 PF1 PC7 | ||
| 170 | * 0: 1 0 0 0 0 | ||
| 171 | * 1: 1 0 1 0 0 | ||
| 172 | * 2: 1 0 0 1 0 | ||
| 173 | * 3: 1 0 1 1 0 | ||
| 174 | * 4: 1 0 0 0 1 | ||
| 175 | * 5: 1 0 1 0 1 | ||
| 176 | * 6: 1 0 0 1 1 | ||
| 177 | * 7: 1 0 1 1 1 | ||
| 178 | * 8: 0 1 0 0 0 | ||
| 179 | * 9: 0 1 1 0 0 | ||
| 180 | * 10: 0 1 0 1 0 | ||
| 181 | * 11: 0 1 1 1 0 | ||
| 182 | * 12: 0 1 0 0 1 | ||
| 183 | * 13: 0 1 1 0 1 | ||
| 184 | * 14: 0 1 0 1 1 | ||
| 185 | * 15: 0 1 1 1 1 | ||
| 186 | * | ||
| 187 | */ | ||
| 188 | static void unselect_cols(void) { | ||
| 189 | DDRB |= 0b01000000; | ||
| 190 | PORTB &= ~0b01000000; | ||
| 191 | |||
| 192 | DDRC |= 0b11000000; | ||
| 193 | PORTC &= ~0b11000000; | ||
| 194 | |||
| 195 | DDRF |= 0b00000011; | ||
| 196 | PORTF &= ~0b00000011; | ||
| 197 | } | ||
| 198 | |||
| 199 | static void select_col(uint8_t col) { | ||
| 200 | |||
| 201 | switch (col) { | ||
| 202 | case 0: | ||
| 203 | PORTC |= 0b01000000; | ||
| 204 | break; | ||
| 205 | case 1: | ||
| 206 | PORTC |= 0b01000000; | ||
| 207 | PORTF |= 0b00000001; | ||
| 208 | break; | ||
| 209 | case 2: | ||
| 210 | PORTC |= 0b01000000; | ||
| 211 | PORTF |= 0b00000010; | ||
| 212 | break; | ||
| 213 | case 3: | ||
| 214 | PORTC |= 0b01000000; | ||
| 215 | PORTF |= 0b00000011; | ||
| 216 | break; | ||
| 217 | case 4: | ||
| 218 | PORTC |= 0b11000000; | ||
| 219 | break; | ||
| 220 | case 5: | ||
| 221 | PORTC |= 0b11000000; | ||
| 222 | PORTF |= 0b00000001; | ||
| 223 | break; | ||
| 224 | case 6: | ||
| 225 | PORTC |= 0b11000000; | ||
| 226 | PORTF |= 0b00000010; | ||
| 227 | break; | ||
| 228 | case 7: | ||
| 229 | PORTC |= 0b11000000; | ||
| 230 | PORTF |= 0b00000011; | ||
| 231 | break; | ||
| 232 | case 8: | ||
| 233 | PORTB |= 0b01000000; | ||
| 234 | break; | ||
| 235 | case 9: | ||
| 236 | PORTB |= 0b01000000; | ||
| 237 | PORTF |= 0b00000001; | ||
| 238 | break; | ||
| 239 | case 10: | ||
| 240 | PORTB |= 0b01000000; | ||
| 241 | PORTF |= 0b00000010; | ||
| 242 | break; | ||
| 243 | case 11: | ||
| 244 | PORTB |= 0b01000000; | ||
| 245 | PORTF |= 0b00000011; | ||
| 246 | break; | ||
| 247 | case 12: | ||
| 248 | PORTB |= 0b01000000; | ||
| 249 | PORTC |= 0b10000000; | ||
| 250 | break; | ||
| 251 | case 13: | ||
| 252 | PORTB |= 0b01000000; | ||
| 253 | PORTF |= 0b00000001; | ||
| 254 | PORTC |= 0b10000000; | ||
| 255 | break; | ||
| 256 | case 14: | ||
| 257 | PORTB |= 0b01000000; | ||
| 258 | PORTF |= 0b00000010; | ||
| 259 | PORTC |= 0b10000000; | ||
| 260 | break; | ||
| 261 | case 15: | ||
| 262 | PORTB |= 0b01000000; | ||
| 263 | PORTF |= 0b00000011; | ||
| 264 | PORTC |= 0b10000000; | ||
| 265 | break; | ||
| 266 | } | ||
| 267 | } | ||
diff --git a/keyboards/octagon_v2/octagon_v2.c b/keyboards/octagon_v2/octagon_v2.c new file mode 100644 index 000000000..05c12c527 --- /dev/null +++ b/keyboards/octagon_v2/octagon_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 "octagon_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/octagon_v2/octagon_v2.h b/keyboards/octagon_v2/octagon_v2.h new file mode 100644 index 000000000..64d2d0169 --- /dev/null +++ b/keyboards/octagon_v2/octagon_v2.h | |||
| @@ -0,0 +1,36 @@ | |||
| 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 OCTAGON_V2_H | ||
| 17 | #define OCTAGON_V2_H | ||
| 18 | |||
| 19 | #include "quantum.h" | ||
| 20 | |||
| 21 | #define KEYMAP( \ | ||
| 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 | #endif | ||
diff --git a/keyboards/octagon_v2/readme.md b/keyboards/octagon_v2/readme.md new file mode 100644 index 000000000..37783c84c --- /dev/null +++ b/keyboards/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) \ No newline at end of file | ||
diff --git a/keyboards/octagon_v2/rules.mk b/keyboards/octagon_v2/rules.mk new file mode 100644 index 000000000..d95dbd960 --- /dev/null +++ b/keyboards/octagon_v2/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 += indicator_leds.c \ | ||
| 72 | matrix.c | ||
