diff --git a/keyboards/glencreag/wk84/config.h b/keyboards/glencreag/wk84/config.h new file mode 100644 index 000000000000..706ded3c32b6 --- /dev/null +++ b/keyboards/glencreag/wk84/config.h @@ -0,0 +1,35 @@ +/* Copyright 2024 GSKY + * + * 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 + +/* External spi flash */ +#define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN B14 + +/* SPI Config for LED Driver */ +#define SPI_DRIVER SPIDQ +#define SPI_SCK_PIN A5 +#define SPI_MOSI_PIN A7 +#define SPI_MISO_PIN A6 + +/* RGB Matrix */ +#define RGB_MATRIX_FRAMEBUFFER_EFFECTS +#define RGB_MATRIX_STARTUP_MODE 13 +#define RGB_TRIGGER_ON_KEYDOWN + +/* WS2812 */ +#define WS2812_SPI_DRIVER SPIDM2 +#define WS2812_SPI_DIVISOR 16 diff --git a/keyboards/glencreag/wk84/halconf.h b/keyboards/glencreag/wk84/halconf.h new file mode 100644 index 000000000000..560c0009283d --- /dev/null +++ b/keyboards/glencreag/wk84/halconf.h @@ -0,0 +1,23 @@ +/* Copyright (C) 2024 Westberry Technology (ChangZhou) Corp., Ltd + * + * 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_SPI TRUE +#define SPI_USE_WAIT TRUE +#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD + +#include_next diff --git a/keyboards/glencreag/wk84/keyboard.json b/keyboards/glencreag/wk84/keyboard.json new file mode 100644 index 000000000000..fecdb65edae9 --- /dev/null +++ b/keyboards/glencreag/wk84/keyboard.json @@ -0,0 +1,286 @@ +{ + "manufacturer": "GLENCREAG", + "keyboard_name": "WK84", + "maintainer": "Gsky", + "bootloader": "wb32-dfu", + "debounce": 1, + "diode_direction": "ROW2COL", + "dynamic_keymap": { + "layer_count": 4 + }, + "eeprom": { + "driver": "wear_leveling", + "wear_leveling": { + "backing_size": 4096, + "driver": "spi_flash" + } + }, + "features": { + "bootmagic": true, + "command": false, + "console": false, + "extrakey": true, + "mousekey": true, + "nkro": true, + "rgb_matrix": true, + }, + "matrix_pins": { + "cols": ["B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7", "C12", "A15", "B10", "B11", "A10", "A9", "C8", "C5"], + "rows": ["A0", "A1", "A2", "A3", "A4", "A8"] + }, + "processor": "WB32FQ95", + "qmk": { + "locking": { + "enabled": true, + "resync": true + }, + "tap_keycode_delay": 10 + }, + "rgb_matrix": { + "animations": { + "alphas_mods": true, + "band_pinwheel_sat": true, + "band_pinwheel_val": true, + "band_sat": true, + "band_spiral_sat": true, + "band_spiral_val": true, + "band_val": true, + "breathing": true, + "cycle_all": true, + "cycle_left_right": true, + "cycle_out_in": true, + "cycle_out_in_dual": true, + "cycle_pinwheel": true, + "cycle_spiral": true, + "cycle_up_down": true, + "digital_rain": true, + "dual_beacon": true, + "gradient_left_right": true, + "gradient_up_down": true, + "hue_breathing": true, + "hue_pendulum": true, + "hue_wave": true, + "jellybean_raindrops": true, + "multisplash": true, + "pixel_flow": true, + "pixel_fractal": true, + "pixel_rain": true, + "rainbow_beacon": true, + "rainbow_moving_chevron": true, + "rainbow_pinwheels": true, + "raindrops": true, + "solid_multisplash": true, + "solid_reactive": true, + "solid_reactive_cross": true, + "solid_reactive_multicross": true, + "solid_reactive_multinexus": true, + "solid_reactive_multiwide": true, + "solid_reactive_nexus": true, + "solid_reactive_simple": true, + "solid_reactive_wide": true, + "solid_splash": true, + "splash": true, + "typing_heatmap": true + }, + "center_point": [77, 30], + "driver": "ws2812", + "layout": [ + {"matrix": [5, 4], "x": 37, "y": 50, "flags": 4}, + {"matrix": [5, 3], "x": 25, "y": 50, "flags": 4}, + {"matrix": [5, 2], "x": 12, "y": 50, "flags": 4}, + {"matrix": [5, 1], "x": 0, "y": 50, "flags": 4}, + {"matrix": [5, 0], "x": 0, "y": 40, "flags": 4}, + {"matrix": [4, 1], "x": 22, "y": 40, "flags": 4}, + {"matrix": [4, 2], "x": 32, "y": 40, "flags": 4}, + {"matrix": [4, 3], "x": 42, "y": 40, "flags": 4}, + {"matrix": [4, 4], "x": 52, "y": 40, "flags": 4}, + {"matrix": [4, 5], "x": 62, "y": 40, "flags": 4}, + {"matrix": [4, 6], "x": 72, "y": 40, "flags": 4}, + {"matrix": [4, 7], "x": 82, "y": 40, "flags": 4}, + {"matrix": [4, 8], "x": 92, "y": 40, "flags": 4}, + {"matrix": [4, 9], "x": 102, "y": 40, "flags": 4}, + {"matrix": [4, 10], "x": 112, "y": 40, "flags": 4}, + {"matrix": [5, 8], "x": 100, "y": 50, "flags": 4}, + {"matrix": [5, 9], "x": 110, "y": 50, "flags": 4}, + {"matrix": [5, 10], "x": 120, "y": 50, "flags": 4}, + {"matrix": [5, 11], "x": 130, "y": 50, "flags": 4}, + {"matrix": [5, 12], "x": 140, "y": 50, "flags": 4}, + {"matrix": [5, 13], "x": 150, "y": 50, "flags": 4}, + {"matrix": [4, 11], "x": 122, "y": 40, "flags": 4}, + {"matrix": [4, 12], "x": 140, "y": 40, "flags": 4}, + {"matrix": [4, 13], "x": 150, "y": 40, "flags": 4}, + {"matrix": [3, 13], "x": 150, "y": 30, "flags": 4}, + {"matrix": [3, 12], "x": 127, "y": 30, "flags": 4}, + {"matrix": [3, 11], "x": 117, "y": 30, "flags": 4}, + {"matrix": [3, 10], "x": 107, "y": 30, "flags": 4}, + {"matrix": [3, 9], "x": 97, "y": 30, "flags": 4}, + {"matrix": [3, 8], "x": 87, "y": 30, "flags": 4}, + {"matrix": [3, 7], "x": 77, "y": 30, "flags": 4}, + {"matrix": [3, 6], "x": 67, "y": 30, "flags": 4}, + {"matrix": [3, 5], "x": 57, "y": 30, "flags": 4}, + {"matrix": [3, 4], "x": 47, "y": 30, "flags": 4}, + {"matrix": [3, 3], "x": 37, "y": 30, "flags": 4}, + {"matrix": [3, 2], "x": 27, "y": 30, "flags": 4}, + {"matrix": [3, 1], "x": 17, "y": 30, "flags": 4}, + {"matrix": [3, 0], "x": 0, "y": 30, "flags": 4}, + {"matrix": [2, 0], "x": 0, "y": 20, "flags": 4}, + {"matrix": [2, 1], "x": 15, "y": 20, "flags": 4}, + {"matrix": [2, 2], "x": 25, "y": 20, "flags": 4}, + {"matrix": [2, 3], "x": 35, "y": 20, "flags": 4}, + {"matrix": [2, 4], "x": 45, "y": 20, "flags": 4}, + {"matrix": [2, 5], "x": 55, "y": 20, "flags": 4}, + {"matrix": [2, 6], "x": 65, "y": 20, "flags": 4}, + {"matrix": [2, 7], "x": 75, "y": 20, "flags": 4}, + {"matrix": [2, 8], "x": 85, "y": 20, "flags": 4}, + {"matrix": [2, 9], "x": 95, "y": 20, "flags": 4}, + {"matrix": [2, 10], "x": 105, "y": 20, "flags": 4}, + {"matrix": [2, 11], "x": 115, "y": 20, "flags": 4}, + {"matrix": [2, 12], "x": 125, "y": 20, "flags": 4}, + {"matrix": [2, 13], "x": 140, "y": 20, "flags": 4}, + {"matrix": [1, 15], "x": 150, "y": 20, "flags": 4}, + {"matrix": [1, 14], "x": 150, "y": 10, "flags": 4}, + {"matrix": [1, 13], "x": 140, "y": 10, "flags": 4}, + {"matrix": [1, 12], "x": 120, "y": 10, "flags": 4}, + {"matrix": [1, 11], "x": 110, "y": 10, "flags": 4}, + {"matrix": [1, 10], "x": 100, "y": 10, "flags": 4}, + {"matrix": [1, 9], "x": 90, "y": 10, "flags": 4}, + {"matrix": [1, 8], "x": 80, "y": 10, "flags": 4}, + {"matrix": [1, 7], "x": 70, "y": 10, "flags": 4}, + {"matrix": [1, 6], "x": 60, "y": 10, "flags": 4}, + {"matrix": [1, 5], "x": 50, "y": 10, "flags": 4}, + {"matrix": [1, 4], "x": 40, "y": 10, "flags": 4}, + {"matrix": [1, 3], "x": 30, "y": 10, "flags": 4}, + {"matrix": [1, 2], "x": 20, "y": 10, "flags": 4}, + {"matrix": [1, 1], "x": 10, "y": 10, "flags": 4}, + {"matrix": [1, 0], "x": 0, "y": 10, "flags": 4}, + {"matrix": [0, 0], "x": 0, "y": 0, "flags": 4}, + {"matrix": [0, 1], "x": 10, "y": 0, "flags": 4}, + {"matrix": [0, 2], "x": 20, "y": 0, "flags": 4}, + {"matrix": [0, 3], "x": 30, "y": 0, "flags": 4}, + {"matrix": [0, 4], "x": 40, "y": 0, "flags": 4}, + {"matrix": [0, 5], "x": 50, "y": 0, "flags": 4}, + {"matrix": [0, 6], "x": 60, "y": 0, "flags": 4}, + {"matrix": [0, 7], "x": 70, "y": 0, "flags": 4}, + {"matrix": [0, 8], "x": 80, "y": 0, "flags": 4}, + {"matrix": [0, 9], "x": 90, "y": 0, "flags": 4}, + {"matrix": [0, 10], "x": 100, "y": 0, "flags": 4}, + {"matrix": [0, 11], "x": 110, "y": 0, "flags": 4}, + {"matrix": [0, 12], "x": 120, "y": 0, "flags": 4}, + {"matrix": [0, 13], "x": 130, "y": 0, "flags": 4}, + {"matrix": [0, 14], "x": 140, "y": 0, "flags": 4}, + {"matrix": [0, 15], "x": 150, "y": 0, "flags": 4} + ], + "react_on_keyup": true, + "led_count": 84, + "max_brightness": 160, + "default":{ + "sat": 255, + "val": 160, + "speed": 195 + }, + "val_steps": 40, + "speed_steps": 60, + "sleep": true + }, + "url": "", + "usb": { + "device_version": "0.1.6", + "pid": "0xE417", + "vid": "0x342D" + }, + "ws2812": { + "driver": "spi", + "pin": "B15" + }, + "community_layouts": ["75_ansi"], + "layouts": { + "LAYOUT_75_ansi": { + "layout": [ + {"label": "Esc", "matrix": [0, 0], "x": 0, "y": 0}, + {"label": "F1", "matrix": [0, 1], "x": 1, "y": 0}, + {"label": "F2", "matrix": [0, 2], "x": 2, "y": 0}, + {"label": "F3", "matrix": [0, 3], "x": 3, "y": 0}, + {"label": "F4", "matrix": [0, 4], "x": 4, "y": 0}, + {"label": "F5", "matrix": [0, 5], "x": 5, "y": 0}, + {"label": "F6", "matrix": [0, 6], "x": 6, "y": 0}, + {"label": "F7", "matrix": [0, 7], "x": 7, "y": 0}, + {"label": "F8", "matrix": [0, 8], "x": 8, "y": 0}, + {"label": "F9", "matrix": [0, 9], "x": 9, "y": 0}, + {"label": "F10", "matrix": [0, 10], "x": 10, "y": 0}, + {"label": "F11", "matrix": [0, 11], "x": 11, "y": 0}, + {"label": "F12", "matrix": [0, 12], "x": 12, "y": 0}, + {"label": "PrintScreen", "matrix": [0, 13], "x": 13, "y": 0}, + {"label": "Pause", "matrix": [0, 14], "x": 14, "y": 0}, + {"label": "Del", "matrix": [0, 15], "x": 15, "y": 0}, + {"label": "~", "matrix": [1, 0], "x": 0, "y": 1}, + {"label": "1", "matrix": [1, 1], "x": 1, "y": 1}, + {"label": "2", "matrix": [1, 2], "x": 2, "y": 1}, + {"label": "3", "matrix": [1, 3], "x": 3, "y": 1}, + {"label": "4", "matrix": [1, 4], "x": 4, "y": 1}, + {"label": "5", "matrix": [1, 5], "x": 5, "y": 1}, + {"label": "6", "matrix": [1, 6], "x": 6, "y": 1}, + {"label": "7", "matrix": [1, 7], "x": 7, "y": 1}, + {"label": "8", "matrix": [1, 8], "x": 8, "y": 1}, + {"label": "9", "matrix": [1, 9], "x": 9, "y": 1}, + {"label": "0", "matrix": [1, 10], "x": 10, "y": 1}, + {"label": "-", "matrix": [1, 11], "x": 11, "y": 1}, + {"label": "=", "matrix": [1, 12], "x": 12, "y": 1}, + {"label": "Backspace", "matrix": [1, 13], "x": 13, "y": 1, "w": 2}, + {"label": "Home", "matrix": [1, 14], "x": 15, "y": 1}, + {"label": "Tab", "matrix": [2, 0], "x": 0, "y": 2, "w": 1.5}, + {"label": "Q", "matrix": [2, 1], "x": 1.5, "y": 2}, + {"label": "W", "matrix": [2, 2], "x": 2.5, "y": 2}, + {"label": "E", "matrix": [2, 3], "x": 3.5, "y": 2}, + {"label": "R", "matrix": [2, 4], "x": 4.5, "y": 2}, + {"label": "T", "matrix": [2, 5], "x": 5.5, "y": 2}, + {"label": "Y", "matrix": [2, 6], "x": 6.5, "y": 2}, + {"label": "U", "matrix": [2, 7], "x": 7.5, "y": 2}, + {"label": "I", "matrix": [2, 8], "x": 8.5, "y": 2}, + {"label": "O", "matrix": [2, 9], "x": 9.5, "y": 2}, + {"label": "P", "matrix": [2, 10], "x": 10.5, "y": 2}, + {"label": "[", "matrix": [2, 11], "x": 11.5, "y": 2}, + {"label": "]", "matrix": [2, 12], "x": 12.5, "y": 2}, + {"label": "K29", "matrix": [2, 13], "x": 13.5, "y": 2, "w": 1.5}, + {"label": "End", "matrix": [1, 15], "x": 15, "y": 2}, + {"label": "Caps Lock", "matrix": [3, 0], "x": 0, "y": 3, "w": 1.75}, + {"label": "A", "matrix": [3, 1], "x": 1.75, "y": 3}, + {"label": "S", "matrix": [3, 2], "x": 2.75, "y": 3}, + {"label": "D", "matrix": [3, 3], "x": 3.75, "y": 3}, + {"label": "F", "matrix": [3, 4], "x": 4.75, "y": 3}, + {"label": "G", "matrix": [3, 5], "x": 5.75, "y": 3}, + {"label": "H", "matrix": [3, 6], "x": 6.75, "y": 3}, + {"label": "J", "matrix": [3, 7], "x": 7.75, "y": 3}, + {"label": "K", "matrix": [3, 8], "x": 8.75, "y": 3}, + {"label": "L", "matrix": [3, 9], "x": 9.75, "y": 3}, + {"label": ";", "matrix": [3, 10], "x": 10.75, "y": 3}, + {"label": "'", "matrix": [3, 11], "x": 11.75, "y": 3}, + {"label": "Enter", "matrix": [3, 12], "x": 12.75, "y": 3, "w": 2.25}, + {"label": "PageUp", "matrix": [3, 13], "x": 15, "y": 3}, + {"label": "LShift", "matrix": [5, 0], "x": 0, "y": 4, "w": 2.25}, + {"label": "Z", "matrix": [4, 1], "x": 2.25, "y": 4}, + {"label": "X", "matrix": [4, 2], "x": 3.25, "y": 4}, + {"label": "C", "matrix": [4, 3], "x": 4.25, "y": 4}, + {"label": "V", "matrix": [4, 4], "x": 5.25, "y": 4}, + {"label": "B", "matrix": [4, 5], "x": 6.25, "y": 4}, + {"label": "N", "matrix": [4, 6], "x": 7.25, "y": 4}, + {"label": "M", "matrix": [4, 7], "x": 8.25, "y": 4}, + {"label": ",", "matrix": [4, 8], "x": 9.25, "y": 4}, + {"label": ".", "matrix": [4, 9], "x": 10.25, "y": 4}, + {"label": "/", "matrix": [4, 10], "x": 11.25, "y": 4}, + {"label": "RShift", "matrix": [4, 11], "x": 12.25, "y": 4, "w": 1.75}, + {"label": "Up", "matrix": [4, 12], "x": 14, "y": 4}, + {"label": "PageDown", "matrix": [4, 13], "x": 15, "y": 4}, + {"label": "LCtrl", "matrix": [5, 1], "x": 0, "y": 5, "w": 1.25}, + {"label": "LWin", "matrix": [5, 2], "x": 1.25, "y": 5, "w": 1.25}, + {"label": "LAlt", "matrix": [5, 3], "x": 2.5, "y": 5, "w": 1.25}, + {"label": "Space", "matrix": [5, 4], "x": 3.75, "y": 5, "w": 6.25}, + {"label": "RAlt", "matrix": [5, 8], "x": 10, "y": 5}, + {"label": "FN", "matrix": [5, 9], "x": 11, "y": 5}, + {"label": "RCtrl", "matrix": [5, 10], "x": 12, "y": 5}, + {"label": "Left", "matrix": [5, 11], "x": 13, "y": 5}, + {"label": "Down", "matrix": [5, 12], "x": 14, "y": 5}, + {"label": "Right", "matrix": [5, 13], "x": 15, "y": 5} + ] + } + } +} diff --git a/keyboards/glencreag/wk84/keymaps/default/keymap.c b/keyboards/glencreag/wk84/keymaps/default/keymap.c new file mode 100644 index 000000000000..f371ab99571e --- /dev/null +++ b/keyboards/glencreag/wk84/keymaps/default/keymap.c @@ -0,0 +1,428 @@ +/* Copyright 2024 GSKY + * + * 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 HOLD_TIME 3000 +#define BLINK_WHITE 0 +#define BLINK_RED 1 + +static bool fn_pressed = false; +static bool lalt_pressed = false; + +static bool led_on = false; +static uint16_t blink_timer = 0; +static uint8_t blink_count = 7; +static uint8_t reset_blink_count =7; +uint8_t blinking = 0; + +static uint16_t reset_timer = 0; + +// Each layer gets a name for readability, which is then used in the keymap matrix below. +// The underscores don't mean anything - you can have a layer called STUFF or any other name. + +#define RGB_HSV_MAX 7 +static uint8_t rgb_hsvs[7][3] = { + {0, 255, 255}, + {77,255, 255}, + {170,255,255}, + {10, 255,255}, + {209,255,255}, + {36, 255,255}, + {0, 0, 255}, +}; + +enum layers { + _Win, + _Mac, + _Winfn, + _Macfn, +}; + + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Keymap _BL: Base Layer (Default Layer) + */ +[_Win] = LAYOUT_75_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_PAUS, KC_DEL, + 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_HOME, + 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_END, + 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_PGUP, + 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_PGDN, + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_Winfn), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT), + +[_Winfn] = LAYOUT_75_ansi( + KC_TRNS, KC_BRID, KC_BRIU, LGUI(KC_D), LGUI(KC_TAB), KC_MAIL, KC_CALC, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, KC_TRNS, KC_TRNS, KC_INS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RM_NEXT, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RM_HUEU, + KC_TRNS, TO(_Win),TO(_Mac),KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RM_TOGG, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RM_VALU, KC_TRNS, + KC_TRNS, GU_TOGG, KC_TRNS, EE_CLR, KC_TRNS, KC_TRNS, KC_TRNS, RM_SPDD, RM_VALD, RM_SPDU), + +[_Mac] = LAYOUT_75_ansi( + + KC_ESC, KC_BRID, KC_BRIU, KC_MCTL, KC_LPAD, KC_NO, KC_NO, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, KC_PSCR, KC_PAUS, KC_DEL, + 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_HOME, + 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_END, + 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_PGUP, + 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_PGDN, + KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, MO(_Macfn), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT), + +[_Macfn] = LAYOUT_75_ansi( + 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_F12, KC_TRNS, KC_TRNS, KC_INS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RM_NEXT, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RM_HUEU, + KC_TRNS, TO(_Win),TO(_Mac),KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RM_TOGG, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RM_VALU, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, EE_CLR, KC_TRNS, KC_TRNS, KC_TRNS ,RM_SPDD, RM_VALD, RM_SPDU) +}; + +typedef union { + uint32_t raw; + struct { + uint8_t flag: 1; + uint8_t rgb_enable: 1; + uint8_t no_gui: 1; + uint8_t rgb_status: 1; + uint8_t rgb_hsv_index: 3; + uint8_t rgb_brightness; + uint8_t Num_To_F1: 1; + uint8_t hui_index: 3; + }; +} confinfo_t; +confinfo_t confinfo; + +typedef struct { + uint8_t brightness_level: 5; + uint8_t speed_level: 3; + bool close_rgb; +} settings_t; +settings_t settings; + + +void blink_all_led_matrix(uint8_t blink_color) { + + if(blink_color == BLINK_WHITE) + { + if (timer_elapsed(blink_timer) > 165) + { + blink_timer = timer_read(); + + if (blink_count < 7) { + led_on = !led_on; + blink_count++; + } + else + { + blink_color = 0; + blinking = 0; + } + } + } + else if(blink_color == BLINK_RED) + { + if (timer_elapsed(blink_timer) > 165) + { + blink_timer = timer_read(); + + if (reset_blink_count < 7) { + led_on = !led_on; + reset_blink_count++; + } + else + { + blink_color = 0; + blinking = 0; + } + + } + } +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) + { + case EE_CLR: + { + if (record->event.pressed) { + reset_timer = timer_read(); + } + return false; + } + break; + case RM_SPDD: + { + if (record->event.pressed) + { + if(settings.speed_level <= 1 ) + { + rgb_matrix_set_speed(15); + + blinking = 1; + blink_count = 0; + return false; + } + if(settings.speed_level == 2 ) + { + rgb_matrix_set_speed(15); + + blinking = 1; + blink_count = 0; + settings.speed_level--; + return false; + } + else + { + settings.speed_level--; + } + } + } + break; + case RM_SPDU: + { + if (record->event.pressed) + { + if(settings.speed_level >= 5 ) + { + blinking = 1; + blink_count = 0; + return false; + } + else if(settings.speed_level == 4 ) + { + blinking = 1; + blink_count = 0; + settings.speed_level++; + } + else + { + settings.speed_level++; + } + } + } + break; + case RM_VALU: + { + if (record->event.pressed) + { + if(settings.brightness_level >= 5 ) + { + blinking = 1; + blink_count = 0; + return false; + } + else if(settings.brightness_level == 4 ) + { + blinking = 1; + blink_count = 0; + settings.brightness_level++; + } + else + { + settings.brightness_level++; + } + } + } + break; + case RM_VALD: + { + if (record->event.pressed) + { + if(settings.brightness_level == 1) + { + blinking = 1; + blink_count = 0; + return false; + } + else if(settings.brightness_level == 2) + { + blinking = 1; + blink_count = 0; + settings.brightness_level--; + } + else + { + settings.brightness_level--; + } + } + } + break; + case KC_LGUI: { + if (record->event.pressed) + { + if(confinfo.no_gui) + return false; + else + return true; + } + }break; + case GU_TOGG: { + if(record->event.pressed){ + confinfo.no_gui = !confinfo.no_gui; + } + return false; + }break; + case RM_TOGG: { + if(record->event.pressed){ + settings.close_rgb = !settings.close_rgb; + } + return false; + }break; + case RM_HUEU: + if (record->event.pressed) { + confinfo.hui_index = (confinfo.hui_index + 1) % RGB_HSV_MAX; + + rgb_matrix_sethsv(rgb_hsvs[confinfo.hui_index][0], + rgb_hsvs[confinfo.hui_index][1], + rgb_matrix_get_val()); + eeconfig_update_user(confinfo.raw); + } + return false; + break; + case RGB_HUD: + if (record->event.pressed) { + uint8_t now_mode_one = rgb_matrix_get_mode(); + if((now_mode_one == 6) ||(now_mode_one == 13) ||(now_mode_one == 15) ||(now_mode_one == 16) ||(now_mode_one == 25) ||(now_mode_one == 26) ||(now_mode_one == 34)){ + (confinfo.rgb_hsv_index == 0)? (confinfo.rgb_hsv_index = 5):(confinfo.rgb_hsv_index = confinfo.rgb_hsv_index - 1); + rgb_matrix_sethsv(rgb_hsvs[confinfo.rgb_hsv_index][0], + rgb_hsvs[confinfo.rgb_hsv_index][1], + rgb_matrix_get_val()); + }else{ + (confinfo.rgb_hsv_index == 0)? (confinfo.rgb_hsv_index = 6):(confinfo.rgb_hsv_index = confinfo.rgb_hsv_index - 1); + rgb_matrix_sethsv(rgb_hsvs[confinfo.rgb_hsv_index][0], + rgb_hsvs[confinfo.rgb_hsv_index][1], + rgb_matrix_get_val()); + } + eeconfig_update_user(confinfo.raw); + } + return false; + break; + case TO(_Win): { + if(record->event.pressed) { + blinking = 1; + blink_count = 0; + set_single_persistent_default_layer(_Win); + } + return false; + } break; + case TO(_Mac): { + if (record->event.pressed) { + blinking = 1; + blink_count = 0; + confinfo.no_gui = false; + set_single_persistent_default_layer(_Mac); + } + return false; + } break; + default: + break; + } + return true; +} + +void matrix_scan_user(void) { + + if(matrix_is_on(5,9)) + fn_pressed = true; + else + fn_pressed = false; + + if(matrix_is_on(5,3)) + lalt_pressed = true; + else + lalt_pressed = false; + + if(matrix_is_on(2,0)) { + if ((fn_pressed)&&(lalt_pressed)){ + reset_keyboard(); + } + } + + if(blinking ==1 ) + blink_all_led_matrix(BLINK_WHITE); + else if(blinking ==2 ) + blink_all_led_matrix(BLINK_RED); + + + if(reset_timer != 0 ) + { + if(timer_elapsed(reset_timer) >= 5000) + { + reset_timer = 0; + reset_blink_count = 0; + confinfo.no_gui = false; + blinking = 2; + + layer_state_t default_layer_temp = default_layer_state; + eeconfig_init(); + default_layer_set(default_layer_temp); + + // This resets the layout options + // via_set_layout_options(VIA_EEPROM_LAYOUT_OPTIONS_DEFAULT); + // This resets the keymaps in EEPROM to what is in flash. + // dynamic_keymap_reset(); + // This resets the macros in EEPROM to nothing. + // dynamic_keymap_macro_reset(); + + rgb_matrix_enable(); + rgb_matrix_mode(13); + // set to cycle_left_right by default + rgb_matrix_sethsv(HSV_RED); + rgb_matrix_set_speed(195); + + rgb_matrix_set_flags(LED_FLAG_ALL); + + settings.brightness_level = 5; + settings.speed_level = 3; + confinfo.no_gui = 0; + } + } +} + +bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { + + if(settings.close_rgb){ + rgb_matrix_set_color_all(0,0,0); + } + + if (host_keyboard_led_state().caps_lock) { + rgb_matrix_set_color(37, 0, 0, 0xff); + } + + // GUI lock + if (confinfo.no_gui) { + rgb_matrix_set_color(2, 255, 255, 255); + } + + if(blink_count <6) + { + if (led_on) { + rgb_matrix_set_color_all(0,0,0); + } else { + rgb_matrix_set_color_all(100,100,100); + } + } + else if(reset_blink_count <6) + { + if (led_on) { + rgb_matrix_set_color_all(0,0,0); + } else { + rgb_matrix_set_color_all(255,0,0); + } + } + + return true; +} diff --git a/keyboards/glencreag/wk84/mcuconf.h b/keyboards/glencreag/wk84/mcuconf.h new file mode 100644 index 000000000000..93213a2d2d2e --- /dev/null +++ b/keyboards/glencreag/wk84/mcuconf.h @@ -0,0 +1,27 @@ +/* Copyright (C) 2024 Westberry Technology (ChangZhou) Corp., Ltd + * + * 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 + +#define WB32_EXTI_REQUIRED + +#undef WB32_SPI_USE_QSPI +#define WB32_SPI_USE_QSPI TRUE + +#undef WB32_SPI_USE_SPIM2 +#define WB32_SPI_USE_SPIM2 TRUE diff --git a/keyboards/glencreag/wk84/readme.md b/keyboards/glencreag/wk84/readme.md new file mode 100644 index 000000000000..0d065dca9fc4 --- /dev/null +++ b/keyboards/glencreag/wk84/readme.md @@ -0,0 +1,25 @@ +# WK84 + +![WK84](https://i.imgur.com/Iau74ZK.png) + + +A keyboard, Equipped with the WestBerry Q95 microcontroller. + +* Keyboard Maintainer: [GSKY](https://github.com/gksygithub) +* Hardware Supported: WK84 + +Make example for this keyboard (after setting up your build environment): + + make glencreag/wk84:default + +Flashing example for this keyboard: + + make glencreag/wk84:default:flash + +To reset the board into bootloader mode, do one of the following: + +* Hold the Reset switch mounted under the space key after the USB cable is connected +* Hold the Esc key while connecting the USB cable (also erases persistent settings) +* Hold down FN + L_Alt first, then press Tab will reset the board to bootloader mode + +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/glencreag/wk84/wk84.c b/keyboards/glencreag/wk84/wk84.c new file mode 100644 index 000000000000..58f38bb153c0 --- /dev/null +++ b/keyboards/glencreag/wk84/wk84.c @@ -0,0 +1,44 @@ +/* Copyright 2024 GSKY + * + * 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 . + */ + +#ifdef EEPROM_ENABLE + +#include "spi_master.h" + +void spi_init(void) { + static bool is_initialised = false; + if (!is_initialised) { + is_initialised = true; + + // Try releasing special pins for a short time + gpio_set_pin_input(SPI_SCK_PIN); + gpio_set_pin_input(SPI_MOSI_PIN); + gpio_set_pin_input(SPI_MISO_PIN); + + chThdSleepMilliseconds(10); + + palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_MODE_ALTERNATE(SPI_SCK_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST | PAL_WB32_CURRENT_LEVEL3); + palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_MODE_ALTERNATE(SPI_MOSI_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST); + palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), PAL_MODE_ALTERNATE(SPI_MISO_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST); + } +} + +#endif + +void keyboard_pre_init_kb(void) { + setPinOutput(B13); + writePinHigh(B13); +}