From 60b2a9a5ea88321629e970e936652cc1ba786b80 Mon Sep 17 00:00:00 2001 From: MechMerlin <30334081+mechmerlin@users.noreply.github.com> Date: Fri, 4 Oct 2019 22:06:57 -0700 Subject: [Keyboard] Preliminary Support for Duck Orion V3 (#6892) * initial commit * fixup init_rows and read_rows routine * fixup matrix based on Marcus's tracing info * add a temporary keymap * add notes * use a standard tkl ansi keymap * turn on that last column * backslash and backspace row left to fix * reorg from backslash to pgdn * got the matrix done but the backspace location at K4N is still suspect * add reset info into readme * add qmk configurator support * add community layout support * remove uneeded keymap readme * add a new column just for the reset switch * change copyright dates * add cautionary message to readme as we don't know about the lighting condition yet * Update keyboards/duck/orion/v3/v3.c Co-Authored-By: fauxpark * Update keyboards/duck/orion/v3/v3.c Co-Authored-By: fauxpark * Update keyboards/duck/orion/v3/v3.c Co-Authored-By: fauxpark * change bootloader comments --- keyboards/duck/orion/info.json | 12 + keyboards/duck/orion/readme.md | 7 + keyboards/duck/orion/rules.mk | 1 + keyboards/duck/orion/v3/config.h | 50 +++++ keyboards/duck/orion/v3/indicator_leds.c | 82 +++++++ keyboards/duck/orion/v3/indicator_leds.h | 1 + keyboards/duck/orion/v3/keymaps/default/keymap.c | 26 +++ keyboards/duck/orion/v3/matrix.c | 272 +++++++++++++++++++++++ keyboards/duck/orion/v3/readme.md | 30 +++ keyboards/duck/orion/v3/rules.mk | 39 ++++ keyboards/duck/orion/v3/v3.c | 65 ++++++ keyboards/duck/orion/v3/v3.h | 36 +++ 12 files changed, 621 insertions(+) create mode 100644 keyboards/duck/orion/info.json create mode 100644 keyboards/duck/orion/readme.md create mode 100644 keyboards/duck/orion/rules.mk create mode 100644 keyboards/duck/orion/v3/config.h create mode 100644 keyboards/duck/orion/v3/indicator_leds.c create mode 100644 keyboards/duck/orion/v3/indicator_leds.h create mode 100644 keyboards/duck/orion/v3/keymaps/default/keymap.c create mode 100644 keyboards/duck/orion/v3/matrix.c create mode 100644 keyboards/duck/orion/v3/readme.md create mode 100644 keyboards/duck/orion/v3/rules.mk create mode 100644 keyboards/duck/orion/v3/v3.c create mode 100644 keyboards/duck/orion/v3/v3.h diff --git a/keyboards/duck/orion/info.json b/keyboards/duck/orion/info.json new file mode 100644 index 0000000000..a1f0a5b389 --- /dev/null +++ b/keyboards/duck/orion/info.json @@ -0,0 +1,12 @@ +{ + "keyboard_name": "Duck Orion V3", + "url": "", + "maintainer": "qmk", + "width": 18.25, + "height": 6.5, + "layouts": { + "LAYOUT_tkl_ansi": { + "layout": [{"x":0, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":6.5, "y":0}, {"x":7.5, "y":0}, {"x":8.5, "y":0}, {"x":9.5, "y":0}, {"x":11, "y":0}, {"x":12, "y":0}, {"x":13, "y":0}, {"x":14, "y":0}, {"x":15.25, "y":0}, {"x":16.25, "y":0}, {"x":17.25, "y":0}, {"x":0, "y":1.5}, {"x":1, "y":1.5}, {"x":2, "y":1.5}, {"x":3, "y":1.5}, {"x":4, "y":1.5}, {"x":5, "y":1.5}, {"x":6, "y":1.5}, {"x":7, "y":1.5}, {"x":8, "y":1.5}, {"x":9, "y":1.5}, {"x":10, "y":1.5}, {"x":11, "y":1.5}, {"x":12, "y":1.5}, {"x":13, "y":1.5, "w":2}, {"x":15.25, "y":1.5}, {"x":16.25, "y":1.5}, {"x":17.25, "y":1.5}, {"x":0, "y":2.5, "w":1.5}, {"x":1.5, "y":2.5}, {"x":2.5, "y":2.5}, {"x":3.5, "y":2.5}, {"x":4.5, "y":2.5}, {"x":5.5, "y":2.5}, {"x":6.5, "y":2.5}, {"x":7.5, "y":2.5}, {"x":8.5, "y":2.5}, {"x":9.5, "y":2.5}, {"x":10.5, "y":2.5}, {"x":11.5, "y":2.5}, {"x":12.5, "y":2.5}, {"x":13.5, "y":2.5, "w":1.5}, {"x":15.25, "y":2.5}, {"x":16.25, "y":2.5}, {"x":17.25, "y":2.5}, {"x":0, "y":3.5, "w":1.75}, {"x":1.75, "y":3.5}, {"x":2.75, "y":3.5}, {"x":3.75, "y":3.5}, {"x":4.75, "y":3.5}, {"x":5.75, "y":3.5}, {"x":6.75, "y":3.5}, {"x":7.75, "y":3.5}, {"x":8.75, "y":3.5}, {"x":9.75, "y":3.5}, {"x":10.75, "y":3.5}, {"x":11.75, "y":3.5}, {"x":12.75, "y":3.5, "w":2.25}, {"x":0, "y":4.5, "w":2.25}, {"x":2.25, "y":4.5}, {"x":3.25, "y":4.5}, {"x":4.25, "y":4.5}, {"x":5.25, "y":4.5}, {"x":6.25, "y":4.5}, {"x":7.25, "y":4.5}, {"x":8.25, "y":4.5}, {"x":9.25, "y":4.5}, {"x":10.25, "y":4.5}, {"x":11.25, "y":4.5}, {"x":12.25, "y":4.5, "w":2.75}, {"x":16.25, "y":4.5}, {"x":0, "y":5.5, "w":1.25}, {"x":1.25, "y":5.5, "w":1.25}, {"x":2.5, "y":5.5, "w":1.25}, {"x":3.75, "y":5.5, "w":6.25}, {"x":10, "y":5.5, "w":1.25}, {"x":11.25, "y":5.5, "w":1.25}, {"x":12.5, "y":5.5, "w":1.25}, {"x":13.75, "y":5.5, "w":1.25}, {"x":15.25, "y":5.5}, {"x":16.25, "y":5.5}, {"x":17.25, "y":5.5}] + } + } +} \ No newline at end of file diff --git a/keyboards/duck/orion/readme.md b/keyboards/duck/orion/readme.md new file mode 100644 index 0000000000..b65901de16 --- /dev/null +++ b/keyboards/duck/orion/readme.md @@ -0,0 +1,7 @@ +# Duck Orion + +Non official firmware for custom TKL Korean keyboard made by Duck. + +Newest version is the [Orion V3](http://duck0113.tistory.com/127) + +See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). diff --git a/keyboards/duck/orion/rules.mk b/keyboards/duck/orion/rules.mk new file mode 100644 index 0000000000..3788e0fbfb --- /dev/null +++ b/keyboards/duck/orion/rules.mk @@ -0,0 +1 @@ +DEFAULT_FOLDER = duck/orion/v3 diff --git a/keyboards/duck/orion/v3/config.h b/keyboards/duck/orion/v3/config.h new file mode 100644 index 0000000000..3a17d59416 --- /dev/null +++ b/keyboards/duck/orion/v3/config.h @@ -0,0 +1,50 @@ +/* +Copyright 2019 MechMerlin + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#pragma once + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0x444B // Duck ("DK") +#define PRODUCT_ID 0x4F52 // Orion ("OR") +#define DEVICE_VER 0x0002 +#define MANUFACTURER Duck +#define PRODUCT Orion V3 +#define DESCRIPTION TKL Korean custom keyboard + +/* key matrix size */ +#define MATRIX_ROWS 6 +#define MATRIX_COLS 18 + +#define DIODE_DIRECTION COL2ROW + +/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ +#define DEBOUNCE 5 + +/* number of backlight levels */ +#define BACKLIGHT_LEVELS 3 + +#define RGBLIGHT_ANIMATIONS +#define RGB_DI_PIN D6 +#define RGBLED_NUM 17 + +/* Set to top left most key */ +#define BOOTMAGIC_LITE_ROW 4 +#define BOOTMAGIC_LITE_COLUMN 10 + +#define TAPPING_TERM 200 diff --git a/keyboards/duck/orion/v3/indicator_leds.c b/keyboards/duck/orion/v3/indicator_leds.c new file mode 100644 index 0000000000..951ef462c6 --- /dev/null +++ b/keyboards/duck/orion/v3/indicator_leds.c @@ -0,0 +1,82 @@ +/* +Copyright 2019 MechMerlin + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include +#include +#include +#include +#include "indicator_leds.h" +#include "duck_led/duck_led.h" + +#define LED_T1H 600 +#define LED_T1L 650 +#define LED_T0H 250 +#define LED_T0L 1000 + +void send_bit_d4(bool bitVal) { + if(bitVal) { + asm volatile ( + "sbi %[port], %[bit] \n\t" + ".rept %[onCycles] \n\t" + "nop \n\t" + ".endr \n\t" + "cbi %[port], %[bit] \n\t" + ".rept %[offCycles] \n\t" + "nop \n\t" + ".endr \n\t" + :: + [port] "I" (_SFR_IO_ADDR(PORTD)), + [bit] "I" (4), + [onCycles] "I" (NS_TO_CYCLES(LED_T1H) - 2), + [offCycles] "I" (NS_TO_CYCLES(LED_T1L) - 2)); + } else { + asm volatile ( + "sbi %[port], %[bit] \n\t" + ".rept %[onCycles] \n\t" + "nop \n\t" + ".endr \n\t" + "cbi %[port], %[bit] \n\t" + ".rept %[offCycles] \n\t" + "nop \n\t" + ".endr \n\t" + :: + [port] "I" (_SFR_IO_ADDR(PORTD)), + [bit] "I" (4), + [onCycles] "I" (NS_TO_CYCLES(LED_T0H) - 2), + [offCycles] "I" (NS_TO_CYCLES(LED_T0L) - 2)); + } +} + +void send_value(uint8_t byte, enum Device device) { + for(uint8_t b = 0; b < 8; b++) { + if(device == Device_STATUSLED) { + send_bit_d4(byte & 0b10000000); + byte <<= 1; + } + } +} + +// Send the LED indicators to the WS2811S chips +void indicator_leds_set(bool leds[8]) { + uint8_t led_cnt; + + cli(); + for(led_cnt = 0; led_cnt < 8; led_cnt++) + send_value(leds[led_cnt] ? 255 : 0, Device_STATUSLED); + sei(); + show(); +} + diff --git a/keyboards/duck/orion/v3/indicator_leds.h b/keyboards/duck/orion/v3/indicator_leds.h new file mode 100644 index 0000000000..fe66eef6b2 --- /dev/null +++ b/keyboards/duck/orion/v3/indicator_leds.h @@ -0,0 +1 @@ +void indicator_leds_set(bool leds[8]); diff --git a/keyboards/duck/orion/v3/keymaps/default/keymap.c b/keyboards/duck/orion/v3/keymaps/default/keymap.c new file mode 100644 index 0000000000..83fa4f9a8e --- /dev/null +++ b/keyboards/duck/orion/v3/keymaps/default/keymap.c @@ -0,0 +1,26 @@ +/* Copyright 2019 MechMerlin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include QMK_KEYBOARD_H + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +[0] = LAYOUT_tkl_ansi(\ + KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR,KC_SLCK,KC_PAUS, \ + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0,KC_MINS, KC_EQL,KC_BSPC, KC_INS ,KC_HOME,KC_PGUP, \ + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P,KC_LBRC,KC_RBRC,KC_BSLS, KC_DEL ,KC_END ,KC_PGDN, \ + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L,KC_SCLN,KC_QUOT, KC_ENT, \ + KC_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_LCTL,KC_LGUI,KC_LALT, KC_SPC, KC_RALT,KC_RGUI, KC_APP,KC_RCTL, KC_LEFT,KC_DOWN,KC_RGHT) \ +}; diff --git a/keyboards/duck/orion/v3/matrix.c b/keyboards/duck/orion/v3/matrix.c new file mode 100644 index 0000000000..3c3240b9f4 --- /dev/null +++ b/keyboards/duck/orion/v3/matrix.c @@ -0,0 +1,272 @@ +/* +Copyright 2019 MechMerlin +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include +#include +#include +#include "matrix.h" +#include "util.h" +#include "print.h" +#include "debug.h" + +static uint8_t debouncing = DEBOUNCE; + +/* matrix state(1:on, 0:off) */ +static matrix_row_t matrix[MATRIX_ROWS]; +static matrix_row_t matrix_debouncing[MATRIX_ROWS]; + +static uint8_t read_rows(uint8_t col); +static void init_rows(void); +static void unselect_cols(void); +static void select_col(uint8_t col); + + +__attribute__ ((weak)) +void matrix_init_kb(void) { + matrix_init_user(); +} + +__attribute__ ((weak)) +void matrix_scan_kb(void) { + matrix_scan_user(); +} + +__attribute__ ((weak)) +void matrix_init_user(void) { +} + +__attribute__ ((weak)) +void matrix_scan_user(void) { +} + +void backlight_init_ports(void) +{ + DDRD |= 0b11010000; + PORTD &= ~0b01010000; + PORTD |= 0b10000000; + DDRB |= 0b00011111; + PORTB &= ~0b00001110; + PORTB |= 0b00010001; + DDRE |= 0b01000000; + PORTE &= ~0b01000000; +} + +void matrix_init(void) { + backlight_init_ports(); + unselect_cols(); + init_rows(); + + for (uint8_t i=0; i < MATRIX_ROWS; i++) { + matrix[i] = 0; + matrix_debouncing[i] = 0; + } + + matrix_init_quantum(); +} + +uint8_t matrix_scan(void) { + for (uint8_t col = 0; col < MATRIX_COLS; col++) { + select_col(col); + _delay_us(3); + + uint8_t rows = read_rows(col); + + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1< + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include "v3.h" +#include "indicator_leds.h" + +enum BACKLIGHT_AREAS { + BACKLIGHT_ALPHAS = 0b00000010, + BACKLIGHT_MODNUM = 0b00001000 +}; + +void backlight_set(uint8_t level) { + switch(level) { + case 0: + PORTB |= BACKLIGHT_ALPHAS; + PORTB |= BACKLIGHT_MODNUM; + break; + case 1: + PORTB &= ~BACKLIGHT_ALPHAS; + PORTB |= BACKLIGHT_MODNUM; + break; + case 2: + PORTB |= BACKLIGHT_ALPHAS; + PORTB &= ~BACKLIGHT_MODNUM; + break; + case 3: + PORTB &= ~BACKLIGHT_ALPHAS; + PORTB &= ~BACKLIGHT_MODNUM; + break; + } +} + +// Port from backlight_update_state +void led_set_kb(uint8_t usb_led) { + bool status[8] = { + IS_HOST_LED_ON(USB_LED_SCROLL_LOCK), /* LED 3 */ + IS_HOST_LED_ON(USB_LED_CAPS_LOCK), /* LED 2 */ + IS_HOST_LED_ON(USB_LED_NUM_LOCK), /* LED 1 */ + + layer_state & (1<<2), /* LED 6 */ + layer_state & (1<<1), /* LED 5 */ + layer_state & (1<<0) ? 0: 1, /* LED 4 */ + + layer_state & (1<<5), /* LED 8 */ + layer_state & (1<<4) /* LED 7 */ + }; + + indicator_leds_set(status); +} + +bool process_record_kb(uint16_t keycode, keyrecord_t *record) { + return process_record_user(keycode, record); +} diff --git a/keyboards/duck/orion/v3/v3.h b/keyboards/duck/orion/v3/v3.h new file mode 100644 index 0000000000..70591cf034 --- /dev/null +++ b/keyboards/duck/orion/v3/v3.h @@ -0,0 +1,36 @@ +/* Copyright 2019 MechMerlin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +#include "quantum.h" + +#define ___ KC_NO + +#define LAYOUT_tkl_ansi( \ + K5A, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, \ + K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4R, K4O, K4P, K4Q, \ + K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3O, K3P, K3Q, \ + K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2N, \ + K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1N, K1P, \ + K0A, K0B, K0C, K0F, K0I, K0K, K0M, K0N, K0O, K0P, K0Q \ +) { \ + { K5A, ___, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, ___ }, \ + { K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, ___, K4O, K4P, K4Q, K4R }, \ + { K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3O, K3P, K3Q, ___ }, \ + { K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, ___, K2N, ___, ___, ___, ___ }, \ + { K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, ___, ___, K1N, ___, K1P, ___, ___ }, \ + { K0A, K0B, K0C, ___, ___, K0F, ___, ___, K0I, ___, K0K, ___, K0M, K0N, K0O, K0P, K0Q, ___ } \ +} -- cgit v1.2.3