From c4a2bea0e6aac51b8c0806f31614383e267eb1d7 Mon Sep 17 00:00:00 2001 From: TW59420 <40019210+TW59420@users.noreply.github.com> Date: Tue, 12 Dec 2023 11:21:09 +0800 Subject: [PATCH] [Keyboard] add mmk_3 (#22569) Co-authored-by: jack <0x6a73@protonmail.com> Co-authored-by: Ryan Co-authored-by: Drashna Jaelre Co-authored-by: Joel Challis --- keyboards/mwstudio/mmk_3/config.h | 26 +++++++++ keyboards/mwstudio/mmk_3/halconf.h | 22 ++++++++ keyboards/mwstudio/mmk_3/info.json | 53 +++++++++++++++++++ .../mwstudio/mmk_3/keymaps/default/keymap.c | 26 +++++++++ keyboards/mwstudio/mmk_3/keymaps/via/keymap.c | 47 ++++++++++++++++ keyboards/mwstudio/mmk_3/keymaps/via/rules.mk | 2 + keyboards/mwstudio/mmk_3/mcuconf.h | 23 ++++++++ keyboards/mwstudio/mmk_3/readme.md | 22 ++++++++ keyboards/mwstudio/mmk_3/rules.mk | 1 + 9 files changed, 222 insertions(+) create mode 100644 keyboards/mwstudio/mmk_3/config.h create mode 100644 keyboards/mwstudio/mmk_3/halconf.h create mode 100644 keyboards/mwstudio/mmk_3/info.json create mode 100644 keyboards/mwstudio/mmk_3/keymaps/default/keymap.c create mode 100644 keyboards/mwstudio/mmk_3/keymaps/via/keymap.c create mode 100644 keyboards/mwstudio/mmk_3/keymaps/via/rules.mk create mode 100644 keyboards/mwstudio/mmk_3/mcuconf.h create mode 100644 keyboards/mwstudio/mmk_3/readme.md create mode 100644 keyboards/mwstudio/mmk_3/rules.mk diff --git a/keyboards/mwstudio/mmk_3/config.h b/keyboards/mwstudio/mmk_3/config.h new file mode 100644 index 0000000000..0265d3ed6e --- /dev/null +++ b/keyboards/mwstudio/mmk_3/config.h @@ -0,0 +1,26 @@ +/* Copyright 2023 TW59420 + * + * 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 RGBLIGHT_LAYERS +#define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_RAINBOW_SWIRL + 5 + +#define WS2812_PWM_DRIVER PWMD4 +#define WS2812_PWM_CHANNEL 3 +#define WS2812_PWM_PAL_MODE 1 +#define WS2812_DMA_STREAM STM32_DMA1_STREAM7 +#define WS2812_DMA_CHANNEL 2 diff --git a/keyboards/mwstudio/mmk_3/halconf.h b/keyboards/mwstudio/mmk_3/halconf.h new file mode 100644 index 0000000000..0af31c5735 --- /dev/null +++ b/keyboards/mwstudio/mmk_3/halconf.h @@ -0,0 +1,22 @@ +/* Copyright 2022 TW59420 + * + * 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 + +#include_next + diff --git a/keyboards/mwstudio/mmk_3/info.json b/keyboards/mwstudio/mmk_3/info.json new file mode 100644 index 0000000000..c63bd69f62 --- /dev/null +++ b/keyboards/mwstudio/mmk_3/info.json @@ -0,0 +1,53 @@ +{ + "manufacturer": "MWStudio", + "keyboard_name": "MMK_3", + "maintainer": "TW59420", + "bootloader": "stm32duino", + "diode_direction": "ROW2COL", + "features": { + "bootmagic": true, + "extrakey": true, + "mousekey": false, + "nkro": true, + "rgblight": true + }, + "matrix_pins": { + "cols": ["A3", "A4", "A5"], + "rows": ["A6"] + }, + "processor": "STM32F103", + "rgblight": { + "animations": { + "alternating": true, + "breathing": true, + "christmas": true, + "knight": true, + "rainbow_mood": true, + "rainbow_swirl": true, + "snake": true, + "static_gradient": true, + "twinkle": true + }, + "hue_steps": 10, + "led_count": 5 + }, + "url": "", + "usb": { + "device_version": "1.0.0", + "pid": "0x3001", + "vid": "0x7BA1" + }, + "ws2812": { + "driver": "pwm" + "pin": "B8", + }, + "layouts": { + "LAYOUT": { + "layout": [ + { "matrix": [0, 0], "x": 0, "y": 0 }, + { "matrix": [0, 1], "x": 1, "y": 0 }, + { "matrix": [0, 2], "x": 2, "y": 0 } + ] + } + } +} diff --git a/keyboards/mwstudio/mmk_3/keymaps/default/keymap.c b/keyboards/mwstudio/mmk_3/keymaps/default/keymap.c new file mode 100644 index 0000000000..b4cc8ae315 --- /dev/null +++ b/keyboards/mwstudio/mmk_3/keymaps/default/keymap.c @@ -0,0 +1,26 @@ +/* Copyright 2023 TW59420 + * + * 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(LT(3, KC_LCTL), LT(1, KC_C), LT(2, KC_V)), + + [1] = LAYOUT(RGB_VAD, KC_TRNS, RGB_VAI), + + [2] = LAYOUT(RGB_SAD, RGB_SAI, KC_TRNS), + + [3] = LAYOUT(KC_TRNS, RGB_HUD, RGB_HUI)}; diff --git a/keyboards/mwstudio/mmk_3/keymaps/via/keymap.c b/keyboards/mwstudio/mmk_3/keymaps/via/keymap.c new file mode 100644 index 0000000000..c48cc10e36 --- /dev/null +++ b/keyboards/mwstudio/mmk_3/keymaps/via/keymap.c @@ -0,0 +1,47 @@ +/* Copyright 2023 TW59420 + * + * 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 rgblight_segment_t PROGMEM my_layer0_dfu[] = RGBLIGHT_LAYER_SEGMENTS({3, 2, HSV_WHITE}); +const rgblight_segment_t PROGMEM my_layer1_val[] = RGBLIGHT_LAYER_SEGMENTS({3, 2, HSV_BLUE}); +const rgblight_segment_t PROGMEM my_layer2_sat[] = RGBLIGHT_LAYER_SEGMENTS({3, 2, HSV_PURPLE}); +const rgblight_segment_t PROGMEM my_layer3_hue[] = RGBLIGHT_LAYER_SEGMENTS({3, 2, HSV_RED}); + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + [0] = LAYOUT(LT(3, KC_LCTL), LT(1, KC_C), LT(2, KC_V)), + + [1] = LAYOUT(RGB_VAD, KC_TRNS, RGB_VAI), + + [2] = LAYOUT(RGB_SAD, RGB_SAI, KC_TRNS), + + [3] = LAYOUT(KC_TRNS, RGB_HUD, RGB_HUI)}; + +const rgblight_segment_t* const PROGMEM my_rgb_layers[] = RGBLIGHT_LAYERS_LIST(my_layer0_dfu, my_layer1_val, my_layer2_sat, my_layer3_hue); + +void keyboard_post_init_user(void) { + // Enable the LED layers + rgblight_layers = my_rgb_layers; +} + +layer_state_t layer_state_set_user(layer_state_t state) { + rgblight_set_layer_state(0, layer_state_cmp(state, 0)); + rgblight_set_layer_state(1, layer_state_cmp(state, 1)); + rgblight_set_layer_state(2, layer_state_cmp(state, 2)); + rgblight_set_layer_state(3, layer_state_cmp(state, 3)); + return state; +} diff --git a/keyboards/mwstudio/mmk_3/keymaps/via/rules.mk b/keyboards/mwstudio/mmk_3/keymaps/via/rules.mk new file mode 100644 index 0000000000..36b7ba9cbc --- /dev/null +++ b/keyboards/mwstudio/mmk_3/keymaps/via/rules.mk @@ -0,0 +1,2 @@ +VIA_ENABLE = yes +LTO_ENABLE = yes diff --git a/keyboards/mwstudio/mmk_3/mcuconf.h b/keyboards/mwstudio/mmk_3/mcuconf.h new file mode 100644 index 0000000000..fb1d1e81f6 --- /dev/null +++ b/keyboards/mwstudio/mmk_3/mcuconf.h @@ -0,0 +1,23 @@ +/* Copyright 2023 TW59420 + * + * 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_PWM_USE_TIM4 +#define STM32_PWM_USE_TIM4 TRUE + + diff --git a/keyboards/mwstudio/mmk_3/readme.md b/keyboards/mwstudio/mmk_3/readme.md new file mode 100644 index 0000000000..997dbc382a --- /dev/null +++ b/keyboards/mwstudio/mmk_3/readme.md @@ -0,0 +1,22 @@ +# 3Key + +![3Key](https://i.imgur.com/WuwlVknh.jpeg) + +Support APM32F103C8T6 keyboard. + +* Keyboard Maintainer: [TW59420](https://github.com/TW59420) +* Hardware Supported: APM32F103C8T6 + +Make example for this keyboard (after setting up your build environment): + + make mwstudio/mmk_3:default + +Flashing example for this keyboard: + + make mwstudio/mmk_3: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). + +## Bootloader +* **Physical reset button**: Short press the button on the back of the PCB to enter the Bootloader and flash the firmware +* **Keycode in layout**: Press the key mapped to RESET if it is available diff --git a/keyboards/mwstudio/mmk_3/rules.mk b/keyboards/mwstudio/mmk_3/rules.mk new file mode 100644 index 0000000000..7ff128fa69 --- /dev/null +++ b/keyboards/mwstudio/mmk_3/rules.mk @@ -0,0 +1 @@ +# This file intentionally left blank \ No newline at end of file