From f952d4f7b779474918453b7ec3ccccdcfbd63b58 Mon Sep 17 00:00:00 2001 From: "Cmdr. Emily" <68452184+cmdremily@users.noreply.github.com> Date: Sun, 18 Oct 2020 09:37:02 +0200 Subject: [PATCH] Support OpenDeck 32 keyboard (#10305) Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com> Co-authored-by: Ryan --- keyboards/opendeck/32/info.json | 46 ++++++ .../opendeck/32/keymaps/default/keymap.c | 37 +++++ .../opendeck/32/keymaps/default/readme.md | 1 + keyboards/opendeck/32/rev1/config.h | 53 +++++++ keyboards/opendeck/32/rev1/rev1.c | 145 ++++++++++++++++++ keyboards/opendeck/32/rev1/rev1.h | 45 ++++++ keyboards/opendeck/32/rev1/rules.mk | 28 ++++ keyboards/opendeck/info.json | 4 + keyboards/opendeck/readme.md | 19 +++ 9 files changed, 378 insertions(+) create mode 100644 keyboards/opendeck/32/info.json create mode 100644 keyboards/opendeck/32/keymaps/default/keymap.c create mode 100644 keyboards/opendeck/32/keymaps/default/readme.md create mode 100644 keyboards/opendeck/32/rev1/config.h create mode 100644 keyboards/opendeck/32/rev1/rev1.c create mode 100644 keyboards/opendeck/32/rev1/rev1.h create mode 100644 keyboards/opendeck/32/rev1/rules.mk create mode 100644 keyboards/opendeck/info.json create mode 100644 keyboards/opendeck/readme.md diff --git a/keyboards/opendeck/32/info.json b/keyboards/opendeck/32/info.json new file mode 100644 index 0000000000..755b4ae23c --- /dev/null +++ b/keyboards/opendeck/32/info.json @@ -0,0 +1,46 @@ +{ + "keyboard_name": "OpenDeck 32", + "width": 8, + "height": 4, + "layouts": { + "LAYOUT_ortho_4x8": { + "layout": [ + { "x":0, "y":0 }, + { "x":1, "y":0 }, + { "x":2, "y":0 }, + { "x":3, "y":0 }, + { "x":4, "y":0 }, + { "x":5, "y":0 }, + { "x":6, "y":0 }, + { "x":7, "y":0 }, + + { "x":0, "y":1 }, + { "x":1, "y":1 }, + { "x":2, "y":1 }, + { "x":3, "y":1 }, + { "x":4, "y":1 }, + { "x":5, "y":1 }, + { "x":6, "y":1 }, + { "x":7, "y":1 }, + + { "x":0, "y":2 }, + { "x":1, "y":2 }, + { "x":2, "y":2 }, + { "x":3, "y":2 }, + { "x":4, "y":2 }, + { "x":5, "y":2 }, + { "x":6, "y":2 }, + { "x":7, "y":2 }, + + { "x":0, "y":3 }, + { "x":1, "y":3 }, + { "x":2, "y":3 }, + { "x":3, "y":3 }, + { "x":4, "y":3 }, + { "x":5, "y":3 }, + { "x":6, "y":3 }, + { "x":7, "y":3 } + ] + } + } +} diff --git a/keyboards/opendeck/32/keymaps/default/keymap.c b/keyboards/opendeck/32/keymaps/default/keymap.c new file mode 100644 index 0000000000..60cf2d5b71 --- /dev/null +++ b/keyboards/opendeck/32/keymaps/default/keymap.c @@ -0,0 +1,37 @@ +/* Copyright 2020 cmdremily + * + * 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 + +#define _BL 0 + +// clang-format off +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +[_BL] = LAYOUT_ortho_4x8( + LSFT(KC_F13), LSFT(KC_F17), LSFT(KC_F21), LCTL(KC_F13), LCTL(KC_F17), LCTL(KC_F21), LALT(KC_F13), LALT(KC_F17), + LSFT(KC_F14), LSFT(KC_F18), LSFT(KC_F22), LCTL(KC_F14), LCTL(KC_F18), LCTL(KC_F22), LALT(KC_F14), LALT(KC_F18), + LSFT(KC_F15), LSFT(KC_F19), LSFT(KC_F23), LCTL(KC_F15), LCTL(KC_F19), LCTL(KC_F23), LALT(KC_F15), LALT(KC_F19), + LSFT(KC_F16), LSFT(KC_F20), LSFT(KC_F24), LCTL(KC_F16), LCTL(KC_F20), LCTL(KC_F24), LALT(KC_F16), LALT(KC_F20) + ) +}; +// clang-format on + +void suspend_power_down_user(void) { + rgb_matrix_set_suspend_state(true); +} + +void suspend_wakeup_init_user(void) { + rgb_matrix_set_suspend_state(false); +} diff --git a/keyboards/opendeck/32/keymaps/default/readme.md b/keyboards/opendeck/32/keymaps/default/readme.md new file mode 100644 index 0000000000..4ccf0b4633 --- /dev/null +++ b/keyboards/opendeck/32/keymaps/default/readme.md @@ -0,0 +1 @@ +# The default keymap for OpenDeck32 diff --git a/keyboards/opendeck/32/rev1/config.h b/keyboards/opendeck/32/rev1/config.h new file mode 100644 index 0000000000..9f8ed74278 --- /dev/null +++ b/keyboards/opendeck/32/rev1/config.h @@ -0,0 +1,53 @@ +/* Copyright 2020 cmdremily + * + * 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 0x4345 +#define PRODUCT_ID 0x2EC0 +#define DEVICE_VER 0x0001 +#define MANUFACTURER OpenDeck +#define PRODUCT OpenDeck32 + +// Key matrix (TtB, LtR) +#define MATRIX_ROWS 4 +#define MATRIX_COLS 8 +#define MATRIX_COL_PINS \ + { B4, D7, D6, D4, F7, F6, F5, F4 } +#define MATRIX_ROW_PINS \ + { C7, C6, B6, B5 } +#define DIODE_DIRECTION COL2ROW + +// RGB matrix +#define DRIVER_ADDR_1 0b1110100 +#define DRIVER_COUNT 1 +#define DRIVER_1_LED_TOTAL (4 * 8 * 3) +#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL) +#define RGB_DISABLE_WHEN_USB_SUSPENDED true +#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_SPIRAL +#define RGB_MATRIX_DISABLE_KEYCODES + +// Set 0 if debouncing isn't needed +#define DEBOUNCE 5 + +#define FORCE_NKRO + +// Slim down the ROM +#define NO_ACTION_LAYER +#define NO_ACTION_TAPPING +#define NO_ACTION_ONESHOT diff --git a/keyboards/opendeck/32/rev1/rev1.c b/keyboards/opendeck/32/rev1/rev1.c new file mode 100644 index 0000000000..297af907e2 --- /dev/null +++ b/keyboards/opendeck/32/rev1/rev1.c @@ -0,0 +1,145 @@ +/* Copyright 2020 cmdremily + * + * 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 "rev1.h" + +#ifdef RGB_MATRIX_ENABLE +const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { + /* Refer to IS31 manual for these locations + * driver + * | R location + * | | G location + * | | | B location + * | | | | */ + // clang-format off + {0, C4_1, C5_1, C6_1}, + {0, C4_2, C5_2, C6_2}, + {0, C4_3, C5_3, C6_3}, + {0, C1_4, C2_4, C3_4}, + {0, C4_9, C5_9, C6_9}, + {0, C4_10, C5_10, C6_10}, + {0, C4_11, C5_11, C6_11}, + {0, C1_12, C2_12, C3_12}, + + {0, C7_1, C8_1, C9_1}, + {0, C7_2, C8_2, C9_2}, + {0, C7_3, C8_3, C9_3}, + {0, C7_4, C8_4, C9_4}, + {0, C7_9, C8_9, C9_9}, + {0, C7_10, C8_10, C9_10}, + {0, C7_11, C8_11, C9_11}, + {0, C7_12, C8_12, C9_12}, + + {0, C1_5, C2_5, C3_5}, + {0, C1_6, C2_6, C3_6}, + {0, C1_7, C2_7, C3_7}, + {0, C1_8, C2_8, C3_8}, + {0, C1_13, C2_13, C3_13}, + {0, C1_14, C2_14, C3_14}, + {0, C1_15, C2_15, C3_15}, + {0, C1_16, C2_16, C3_16}, + + {0, C7_5, C8_5, C9_5}, + {0, C7_6, C8_6, C9_6}, + {0, C4_7, C5_7, C6_7}, + {0, C4_8, C5_8, C6_8}, + {0, C7_13, C8_13, C9_13}, + {0, C7_14, C8_14, C9_14}, + {0, C4_15, C5_15, C6_15}, + {0, C4_16, C5_16, C6_16}, + // clang-format on +}; + +#define P(x,y) {(x*224 / (MATRIX_COLS - 1)), (y*64 / (MATRIX_ROWS - 1))} +// clang-format off +led_config_t g_led_config = { + // Key Matrix to LED Index + { + {0, 1, 2, 3, 4, 5, 6, 7}, + {8, 9, 10, 11, 12, 13, 14, 15}, + {16, 17, 18, 19, 20, 21, 22, 23}, + {24, 25, 26, 27, 28, 29, 30, 31} + }, { + // LED Index to Physical Position + P(0, 0), P(1, 0), P(2, 0), P(3, 0), P(4, 0), P(5, 0), P(6, 0), P(7, 0), + P(0, 1), P(1, 1), P(2, 1), P(3, 1), P(4, 1), P(5, 1), P(6, 1), P(7, 1), + P(0, 2), P(1, 2), P(2, 2), P(3, 2), P(4, 2), P(5, 2), P(6, 2), P(7, 2), + P(0, 3), P(1, 3), P(2, 3), P(3, 3), P(4, 3), P(5, 3), P(6, 3), P(7, 3), + }, { + // LED Index to Flag + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 + } +}; +#undef P + +// clang-format on + +// Set custom key colors here, in order to change the RGB effect, either reserve some keys +// in the keymap to adjust the pattern (see QMK docs, incompatible with wrapper keys) or +// change the default pattern in config.h. +/* +void rgb_matrix_indicators_kb(void) { + //rgb_matrix_set_color(0, 255, 255, 255); + //rgb_matrix_set_color_all(0x86,0xff,0xff); +} +*/ + +void keyboard_pre_init_kb(void) { + // Light power LED + setPinOutput(POWER_LED_PIN); + writePinLow(POWER_LED_PIN); + + // Enable RGB driver IC + setPinOutput(RGB_DISABLE_N_PIN); + writePinHigh(RGB_DISABLE_N_PIN); + + // We don't use this feature of the IS31FL3731 but it is electrically connected + // Make sure not to drive it + setPinInput(RGB_IRQ_N_PIN); +} + +void keyboard_post_init_user() { + // RGB enabled by default, no way to turn off. No need to expend EEPROM write cycles here. + rgb_matrix_enable_noeeprom(); +} +#endif + +#if defined(KC_WRAPPER_KEY) + +static uint8_t g_key_wrapper_tracker = 0; + +bool process_record_kb(uint16_t keycode, keyrecord_t *record) { + if (!process_record_user(keycode, record) { return false; } + if (record->event.pressed && keycode != KC_WRAPPER_KEY) { + register_code(KC_WRAPPER_KEY); + register_code(keycode); + g_key_wrapper_tracker++; + return false; + } + return true; +} + +void post_process_record_kb(uint16_t keycode, keyrecord_t *record) { + if (!record->event.pressed && keycode != KC_WRAPPER_KEY) { + --g_key_wrapper_tracker; + if (g_key_wrapper_tracker <= 0) { + unregister_code(KC_WRAPPER_KEY); + g_key_wrapper_tracker = 0; + } + } + post_process_record_user(keycode, record); +} +#endif diff --git a/keyboards/opendeck/32/rev1/rev1.h b/keyboards/opendeck/32/rev1/rev1.h new file mode 100644 index 0000000000..9c208df8a8 --- /dev/null +++ b/keyboards/opendeck/32/rev1/rev1.h @@ -0,0 +1,45 @@ +/* Copyright 2020 cmdremily + * + * 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 POWER_LED_PIN F1 +#define RGB_DISABLE_N_PIN D2 +#define RGB_IRQ_N_PIN D3 + +// If you want something similar to what Taran from LMG does in https://github.com/TaranVH/2nd-keyboard +// you can create a "wrapper key" by uncommenting the row below and chosing your wrapper keycode. +// You can then change the keymap in ../keymaps/default/keymap.c to adjust what key is sent inside the +// wrapper. +// Note: The default is to not wrap and to send F13-F24 with combinations of shift/control/alt as these +// are immediately usable in most software (e.g. OBS and DCSB for streaming) without using AHK. +//#define KC_WRAPPER_KEY KC_F24 + +// clang-format off +#define LAYOUT_ortho_4x8( \ + Q00, Q01, Q02, Q03, Q04, Q05, Q06, Q07, \ + Q10, Q11, Q12, Q13, Q14, Q15, Q16, Q17, \ + Q20, Q21, Q22, Q23, Q24, Q25, Q26, Q27, \ + Q30, Q31, Q32, Q33, Q34, Q35, Q36, Q37 \ +) { \ + {Q00, Q01, Q02, Q03, Q04, Q05, Q06, Q07}, \ + {Q10, Q11, Q12, Q13, Q14, Q15, Q16, Q17}, \ + {Q20, Q21, Q22, Q23, Q24, Q25, Q26, Q27}, \ + {Q30, Q31, Q32, Q33, Q34, Q35, Q36, Q37} \ +} +// clang-format on diff --git a/keyboards/opendeck/32/rev1/rules.mk b/keyboards/opendeck/32/rev1/rules.mk new file mode 100644 index 0000000000..f4f4fa8af5 --- /dev/null +++ b/keyboards/opendeck/32/rev1/rules.mk @@ -0,0 +1,28 @@ +# MCU name +MCU = atmega32u4 + +# Processor frequency +F_CPU = 8000000 + +# Bootloader selection +BOOTLOADER = atmel-dfu + +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration +MOUSEKEY_ENABLE = no # Mouse keys +EXTRAKEY_ENABLE = no # Audio control and System control +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = no # Commands for debug and configuration +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +NKRO_ENABLE = yes # USB Nkey Rollover +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow +BLUETOOTH_ENABLE = no # Enable Bluetooth +AUDIO_ENABLE = no # Audio output +RGB_MATRIX_ENABLE = IS31FL3731 + +LTO_ENABLE = yes diff --git a/keyboards/opendeck/info.json b/keyboards/opendeck/info.json new file mode 100644 index 0000000000..7ee0ba60da --- /dev/null +++ b/keyboards/opendeck/info.json @@ -0,0 +1,4 @@ +{ + "url": "https://github.com/cmdremily/OpenDeck", + "maintainer": "cmdremily" +} diff --git a/keyboards/opendeck/readme.md b/keyboards/opendeck/readme.md new file mode 100644 index 0000000000..fb2d01e880 --- /dev/null +++ b/keyboards/opendeck/readme.md @@ -0,0 +1,19 @@ +# OpenDeck + +A OSH/OSW stream deck for streamers + +* Keyboard Maintainer: [cmdremily](https://github.com/cmdremily/) +* Hardware Supported: OpenDeck32 +* Hardware Availability: [OSH on GitHub](https://github.com/cmdremily/OpenDeck) + +Make example for this keyboard (after setting up your build environment): + + make opendeck/32/rev1:default + +Flashing example for this keyboard: + + make opendeck/32/rev1:default:flash + +then press the reset switch on the PCB. + +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).