diff options
Diffstat (limited to 'keyboards')
-rw-r--r-- | keyboards/winry/winry315/config.h | 138 | ||||
-rw-r--r-- | keyboards/winry/winry315/info.json | 104 | ||||
-rw-r--r-- | keyboards/winry/winry315/keymaps/default/keymap.c | 79 | ||||
-rw-r--r-- | keyboards/winry/winry315/keymaps/default/readme.md | 1 | ||||
-rw-r--r-- | keyboards/winry/winry315/keymaps/left_numpad/config.h | 6 | ||||
-rw-r--r-- | keyboards/winry/winry315/keymaps/left_numpad/keymap.c | 81 | ||||
-rw-r--r-- | keyboards/winry/winry315/keymaps/left_numpad/readme.md | 3 | ||||
-rw-r--r-- | keyboards/winry/winry315/keymaps/via/config.h | 15 | ||||
-rw-r--r-- | keyboards/winry/winry315/keymaps/via/encoder_actions.c | 85 | ||||
-rw-r--r-- | keyboards/winry/winry315/keymaps/via/encoder_actions.h | 21 | ||||
-rw-r--r-- | keyboards/winry/winry315/keymaps/via/keymap.c | 44 | ||||
-rw-r--r-- | keyboards/winry/winry315/keymaps/via/rules.mk | 4 | ||||
-rw-r--r-- | keyboards/winry/winry315/readme.md | 45 | ||||
-rw-r--r-- | keyboards/winry/winry315/rules.mk | 21 | ||||
-rw-r--r-- | keyboards/winry/winry315/winry315.c | 262 | ||||
-rw-r--r-- | keyboards/winry/winry315/winry315.h | 86 |
16 files changed, 995 insertions, 0 deletions
diff --git a/keyboards/winry/winry315/config.h b/keyboards/winry/winry315/config.h new file mode 100644 index 0000000000..1a9617c1e3 --- /dev/null +++ b/keyboards/winry/winry315/config.h @@ -0,0 +1,138 @@ +// Copyright 2022 Sergey Vlasov (@sigprof) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "config_common.h" + +// Key matrix size. +#define MATRIX_ROWS 1 +#define MATRIX_COLS 24 + +// Key pins (including encoder press switches). +// The NO_PIN entries are reserved for encoder rotation mappings. +#define DIRECT_PINS \ + { \ + { F4, C7, D4, D5, D1, F5, C6, D6, D3, D2, F6, B6, D7, B4, B5, B2, D0, E6, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN } \ + } + +// clang-format off + +// Encoder pins. +// Encoder numbering (assuming the default board orientation with encoders on +// the top side): +// 0 - left +// 1 - center (with a longer shaft and a larger knob) +// 2 - right +#define ENCODERS_PAD_A { F1, B0, B3 } +#define ENCODERS_PAD_B { F0, B1, B7 } +#define ENCODER_RESOLUTION 4 + +// Encoder mappings (used for VIA). +#define ENCODERS 3 +#define ENCODERS_CW_KEY { { 22, 0 }, { 18, 0 }, { 20, 0 } } +#define ENCODERS_CCW_KEY { { 23, 0 }, { 19, 0 }, { 21, 0 } } + +// clang-format on + +// RGB LED parameters. +// This PCB uses a single chain of WS2812-compatible addressable RGB LEDs for +// per-key backlight and underglow. +#define RGB_DI_PIN F7 +#define RGBLED_NUM 27 +#define RGBLIGHT_LIMIT_VAL 150 + +// RGB Lighting configuration. This mode is used by the vendor firmware, and +// can be chosen if the full RGB Matrix support is not desired for some reason. +#ifdef RGBLIGHT_ENABLE +# define RGBLIGHT_HUE_STEP 8 +# define RGBLIGHT_SAT_STEP 8 +# define RGBLIGHT_VAL_STEP 8 +# define RGBLIGHT_SLEEP +# 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 +#endif + +// RGB Matrix configuration. +#ifdef RGB_MATRIX_ENABLE +# define DRIVER_LED_TOTAL RGBLED_NUM +# define RGB_MATRIX_MAXIMUM_BRIGHTNESS RGBLIGHT_LIMIT_VAL + +# define RGB_MATRIX_CENTER \ + { 35, 35 } + +# define RGB_DISABLE_WHEN_USB_SUSPENDED + +// This option is required for the TYPING_HEATMAP and DIGITAL_RAIN effects, +// both of which are disabled below, so the common support for those effects is +// disabled too. +# undef RGB_MATRIX_FRAMEBUFFER_EFFECTS + +// This option is required for reactive effects; disabling this option will +// implicitly disable all of them. +# define RGB_MATRIX_KEYPRESSES + +# define ENABLE_RGB_MATRIX_ALPHAS_MODS +# define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN +# define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT +# define ENABLE_RGB_MATRIX_BREATHING +# define ENABLE_RGB_MATRIX_BAND_SAT +# define ENABLE_RGB_MATRIX_BAND_VAL +# define ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT +# define ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL +# define ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT +# define ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL +# define ENABLE_RGB_MATRIX_CYCLE_ALL +# define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT +# define ENABLE_RGB_MATRIX_CYCLE_UP_DOWN +# define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON +# define ENABLE_RGB_MATRIX_CYCLE_OUT_IN +# define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL +# define ENABLE_RGB_MATRIX_CYCLE_PINWHEEL +# define ENABLE_RGB_MATRIX_CYCLE_SPIRAL +# define ENABLE_RGB_MATRIX_DUAL_BEACON +# define ENABLE_RGB_MATRIX_RAINBOW_BEACON +# define ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS +# define ENABLE_RGB_MATRIX_RAINDROPS +# define ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS +# define ENABLE_RGB_MATRIX_HUE_BREATHING +# define ENABLE_RGB_MATRIX_HUE_PENDULUM +# define ENABLE_RGB_MATRIX_HUE_WAVE +# define ENABLE_RGB_MATRIX_PIXEL_RAIN +// The PIXEL_FRACTAL effect does not work properly when the matrix layout is +// different from the physical layout; it also has problems when underglow +// LEDs are present, or when multiple LEDs are associated with the same key. +# undef ENABLE_RGB_MATRIX_PIXEL_FRACTAL + +// Framebuffer effects; can be enabled only if RGB_MATRIX_FRAMEBUFFER_EFFECTS +// is defined. Both of these effects currently don't work properly when the +// key matrix does not match the physical layout, so they are disabled. +# undef ENABLE_RGB_MATRIX_TYPING_HEATMAP +# undef ENABLE_RGB_MATRIX_DIGITAL_RAIN + +// Reactive effects; can be enabled only if at least one of +// RGB_MATRIX_KEYPRESSES or RGB_MATRIX_KEYRELEASES is defined. +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS +# define ENABLE_RGB_MATRIX_SPLASH +# define ENABLE_RGB_MATRIX_MULTISPLASH +# define ENABLE_RGB_MATRIX_SOLID_SPLASH +# define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH + +#endif + +// Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed. +#define DEBOUNCE 5 diff --git a/keyboards/winry/winry315/info.json b/keyboards/winry/winry315/info.json new file mode 100644 index 0000000000..6410c6222f --- /dev/null +++ b/keyboards/winry/winry315/info.json @@ -0,0 +1,104 @@ +{ + "manufacturer": "Winry", + "keyboard_name": "Winry315", + "maintainer": "sigprof", + "url": "", + "usb": { + "device_version": "0.0.1", + "pid": "0x0315", + "vid": "0xF1F1" + }, + "layout_aliases": { + "LAYOUT_all": "LAYOUT_top" + }, + "layouts": { + "LAYOUT_top": { + "layout": [ + { "label": "E0", "x": 0.5, "y": 0.25 }, + { "label": "E1", "x": 1.75, "y": 0, "h": 1.5, "w": 1.5 }, + { "label": "E2", "x": 3.5, "y": 0.25 }, + { "label": "0", "x": 0, "y": 1.75 }, + { "label": "1", "x": 1, "y": 1.75 }, + { "label": "2", "x": 2, "y": 1.75 }, + { "label": "3", "x": 3, "y": 1.75 }, + { "label": "4", "x": 4, "y": 1.75 }, + { "label": "5", "x": 0, "y": 2.75 }, + { "label": "6", "x": 1, "y": 2.75 }, + { "label": "7", "x": 2, "y": 2.75 }, + { "label": "8", "x": 3, "y": 2.75 }, + { "label": "9", "x": 4, "y": 2.75 }, + { "label": "10", "x": 0, "y": 3.75 }, + { "label": "11", "x": 1, "y": 3.75 }, + { "label": "12", "x": 2, "y": 3.75 }, + { "label": "13", "x": 3, "y": 3.75 }, + { "label": "14", "x": 4, "y": 3.75 } + ] + }, + "LAYOUT_left": { + "layout": [ + { "label": "E2", "x": 0.25, "y": 0.5 }, + { "label": "4", "x": 1.75, "y": 0 }, + { "label": "9", "x": 2.75, "y": 0 }, + { "label": "14", "x": 3.75, "y": 0 }, + { "label": "3", "x": 1.75, "y": 1 }, + { "label": "8", "x": 2.75, "y": 1 }, + { "label": "13", "x": 3.75, "y": 1 }, + { "label": "E1", "x": 0, "y": 1.75, "h": 1.5, "w": 1.5 }, + { "label": "2", "x": 1.75, "y": 2 }, + { "label": "7", "x": 2.75, "y": 2 }, + { "label": "12", "x": 3.75, "y": 2 }, + { "label": "1", "x": 1.75, "y": 3 }, + { "label": "6", "x": 2.75, "y": 3 }, + { "label": "11", "x": 3.75, "y": 3 }, + { "label": "E0", "x": 0.25, "y": 3.5 }, + { "label": "0", "x": 1.75, "y": 4 }, + { "label": "5", "x": 2.75, "y": 4 }, + { "label": "10", "x": 3.75, "y": 4 } + ] + }, + "LAYOUT_right": { + "layout": [ + { "label": "10", "x": 0, "y": 0 }, + { "label": "5", "x": 1, "y": 0 }, + { "label": "0", "x": 2, "y": 0 }, + { "label": "E0", "x": 3.5, "y": 0.5 }, + { "label": "11", "x": 0, "y": 1 }, + { "label": "6", "x": 1, "y": 1 }, + { "label": "1", "x": 2, "y": 1 }, + { "label": "12", "x": 0, "y": 2 }, + { "label": "7", "x": 1, "y": 2 }, + { "label": "2", "x": 2, "y": 2 }, + { "label": "E1", "x": 3.25, "y": 1.75, "h": 1.5, "w": 1.5 }, + { "label": "13", "x": 0, "y": 3 }, + { "label": "8", "x": 1, "y": 3 }, + { "label": "3", "x": 2, "y": 3 }, + { "label": "14", "x": 0, "y": 4 }, + { "label": "9", "x": 1, "y": 4 }, + { "label": "4", "x": 2, "y": 4 }, + { "label": "E2", "x": 3.5, "y": 3.5 } + ] + }, + "LAYOUT_bottom": { + "layout": [ + { "label": "14", "x": 0, "y": 0 }, + { "label": "13", "x": 1, "y": 0 }, + { "label": "12", "x": 2, "y": 0 }, + { "label": "11", "x": 3, "y": 0 }, + { "label": "10", "x": 4, "y": 0 }, + { "label": "9", "x": 0, "y": 1 }, + { "label": "8", "x": 1, "y": 1 }, + { "label": "7", "x": 2, "y": 1 }, + { "label": "6", "x": 3, "y": 1 }, + { "label": "5", "x": 4, "y": 1 }, + { "label": "4", "x": 0, "y": 2 }, + { "label": "3", "x": 1, "y": 2 }, + { "label": "2", "x": 2, "y": 2 }, + { "label": "1", "x": 3, "y": 2 }, + { "label": "0", "x": 4, "y": 2 }, + { "label": "E2", "x": 0.5, "y": 3.5 }, + { "label": "E1", "x": 1.75, "y": 3.25, "h": 1.5, "w": 1.5 }, + { "label": "E0", "x": 3.5, "y": 3.5 } + ] + } + } +} diff --git a/keyboards/winry/winry315/keymaps/default/keymap.c b/keyboards/winry/winry315/keymaps/default/keymap.c new file mode 100644 index 0000000000..a0bc2706ca --- /dev/null +++ b/keyboards/winry/winry315/keymaps/default/keymap.c @@ -0,0 +1,79 @@ +// Copyright 2022 Sergey Vlasov (@sigprof) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include QMK_KEYBOARD_H + +// Defines names for use in layer keycodes and the keymap +enum layer_names { + _BASE, + _RGB, +}; + +// Shorter defines for some QMK keycodes (to keep the keymap aligned) +#define U_LTESC LT(_RGB, KC_ESC) + +// clang-format off +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + // Base + [_BASE] = LAYOUT_top( + KC_HOME, KC_MUTE, KC_MPLY, + KC_1, KC_2, KC_3, KC_4, KC_5, + KC_6, KC_7, KC_8, KC_9, KC_0, + U_LTESC, KC_TAB, KC_SPC, KC_BSPC, KC_ENT + ), + + // RGB configuration + [_RGB] = LAYOUT_top( + RGB_M_P, RGB_M_B, RGB_M_R, + RGB_MOD, RGB_HUI, RGB_SAI, RGB_VAI, RGB_SPI, + RGB_RMOD,RGB_HUD, RGB_SAD, RGB_VAD, RGB_SPD, + KC_TRNS, RGB_TOG, RGB_M_P, RGB_M_B, RGB_M_R + ), +}; +// clang-format on + +bool encoder_update_user(uint8_t index, bool clockwise) { + uint8_t layer = get_highest_layer(layer_state | default_layer_state); + + switch (index) { + case 0: + // Left encoder + if (layer == _RGB) { + if (clockwise) { + rgblight_increase_hue(); + } else { + rgblight_decrease_hue(); + } + } else { + tap_code(clockwise ? KC_PGDN : KC_PGUP); + } + break; + + case 1: + // Center encoder + if (layer == _RGB) { + if (clockwise) { + rgblight_increase_sat(); + } else { + rgblight_decrease_sat(); + } + } else { + tap_code_delay(clockwise ? KC_VOLU : KC_VOLD, 10); + } + break; + + case 2: + // Right encoder + if (layer == _RGB) { + if (clockwise) { + rgblight_increase_val(); + } else { + rgblight_decrease_val(); + } + } else { + tap_code_delay(clockwise ? KC_MNXT : KC_MPRV, 10); + } + break; + } + return false; +} diff --git a/keyboards/winry/winry315/keymaps/default/readme.md b/keyboards/winry/winry315/keymaps/default/readme.md new file mode 100644 index 0000000000..685bea5767 --- /dev/null +++ b/keyboards/winry/winry315/keymaps/default/readme.md @@ -0,0 +1 @@ +# The default keymap for Winry315 diff --git a/keyboards/winry/winry315/keymaps/left_numpad/config.h b/keyboards/winry/winry315/keymaps/left_numpad/config.h new file mode 100644 index 0000000000..acb72b5bb4 --- /dev/null +++ b/keyboards/winry/winry315/keymaps/left_numpad/config.h @@ -0,0 +1,6 @@ +// Copyright 2022 Sergey Vlasov (@sigprof) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#define WINRY315_DEFAULT_ORIENTATION WINRY315_ORIENTATION_LEFT diff --git a/keyboards/winry/winry315/keymaps/left_numpad/keymap.c b/keyboards/winry/winry315/keymaps/left_numpad/keymap.c new file mode 100644 index 0000000000..8864b1b45a --- /dev/null +++ b/keyboards/winry/winry315/keymaps/left_numpad/keymap.c @@ -0,0 +1,81 @@ +// Copyright 2022 Sergey Vlasov (@sigprof) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include QMK_KEYBOARD_H + +// Defines names for use in layer keycodes and the keymap +enum layer_names { + _BASE, + _RGB, +}; + +// Shorter defines for some QMK keycodes (to keep the keymap aligned) +#define U_LTESC LT(_RGB, KC_ESC) + +// clang-format off +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Base */ + [_BASE] = LAYOUT_left( + KC_MPLY, U_LTESC, KC_BSPC, KC_PENT, + KC_P7, KC_P8, KC_P9, + KC_MUTE, KC_P4, KC_P5, KC_P6, + KC_P1, KC_P2, KC_P3, + KC_HOME, KC_P0, KC_P0, KC_PDOT + ), + + /* RGB configuration */ + [_RGB] = LAYOUT_left( + RGB_M_R, KC_TRNS, RGB_SPD, RGB_SPI, + RGB_TOG, RGB_HUD, RGB_HUI, + RGB_M_B, RGB_M_P, RGB_SAD, RGB_SAI, + KC_NO, RGB_VAD, RGB_VAI, + RGB_M_P, KC_NLCK, RGB_RMOD,RGB_MOD + ), +}; +// clang-format on + +bool encoder_update_user(uint8_t index, bool clockwise) { + uint8_t layer = get_highest_layer(layer_state | default_layer_state); + + switch (index) { + case 0: + // Bottom encoder (left in the default orientation) + if (layer == _RGB) { + if (clockwise) { + rgblight_increase_val(); + } else { + rgblight_decrease_val(); + } + } else { + tap_code(clockwise ? KC_PGDN : KC_PGUP); + } + break; + + case 1: + // Center encoder + if (layer == _RGB) { + if (clockwise) { + rgblight_increase_sat(); + } else { + rgblight_decrease_sat(); + } + } else { + tap_code_delay(clockwise ? KC_VOLU : KC_VOLD, 10); + } + break; + + case 2: + // Top encoder (right in the default orientation) + if (layer == _RGB) { + if (clockwise) { + rgblight_increase_hue(); + } else { + rgblight_decrease_hue(); + } + } else { + tap_code_delay(clockwise ? KC_MNXT : KC_MPRV, 10); + } + break; + } + return false; +} diff --git a/keyboards/winry/winry315/keymaps/left_numpad/readme.md b/keyboards/winry/winry315/keymaps/left_numpad/readme.md new file mode 100644 index 0000000000..9562c2fc19 --- /dev/null +++ b/keyboards/winry/winry315/keymaps/left_numpad/readme.md @@ -0,0 +1,3 @@ +# The “Left Numpad” keymap for Winry315 + +This is a keymap example for the Winry315 board in the “left” orientation (the board is rotated so that the encoders are on the left side, and the keys are in 5 rows of 3 keys). The `LAYOUT_left` macro is used for this orientation, and `WINRY315_DEFAULT_ORIENTATION` is redefined in `config.h` to change the behavior of RGB Matrix effects. diff --git a/keyboards/winry/winry315/keymaps/via/config.h b/keyboards/winry/winry315/keymaps/via/config.h new file mode 100644 index 0000000000..5fc0e02531 --- /dev/null +++ b/keyboards/winry/winry315/keymaps/via/config.h @@ -0,0 +1,15 @@ +// Copyright 2022 Sergey Vlasov (@sigprof) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#define DYNAMIC_KEYMAP_LAYER_COUNT 8 + +// Enable a limited form of RGB Matrix support in VIA (requires redefining the +// effect list in the VIA JSON, which then becomes not 100% compatible with the +// RGBLIGHT firmwares). +#define VIA_QMK_RGBLIGHT_ENABLE + +// Enable the workaround for the speed parameter mismatch between RGBLIGHT and +// RGB Matrix, so that the speed slider in VIA behaves in a more useful way. +#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/winry/winry315/keymaps/via/encoder_actions.c b/keyboards/winry/winry315/keymaps/via/encoder_actions.c new file mode 100644 index 0000000000..96dfe74bca --- /dev/null +++ b/keyboards/winry/winry315/keymaps/via/encoder_actions.c @@ -0,0 +1,85 @@ +/* Copyright 2020 Neil Brian Ramirez + * Copyright 2021 drashna jael're (@drashna) + * Copyright 2022 Sergey Vlasov (@sigprof) + * + * 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 3 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 <http://www.gnu.org/licenses/>. + */ + +#include "encoder_actions.h" + +#if defined(VIA_ENABLE) && defined(ENCODER_ENABLE) + +# ifndef ENCODER_TAP_DURATION_MS +# define ENCODER_TAP_DURATION_MS 10 +# endif + +# define ENCODER_STATE_CW 0x01 +# define ENCODER_STATE_CCW 0x02 + +# ifdef ENCODERS +static uint8_t encoder_state[ENCODERS] = {0}; +static uint16_t encoder_timer[ENCODERS] = {0}; +static keypos_t encoder_cw[ENCODERS] = ENCODERS_CW_KEY; +static keypos_t encoder_ccw[ENCODERS] = ENCODERS_CCW_KEY; + +static void exec_encoder_action(uint8_t index, bool clockwise, bool pressed) { + // clang-format off + keyevent_t encoder_event = (keyevent_t) { + .key = clockwise ? encoder_cw[index] : encoder_ccw[index], + .pressed = pressed, + .time = (timer_read() | 1) + }; + // clang-format on + action_exec(encoder_event); +} +# endif + +void encoder_action_unregister(void) { +# ifdef ENCODERS + for (int index = 0; index < ENCODERS; ++index) { + if (encoder_state[index] && (timer_elapsed(encoder_timer[index]) >= ENCODER_TAP_DURATION_MS)) { + bool clockwise = !!(encoder_state[index] & ENCODER_STATE_CW); + encoder_state[index] = 0; + exec_encoder_action(index, clockwise, false); + } + } +# endif +} + +void encoder_action_register(uint8_t index, bool clockwise) { +# ifdef ENCODERS + if (encoder_state[index]) { + bool was_clockwise = !!(encoder_state[index] & ENCODER_STATE_CW); + encoder_state[index] = 0; + exec_encoder_action(index, was_clockwise, false); + } + encoder_state[index] = clockwise ? ENCODER_STATE_CW : ENCODER_STATE_CCW; + encoder_timer[index] = timer_read(); + exec_encoder_action(index, clockwise, true); +# endif +} + +void matrix_scan_kb(void) { + encoder_action_unregister(); + matrix_scan_user(); +} + +bool encoder_update_kb(uint8_t index, bool clockwise) { + encoder_action_register(index, clockwise); + // don't return user actions, because they are in the keymap + // encoder_update_user(index, clockwise); + return true; +}; + +#endif diff --git a/keyboards/winry/winry315/keymaps/via/encoder_actions.h b/keyboards/winry/winry315/keymaps/via/encoder_actions.h new file mode 100644 index 0000000000..2484af52ae --- /dev/null +++ b/keyboards/winry/winry315/keymaps/via/encoder_actions.h @@ -0,0 +1,21 @@ +/* Copyright 2020 Neil Brian Ramirez + * + * 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 3 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 <http://www.gnu.org/licenses/>. + */ + +#include "quantum.h" + +void encoder_action_unregister(void); + +void encoder_action_register(uint8_t index, bool clockwise); diff --git a/keyboards/winry/winry315/keymaps/via/keymap.c b/keyboards/winry/winry315/keymaps/via/keymap.c new file mode 100644 index 0000000000..67598ac337 --- /dev/null +++ b/keyboards/winry/winry315/keymaps/via/keymap.c @@ -0,0 +1,44 @@ +// Copyright 2022 Sergey Vlasov (@sigprof) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include QMK_KEYBOARD_H + +// clang-format off + +#define LAYOUT_via( \ + k17, k15, k16, \ + k23,k22, k19,k18, k21,k20, \ + k00, k01, k02, k03, k04, \ + k05, k06, k07, k08, k09, \ + k10, k11, k12, k13, k14 \ +) { \ + { k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k20, k21, k22, k23 } \ +} + +#define U_LTESC LT(1, KC_ESC) + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = LAYOUT_via( + KC_HOME, KC_MUTE, KC_MPLY, + KC_PGUP, KC_PGDN, KC_VOLD, KC_VOLU, KC_MPRV, KC_MNXT, + KC_1, KC_2, KC_3, KC_4, KC_5, + KC_6, KC_7, KC_8, KC_9, KC_0, + U_LTESC, KC_TAB, KC_SPC, KC_BSPC, KC_ENT + ), + [1] = LAYOUT_via( + RGB_M_P, RGB_M_B, RGB_M_R, + RGB_HUD, RGB_HUI, RGB_SAD, RGB_SAI, RGB_VAD, RGB_VAI, + RGB_MOD, RGB_HUI, RGB_SAI, RGB_VAI, RGB_SPI, + RGB_RMOD,RGB_HUD, RGB_SAD, RGB_VAD, RGB_SPD, + KC_TRNS, RGB_TOG, RGB_M_P, RGB_M_B, RGB_M_R + ), + [2 ... 7] = LAYOUT_via( + KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ), +}; + +// clang-format on diff --git a/keyboards/winry/winry315/keymaps/via/rules.mk b/keyboards/winry/winry315/keymaps/via/rules.mk new file mode 100644 index 0000000000..6098ef3ad8 --- /dev/null +++ b/keyboards/winry/winry315/keymaps/via/rules.mk @@ -0,0 +1,4 @@ +VIA_ENABLE = yes +LTO_ENABLE = yes + +SRC += encoder_actions.c diff --git a/keyboards/winry/winry315/readme.md b/keyboards/winry/winry315/readme.md new file mode 100644 index 0000000000..099e6b42b4 --- /dev/null +++ b/keyboards/winry/winry315/readme.md @@ -0,0 +1,45 @@ +# Winry315 + +![Winry315](https://i.imgur.com/nWE5mbXh.jpeg) + +Winry315 is a macropad with 3 rotary encoders and 15 keys (arranged as 3 rows of 5 keys). + +This board may also be known as “YD3xn15mx”, “YD315” or “YD 3x15m”. Boards sold by the [SpiderIsland shop on AliExpress](https://www.aliexpress.com/store/5241107) may have “DEBROGLIE” on the bottom side of the case. + +More photos can be found [in this Imgur album](https://imgur.com/a/0xf9pju). + +* Keyboard Maintainer: [Sergey Vlasov](https://github.com/sigprof) +* Hardware Supported: Winry315 PCB +* Hardware Availability: [Taobao](https://world.taobao.com/item/657924681898.htm), [AliExpress](https://www.aliexpress.com/item/1005003500083583.html) + +Make example for this keyboard (after setting up your build environment): + + make winry/winry315:default + +Flashing example for this keyboard: + + make winry/winry315: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 + +Enter the bootloader in 3 ways: + +* **Bootmagic reset**: Hold down the top left key (not the encoder) and plug in the keyboard. This apparently also works with the vendor VIA firmware. + * Note that the bootmagic key does not change with the board orientation configured using `WINRY315_DEFAULT_ORIENTATION` — the “top left” key position in the default orientation (encoders on the top side) is always used. +* **Physical reset button**: Briefly press the button on the back of the PCB (the acrylic bottom cover should have a hole to access that button). +* **Keycode in layout**: Press the key mapped to `RESET` if it is available (the default keymap does not have that keycode assigned to any key, but you can use that keycode in your custom keymap if you want to have easier access to the bootloader). + +## Orientation + +Although the normal orientation of this macropad is with the encoders on the “top” side (away from the user), you may prefer using it in a sideways orientation (with the encoders on the left or right side). There are extra layout macros (`LAYOUT_left`, `LAYOUT_right` and even `LAYOUT_bottom` for completeness) which you can use in the keymap; however, just using one of those macros won't change the behavior of RGB Matrix effects. If you want to change the orientation of various RGB Matrix effects too, you can specify the desired orientation in the `config.h` file for your custom keymap by using one of the following defines: + + #define WINRY315_DEFAULT_ORIENTATION WINRY315_ORIENTATION_TOP + #define WINRY315_DEFAULT_ORIENTATION WINRY315_ORIENTATION_LEFT + #define WINRY315_DEFAULT_ORIENTATION WINRY315_ORIENTATION_RIGHT + #define WINRY315_DEFAULT_ORIENTATION WINRY315_ORIENTATION_BOTTOM + +The VIA firmware changes the orientation for RGB Matrix effects automatically when the “Encoder Side” layout option is changed. + +Note that stems of MX switches are not symmetrical with respect to 90° rotation, so you may have some difficulties when putting the keycaps on switches if you choose one of sideways orientations. diff --git a/keyboards/winry/winry315/rules.mk b/keyboards/winry/winry315/rules.mk new file mode 100644 index 0000000000..c10a9d570a --- /dev/null +++ b/keyboards/winry/winry315/rules.mk @@ -0,0 +1,21 @@ +# MCU name +MCU = atmega32u4 + +# Bootloader selection +BOOTLOADER = atmel-dfu + +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = no # Commands for debug and configuration +NKRO_ENABLE = no # Enable N-Key Rollover +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow +AUDIO_ENABLE = no # Audio output +ENCODER_ENABLE = yes +RGB_MATRIX_ENABLE = yes +RGB_MATRIX_DRIVER = WS2812 diff --git a/keyboards/winry/winry315/winry315.c b/keyboards/winry/winry315/winry315.c new file mode 100644 index 0000000000..c741ffeb74 --- /dev/null +++ b/keyboards/winry/winry315/winry315.c @@ -0,0 +1,262 @@ +// Copyright 2022 Sergey Vlasov (@sigprof) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "winry315.h" + +#include "via.h" + +#if !defined(WINRY315_DEFAULT_ORIENTATION) +# define WINRY315_DEFAULT_ORIENTATION WINRY315_ORIENTATION_TOP +#endif + +#if !defined(VIA_ENABLE) && defined(ENCODER_ENABLE) +# ifndef MEDIA_KEY_DELAY +# define MEDIA_KEY_DELAY 10 +# endif +bool encoder_update_kb(uint8_t index, bool clockwise) { + if (!encoder_update_user(index, clockwise)) { + return false; + } + if (index == 0) { + // Left encoder (assuming the default "top" orientation) + if (clockwise) { + tap_code(KC_PGDN); + } else { + tap_code(KC_PGUP); + } + } else if (index == 1) { + // Center encoder + if (clockwise) { + tap_code_delay(KC_VOLU, MEDIA_KEY_DELAY); + } else { + tap_code_delay(KC_VOLD, MEDIA_KEY_DELAY); + } + } else if (index == 2) { + // Right encoder + if (clockwise) { + tap_code_delay(KC_MNXT, MEDIA_KEY_DELAY); + } else { + tap_code_delay(KC_MPRV, MEDIA_KEY_DELAY); + } + } + return true; +} +#endif // !defined(VIA_ENABLE) && defined(ENCODER_ENABLE) + +#if defined(RGB_MATRIX_ENABLE) + +// LED mapping (assuming the default "top" orientation): +// 0 - right encoder, top right +// 1 - right encoder, top left +// 2 - center encoder, top right +// 3 - center encoder, top left +// 4 - left encoder, top right +// 5 - left encoder, top left +// 6 - row 0, column 0 +// 7 - row 1, column 0 +// 8 - row 2, column 0 +// 9 - row 2, column 1 +// 10 - row 1, column 1 +// 11 - row 0, column 1 +// 12 - row 0, column 2 +// 13 - row 1, column 2 +// 14 - row 2, column 2 +// 15 - row 2, column 3 +// 16 - row 1, column 3 +// 17 - row 0, column 3 +// 18 - row 0, column 4 +// 19 - row 1, column 4 +// 20 - row 2, column 4 +// 21 - underglow, right bottom +// 22 - underglow, left bottom +// 23 - underglow, left middle +// 24 - underglow, left top +// 25 - underglow, right top +// 26 - underglow, right middle + +# define X_MM_MIN (-42) +# define X_MM_MAX 42 +# define Y_MM_MIN (-40) // actually -35, but adjusted to get height = width +# define Y_MM_MAX 44 // actually 40, but adjusted to get height = width +# define WIDTH_MM (X_MM_MAX - X_MM_MIN) +# define HEIGHT_MM (Y_MM_MAX - Y_MM_MIN) +# define WIDTH_UNITS (35 * 2) // needs to match RGB_MATRIX_CENTER +# define HEIGHT_UNITS (35 * 2) // needs to match RGB_MATRIX_CENTER + +// Convert the LED physical coordinates from millimeters with the origin at the +// PCB center to the form expected by the RGB Matrix code. +# define LED(x_mm, y_mm) \ + { ((x_mm - X_MM_MIN) * WIDTH_UNITS + WIDTH_MM / 2) / WIDTH_MM, ((Y_MM_MAX - y_mm) * HEIGHT_UNITS + HEIGHT_MM / 2) / HEIGHT_MM } + +// clang-format off +static const led_config_t PROGMEM initial_led_config = { + { + { 6, 11, 12, 17, 18, 7, 10, 13, 16, 19, 8, 9, 14, 15, 20, 2, 0, 4, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED } + }, + { + LED( 35, 36), + LED( 21, 36), + LED( 8, 34), + LED(-8, 34), + LED(-21, 36), + LED(-35, 36), + LED(-38, 5), + LED(-38, -14), + LED(-38, -33), + LED(-19, -33), + LED(-19, -14), + LED(-19, 5), + LED( 0, 5), + LED( 0, -14), + LED( 0, -33), + LED( 19, -33), + LED( 19, -14), + LED( 19, 5), + LED( 38, 5), + LED( 38, -14), + LED( 38, -33), + LED( 28, -35), + LED(-28, -35), + LED(-37, -9), + LED(-42, 40), + LED( 42, 40), + LED( 37, -9) + }, + { + 1, 1, 1, 1, 1, 1, // encoders (colored as modifiers) + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // regular keys + 2, 2, 2, 2, 2, 2 // underglow + } +}; +// clang-format on + +led_config_t g_led_config; + +void keyboard_pre_init_kb(void) { + // To be safe against any possible changes to rgb_matrix_init(), |