diff --git a/keyboards/typek/config.h b/keyboards/typek/config.h new file mode 100644 index 00000000000..ceb758c0429 --- /dev/null +++ b/keyboards/typek/config.h @@ -0,0 +1,53 @@ +/* +Copyright 2022 Gondolindrim + +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 . +*/ + +#define RGBLIGHT_LIMIT_VAL 200 +#define RGBLIGHT_DEFAULT_VAL RGBLIGHT_LIMIT_VAL + +#define RGBLIGHT_EFFECT_BREATHING +#define RGBLIGHT_EFFECT_RAINBOW_MOOD +#define RGBLIGHT_EFFECT_RAINBOW_SWIRL +#define RGBLIGHT_EFFECT_SNAKE +#define RGBLIGHT_EFFECT_KNIGHT +#define RGBLIGHT_EFFECT_CHRISTMAS +#define RGBLIGHT_EFFECT_STATIC_GRADIENT +#define RGBLIGHT_EFFECT_RGB_TEST +#define RGBLIGHT_EFFECT_ALTERNATING +#define RGBLIGHT_EFFECT_TWINKLE + +#define RGBLIGHT_DEFAULT_MODE (RGBLIGHT_MODE_RAINBOW_SWIRL + 5) + +#define WS2812_PWM_COMPLEMENTARY_OUTPUT +#define WS2812_PWM_DRIVER PWMD1 +#define WS2812_PWM_CHANNEL 3 +#define WS2812_PWM_PAL_MODE 1 +#define WS2812_DMA_STREAM STM32_DMA2_STREAM5 +#define WS2812_DMA_CHANNEL 6 + +/* LED MAP + 0 , 1 , 2 Three indicators + 3 , 4 , 5 Three RGBs on left side + 66, 67, 68 Three RGBs on right side + 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6 Left RGB wing (30 LEDs) + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65 Right RGB wing (30 LEDs) + */ +#define RGBLIGHT_LED_MAP {0 , 1 , 2, 3 , 4 , 5, 66, 67, 68, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65 } + +#define EECONFIG_KB_DATA_SIZE (3*6) + +#define WEAR_LEVELING_LOGICAL_SIZE 2048 +#define WEAR_LEVELING_BACKING_SIZE 4096 diff --git a/keyboards/typek/halconf.h b/keyboards/typek/halconf.h new file mode 100644 index 00000000000..485d48ef306 --- /dev/null +++ b/keyboards/typek/halconf.h @@ -0,0 +1,22 @@ +/* Copyright 2020 QMK + * + * 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 + +#define HAL_USE_PWM TRUE +#define HAL_USE_PAL TRUE + +#include_next diff --git a/keyboards/typek/info.json b/keyboards/typek/info.json new file mode 100644 index 00000000000..8076209447f --- /dev/null +++ b/keyboards/typek/info.json @@ -0,0 +1,110 @@ +{ + "keyboard_name": "TypeK-S Rev. Zeta-RC2", + "manufacturer": "gok", + "usb": { + "pid": "0x8475", + "vid": "0x7179", + "device_version": "6.2.0" + }, + "diode_direction": "COL2ROW", + "matrix_pins": { + "cols": ["A3" , "B12", "A0" , "A10", "B0" , "B1" , "B10", "B3" , "C15", "C14", "C13", "B9" , "B8" , "B5" ], + "rows": ["A7" , "A8" , "A15", "A1" , "A2" ] + }, + "features": { + "bootmagic": true, + "lto": true, + "mousekey": false, + "extrakey": false, + "console": false, + "backlight": false, + "rgblight": true, + "audio": false, + "encoder": false, + "nkro": true + }, + "ws2812":{ + "pin": "B15" + }, + "rgblight": { + "led_count": 69 + }, + "url": "https://www.gok.design/type-k", + "maintainer": "Gondolindrim", + "processor": "STM32F411", + "bootloader": "stm32-dfu", + "layouts": { + "LAYOUT": { + "layout": [ + {"label":"Esc", "matrix":[ 0, 0], "x":0.75, "y":0 }, + {"label":"`~", "matrix":[ 0, 1], "x":2.5, "y":0 }, + {"label":"1!", "matrix":[ 0, 2], "x":3.5, "y":0 }, + {"label":"2@", "matrix":[ 0, 3], "x":5, "y":0 }, + {"label":"3#", "matrix":[ 0, 4], "x":6, "y":0 }, + {"label":"4$", "matrix":[ 0, 5], "x":7, "y":0 }, + {"label":"5%", "matrix":[ 0, 6], "x":8, "y":0 }, + {"label":"7&", "matrix":[ 0, 7], "x":12.75, "y":0 }, + {"label":"8*", "matrix":[ 0, 8], "x":13.75, "y":0 }, + {"label":"9(", "matrix":[ 0, 9], "x":14.75, "y":0 }, + {"label":"0)", "matrix":[ 0,10], "x":15.75, "y":0 }, + {"label":"-_", "matrix":[ 0,11], "x":17, "y":0 }, + {"label":"=+", "matrix":[ 0,12], "x":18, "y":0 }, + {"label":"\\|", "matrix":[ 0,13], "x":19, "y":0 }, + {"label":"Page Up", "matrix":[ 1, 0], "x":0.5, "y":1 }, + {"label":"Tab", "matrix":[ 1, 1], "x":2.25, "y":1, "w":1.5 }, + {"label":"Q", "matrix":[ 1, 2], "x":3.75, "y":1 }, + {"label":"W", "matrix":[ 1, 3], "x":5.5, "y":1 }, + {"label":"E", "matrix":[ 1, 4], "x":6.5, "y":1 }, + {"label":"R", "matrix":[ 1, 5], "x":7.5, "y":1 }, + {"label":"T", "matrix":[ 1, 6], "x":8.5, "y":1 }, + {"label":"Y", "matrix":[ 1, 7], "x":12, "y":1 }, + {"label":"U", "matrix":[ 1, 8], "x":13, "y":1 }, + {"label":"I", "matrix":[ 1, 9], "x":14, "y":1 }, + {"label":"O", "matrix":[ 1,10], "x":15, "y":1 }, + {"label":"P", "matrix":[ 1,11], "x":16.75, "y":1 }, + {"label":"[{", "matrix":[ 1,12], "x":17.75, "y":1 }, + {"label":"]}", "matrix":[ 1,13], "x":18.75, "y":1 }, + {"label":"Page Down", "matrix":[ 2, 0], "x":0.25, "y":2 }, + {"label":"Caps Lock", "matrix":[ 2, 1], "x":2.25, "y":2, "w":1.75}, + {"label":"A", "matrix":[ 2, 2], "x":4, "y":2 }, + {"label":"S", "matrix":[ 2, 3], "x":5.75, "y":2 }, + {"label":"D", "matrix":[ 2, 4], "x":6.75, "y":2 }, + {"label":"F", "matrix":[ 2, 5], "x":7.75, "y":2 }, + {"label":"G", "matrix":[ 2, 6], "x":8.75, "y":2 }, + {"label":"H", "matrix":[ 2, 7], "x":12.25, "y":2 }, + {"label":"J", "matrix":[ 2, 8], "x":13.25, "y":2 }, + {"label":"K", "matrix":[ 2, 9], "x":14.25, "y":2 }, + {"label":"L", "matrix":[ 2,10], "x":15.25, "y":2 }, + {"label":";:", "matrix":[ 2,11], "x":17.25, "y":2 }, + {"label":"\"", "matrix":[ 2,12], "x":18.25, "y":2 }, + {"label":"Del", "matrix":[ 2,13], "x":20, "y":0 }, + {"label":"End", "matrix":[ 3, 0], "x":0, "y":3 }, + {"label":"Shift", "matrix":[ 3, 1], "x":1.5, "y":3, "w":2.25}, + {"label":"Z", "matrix":[ 3, 2], "x":3.75, "y":3 }, + {"label":"X", "matrix":[ 3, 3], "x":6, "y":3 }, + {"label":"C", "matrix":[ 3, 4], "x":7, "y":3 }, + {"label":"V", "matrix":[ 3, 5], "x":8, "y":3 }, + {"label":"B", "matrix":[ 3, 6], "x":9, "y":3 }, + {"label":"B", "matrix":[ 3, 7], "x":11.75, "y":3 }, + {"label":"N", "matrix":[ 3, 8], "x":12.75, "y":3 }, + {"label":"M", "matrix":[ 3, 9], "x":13.75, "y":3 }, + {"label":",<", "matrix":[ 3,10], "x":14.75, "y":3 }, + {"label":".>", "matrix":[ 3,11], "x":17, "y":3 }, + {"label":"/?", "matrix":[ 3,12], "x":18, "y":3 }, + {"label":"Shift", "matrix":[ 3,13], "x":19, "y":3, "w":1.25}, + {"label":"Control", "matrix":[ 4, 1], "x":1.5, "y":4, "w":1.5 }, + {"label":"Alt", "matrix":[ 4, 2], "x":6, "y":4, "w":1.5 }, + {"label":"Space", "matrix":[ 4, 4], "x":7.5, "y":4, "w":2 }, + {"label":"Left GUI", "matrix":[ 4, 5], "x":9.5, "y":4 }, + {"label":"^6", "matrix":[ 4, 6], "x":9, "y":0 }, + {"label":"Space", "matrix":[ 4, 7], "x":11.25, "y":4 }, + {"label":"Space", "matrix":[ 4, 8], "x":12.25, "y":4, "w":2 }, + {"label":"Alt", "matrix":[ 4, 9], "x":14.25, "y":4, "w":1.5 }, + {"label":"Backspace", "matrix":[ 4,10], "x":19.75, "y":1, "w":1.5 }, + {"label":"Enter", "matrix":[ 4,11], "x":19.25, "y":2, "w":2.25}, + {"label":"MO(1)", "matrix":[ 4,12], "x":20.25, "y":3 }, + {"label":"Control", "matrix":[ 4,13], "x":19.25, "y":4, "w":1.5 } + ] + } + } +} diff --git a/keyboards/typek/keymaps/default/keymap.c b/keyboards/typek/keymaps/default/keymap.c new file mode 100644 index 00000000000..611ffb35f4c --- /dev/null +++ b/keyboards/typek/keymaps/default/keymap.c @@ -0,0 +1,48 @@ +/* Copyright 2023 Gondolindrim + * + * 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( /* Base */ + KC_ESC , KC_GRV , KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_7 , KC_8 , KC_9 , KC_0 , KC_MINS, KC_EQL, KC_BSLS, + 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_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_DEL , + MO(1) , KC_LSFT, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_B , KC_N , KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_RSFT, + KC_LCTL, KC_LALT, KC_SPC , KC_LGUI, KC_6 , KC_SPC , KC_SPC , KC_RALT, KC_BSPC, KC_ENT , MO(1) , KC_RCTL +), +[1] = LAYOUT( + QK_BOOT, 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_TRNS, + KC_HOME, KC_TRNS, KC_TRNS, KC_UP , KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_END , KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, 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, 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, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS +), +[2] = LAYOUT( + 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, 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, 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, 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, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS +), +[3] = LAYOUT( + 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, 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, 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, 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, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS +) +}; diff --git a/keyboards/typek/keymaps/via/keymap.c b/keyboards/typek/keymaps/via/keymap.c new file mode 100644 index 00000000000..87a69075f69 --- /dev/null +++ b/keyboards/typek/keymaps/via/keymap.c @@ -0,0 +1,48 @@ +/* Copyright 2023 Gondolindrim + * + * 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( /* Base */ + KC_ESC , KC_GRV , KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_7 , KC_8 , KC_9 , KC_0 , KC_MINS, KC_EQL, KC_BSLS, + 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_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_DEL , + MO(1) , KC_LSFT, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_B , KC_N , KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_RSFT, + KC_LCTL, KC_LALT, KC_SPC , KC_LGUI, KC_6 , KC_SPC , KC_SPC , KC_RALT, KC_BSPC, KC_ENT , MO(1) , KC_RCTL +), +[1] = LAYOUT( + QK_BOOT, KC_TRNS, KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_TRNS, + KC_HOME, KC_TRNS, KC_TRNS, KC_UP , KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_END , KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, 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, 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, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS +), +[2] = LAYOUT( + 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, 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, 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, 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, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS +), +[3] = LAYOUT( + 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, 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, 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, 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, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS +) +}; diff --git a/keyboards/typek/keymaps/via/rules.mk b/keyboards/typek/keymaps/via/rules.mk new file mode 100644 index 00000000000..1e5b99807cb --- /dev/null +++ b/keyboards/typek/keymaps/via/rules.mk @@ -0,0 +1 @@ +VIA_ENABLE = yes diff --git a/keyboards/typek/mcuconf.h b/keyboards/typek/mcuconf.h new file mode 100644 index 00000000000..3b8dd15a879 --- /dev/null +++ b/keyboards/typek/mcuconf.h @@ -0,0 +1,41 @@ +/* Copyright 2020 QMK + * + * 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_next +#undef STM32_PLLM_VALUE +#undef STM32_PLLN_VALUE +#undef STM32_PLLP_VALUE +#undef STM32_PLLQ_VALUE +#undef STM32_PPRE1 +#undef STM32_PPRE2 + +#define STM32_PLLM_VALUE 4 +#define STM32_PLLN_VALUE 72 +#define STM32_PLLP_VALUE 2 +#define STM32_PLLQ_VALUE 3 +#define STM32_PPRE1 STM32_PPRE1_DIV2 +#define STM32_PPRE2 STM32_PPRE2_DIV1 + +#undef STM32_I2C_USE_I2C1 +#define STM32_I2C_USE_I2C1 TRUE + +#undef STM32_PWM_USE_ADVANCED +#define STM32_PWM_USE_ADVANCED TRUE + +#undef STM32_PWM_USE_TIM1 +#define STM32_PWM_USE_TIM1 TRUE diff --git a/keyboards/typek/readme.md b/keyboards/typek/readme.md new file mode 100644 index 00000000000..c83895155d7 --- /dev/null +++ b/keyboards/typek/readme.md @@ -0,0 +1,60 @@ +# Iron 165R2 QMK folder + +![Iron165R2](https://i.imgur.com/jPamxKu.jpg) + +## Introduction + +This is the QMK Firmware repository for the Iron165 Round 2 PCB, a keyboard designed by [Smith and Rune](https://smithrune.com/) and PCB designed by [Gondolindrim](http://github.com/Gondolindrim), who is also the firwmare maintainer. + +The Iron 165R2 PCB is a 65% PCB with support for a myriad of alternative layouts, including a 7U bottom row and ISO. It also supports in-switch single-color LEDs and RGB LEDs for underglow light. + +As of November 2021, the only way to obtain an Iron165 was through the [Group Buy](https://geekhack.org/index.php?topic=110985) which is already over; extra units are still to be sold. + +## How to flash + +### Enter bootloader + +The DFU state in the bootloader can be accessed in 3 ways: + +* **Bootmagic reset**: Hold down the key at (0,0) in the matrix (usually the top left key, escape in the default keymap) and plug in the keyboard; +* **Physical reset button**: press the button on the front of the PCB, next to caps lock, for at least five seconds; +* **Keycode in layout**: Press the key mapped to `RESET`; in the default layout, that is top left key ('escape') in layer 1. + +### How to compile and flash + +The 165R2 PCB was prototyped and tested using two microcontrollers: STM32F072 and STM32F411. Most production-run units were manufactured with the latter. + +After checking what PCB you own and setting up your build environment, you can compile the Iron 165R2 default keymap by using one of the options below. + + make smithrune/iron165r2/165r2_f072:default + make smithrune/iron165r2/165r2_f411:default + +And use dfu-util in the command line or through a GUI like QMK toolbox to upload the firmware to the PCB. To directly flash the PCB after it is put into a DFU state, use: + + make smithrune/iron165r2/165r2_f072:default:flash + make smithrune/iron165r2/165r2_f411:default:flash + +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). + +## The "runes RGB" feature + +The firmware for 165R2 allows the user to control the RGBs on the PCB through limiting their span according to the usage. There are four possible usages: + +- "Rune RGBs" where only the RGBs under the SnR rune logo on the 165R2 case are lit up; +- "Line RGBs" where only the RGBs on the two alpha cluster rows are lit up; +- "Luke RGBs" where the line RGBs and D25-D23 are on (to avoid hotspotting on the rune backplate); and +- "All RGBs" where all RGBs are turned on. + +In order to use the "rune RGBs" option, you can turn this option on by un-commenting the respective line on the corresponding `config.h` file: + + #define RUNES_RGBS + +If you want to use the "line RGBs" option, you can un-comment the respective lone on the corresponding `config.h` file: + + #define LINES_RGBS + +If you want to use the "luke RGBs" option, you can un-comment the respective lone on the corresponding `config.h` file: + + #define LUKE_RGBS + +The options supersede each other in this order. If no option is defined, then the firwmare defaults to the "all RGBs" option. diff --git a/keyboards/typek/rules.mk b/keyboards/typek/rules.mk new file mode 100644 index 00000000000..a92b0993283 --- /dev/null +++ b/keyboards/typek/rules.mk @@ -0,0 +1,2 @@ +# Enter lower-power sleep mode when on the ChibiOS idle thread +OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE diff --git a/keyboards/typek/typek.c b/keyboards/typek/typek.c new file mode 100644 index 00000000000..97bb8925d6d --- /dev/null +++ b/keyboards/typek/typek.c @@ -0,0 +1,339 @@ +/* Copyright 2023 Gondolindrim + * + * 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 "quantum.h" +#include "print.h" + +/* RGB indicators: by default, they are numbered (when looking from above) INDICATOR_R, INDICATOR_C, INDICATOR_L +*/ + +// Declaring a type indicator_config that stores color and enabled state +typedef struct _indicator_config_t { +// H, S, V store the color values; func stores the function (caps lock, scroll, num, layer indication); index stores the RGB LED index; and enabled stores the enabled state + uint8_t h; + uint8_t s; + uint8_t v; + uint8_t func ; + uint8_t index ; + bool enabled; +} indicator_config ; + +// Number of properties of the "indicator" struct +#define INDICATOR_PROPERTY_NUMBER 6 +// Declaring a keyboard_indicators type that stores the indicators states +#define INDICATOR_NUMBER 3 + +/* List of functions: + 0x00 NONE + 0x01 CAPS LOCK + 0x02 NUM LOCK + 0x03 SCROLL LOCK + 0x04 LAYER 0 + 0x05 LAYER 1 + 0x06 LAYER 2 + 0x07 LAYER 3 +*/ + +bool func_switch(uint8_t func) { + switch (func) + { + case 0x00: + { + return false; + break; + } + case 0x01: // If indicator is set as caps lock + { + if (host_keyboard_led_state().caps_lock) return true; + break; + } + case 0x02: // If indicator is set as num lock + { + if (host_keyboard_led_state().num_lock) return true; + break; + } + case 0x03: // If indicator is set as scroll lock + { + if (host_keyboard_led_state().scroll_lock) return true; + break; + } + case 0x04: // If indicator is set as layer 0 + case 0x05: + case 0x06: + case 0x07: + { + if ( IS_LAYER_ON( (int)(func) - 4 ) ) return true; + break; + } + default: + { + return false; + } + } + return false; +} + +// Here the indicators functions themselves are programmed. +bool set_indicator(indicator_config indicator) { + if (!indicator.enabled) return false; + return func_switch(indicator.func & 0x0F) | func_switch( (indicator.func & 0xF0) >> 4); +} + +typedef struct _keyboard_indicators_t { + indicator_config ind1 ; + indicator_config ind2 ; + indicator_config ind3 ; +} keyboard_indicators ; + +_Static_assert(sizeof(keyboard_indicators) == EECONFIG_KB_DATA_SIZE, "Mismatch in keyboard indicators stored data"); + +// Declaring a new variable indicators of the type keyboard_indicators +keyboard_indicators indicators; +uint8_t* pIndicators = (uint8_t*)&indicators ; // Gets a pointer to the first indicator + +// This function returns the pointer to an indicator given an index. Basically what is done is shifting the pointer of the indicators struct by 6*index. +// Each indicator is INDICATOR_PROPERTY_NUMBER bytes long, so the shift needs to be that size. +indicator_config* get_indicator_p (int index) { + return (indicator_config*) (pIndicators + INDICATOR_PROPERTY_NUMBER*index) ; +} + +// Initializing persistent memory configuration: default values are declared and stored in PMEM +void eeconfig_init_kb(void) { + // Default values: indicators start at white, 150 (roughly 60%) brightness value. Indicators 1 and 2 are active by default. + // INDICATOR 0: RIGHT INDICATOR + indicators.ind1.h = 0; + indicators.ind1.s = 255; + indicators.ind1.v = 150; + indicators.ind1.func = 0x76; + indicators.ind1.index = 0; + indicators.ind1.enabled = true; + + // INDICATOR 1: MIDDLE INDICATOR + indicators.ind2.h = 86; + indicators.ind2.s = 255; + indicators.ind2.v = 150; + indicators.ind2.func = 0x75; + indicators.ind2.index = 1; + indicators.ind2.enabled = true; + + // INDICATOR 2: LEFT INDICATOR + indicators.ind3.h = 166; + indicators.ind3.s = 254; + indicators.ind3.v = 150; + indicators.ind3.func = 0x01; + indicators.ind3.index = 2; + indicators.ind3.enabled = true; + + // Write default value to EEPROM now + eeconfig_update_kb_datablock(&indicators); +} + +// INDICATOR CALLBACK ------------------------------------------------------------------------------ +bool indicators_callback(void) { + + // Basic functioning: for each indicator, set_indicator is used to decide if the current indicator should be lit or off. + indicator_config* current_indicator_p ; + int index ; + for (index = 0 ; index < INDICATOR_NUMBER ; index++) { + current_indicator_p = get_indicator_p(index) ; + if (set_indicator( *(current_indicator_p)) ) sethsv( current_indicator_p -> h, current_indicator_p -> s, current_indicator_p -> v, (LED_TYPE *)&led[current_indicator_p -> index]); + else sethsv( 0,0,0, (LED_TYPE *)&led[current_indicator_p -> index]); + } + return true; +} + +// This function gets called when caps, num, scroll change +bool led_update_kb(led_t led_state) { + indicators_callback(); + return true; +} + +// This function is called when layers change +layer_state_t layer_state_set_user(layer_state_t state) { + indicators_callback(); + return state; +} + +// At the keyboard start, retrieves PMEM stored configs and runs indicator_callback +void keyboard_post_init_kb(void) { + eeconfig_read_kb_datablock(&indicators); + rgblight_set_effect_range(3,66); + indicators_callback(); + + debug_enable = true; + //debug_keyboard = true; +} + +// VIA CONFIGURATION ------------------------------------------------------------------------------- +enum via_indicator_color { + id_ind1_enabled = 1, + id_ind1_brightness = 2, + id_ind1_color = 3, + id_ind1_func1 = 4, + id_ind1_func2 = 5, +// + id_ind2_enabled = 6, + id_ind2_brightness = 7, + id_ind2_color = 8, + id_ind2_func1 = 9, + id_ind2_func2 = 10, +// + id_ind3_enabled = 11, + id_ind3_brightness = 12, + id_ind3_color = 13, + id_ind3_func1 = 14, + id_ind3_func2 = 15 +}; + +int indi_index; +int data_index; + +void indicator_config_set_value( uint8_t *data ) +{ + // data = [ value_id, value_data ] + uint8_t *value_id; + value_id = &(data[0]); + uint8_t *value_data = &(data[1]); + + /* Suppose that the brightness value of indicator 3 is being changed; then + index = (12-1)/INDICATOR_PROPERTY_NUMBER = 11/5 = 2 (integer division!), which indeed relates to indicator 3 (ind1 is 0, ind2 is 1 etc) + data_index = (12 - index*INDICATOR_PROPERTY_NUMBER) = 12 - 2*5 = 2, which indeed relates to a brightness setting (0 is for enabled, 1 for brightness, 2 for color and 3 for func) + Therefore, the basic idea is that index is about which indicator the set_value is about, and data_index about what indicator property it is + */ + indi_index = ( (int)(*value_id) - 1) / 5; + data_index = (int)(*value_id) - indi_index*5; + indicator_config* current_indicator_p = get_indicator_p(indi_index); + uprintf("--> value_id: %X\n", (int)(*value_id)); + switch ( data_index ) + { + case 1 : + { + current_indicator_p -> enabled = value_data[0]; + break; + } + case 2 : + { + current_indicator_p -> v = value_data[0]; + break; + } + case 3: + { + current_indicator_p -> h = value_data[0]; + current_indicator_p -> s = value_data[1]; + break; + } + case 4: + { + current_indicator_p -> func = (current_indicator_p -> func & 0xF0 ) | (uint8_t) value_data[0]; + break; + } + case 5: + { + + current_indicator_p -> func = (current_indicator_p -> func & 0x0F ) | ((uint8_t) value_data[0] << 4); + break; + } + } + indicators_callback(); +} + + +void indicator_config_get_value( uint8_t *data ) +{ + // data = [ value_id, value_data ] + uint8_t *value_id = &(data[0]); + uint8_t *value_data = &(data[1]); + + indi_index = ( (int)(*value_id) - 1) / 5; data_index = (int)(*value_id) - indi_index*5; + indicator_config* current_indicator_p = get_indicator_p(indi_index); + switch ( data_index ) + { + case 1: + { + value_data[0] = current_indicator_p -> enabled; + break; + } + case 2: + { + + value_data[0] = current_indicator_p -> v; + break; + } + case 3: + { + + value_data[0] = current_indicator_p -> h; + value_data[1] = current_indicator_p -> s; + break; + } + case 4: + { + + value_data[0] = current_indicator_p -> func & 0x0F; + uprintf("--> Current func: %x, current func with bitwise or: %X\n", current_indicator_p -> func, current_indicator_p -> func % 0x0F); + break; + } + case 5: + { + + value_data[0] = (current_indicator_p -> func & 0xF0) >> 4; + uprintf("--> Current func: %x, current func with bitwise or: %X\n", current_indicator_p -> func, current_indicator_p -> func % 0xF0); + break; + } + } +} + +void indicator_config_save(void) +{ + eeconfig_update_kb_datablock(&indicators); +} + +void via_custom_value_command_kb(uint8_t *data, uint8_t length) { + // data = [ command_id, channel_id, value_id, value_data ] + uint8_t *command_id = &(data[0]); + uint8_t *channel_id = &(data[1]); + uint8_t *value_id_and_data = &(data[2]); + + if ( *channel_id == id_custom_channel ) { + switch ( *command_id ) + { + case id_custom_set_value: + { + indicator_config_set_value(value_id_and_data); + break; + } + case id_custom_get_value: + { + indicator_config_get_value(value_id_and_data); + break; + } + case id_custom_save: + { + indicator_config_save(); + break; + } + default: + { + // Unhandled message. + *command_id = id_unhandled; + break; + } + } + return; + } + + *command_id = id_unhandled; +}