From bf24140d7b4dcff2afbcdab5a0f30026c96b7f06 Mon Sep 17 00:00:00 2001 From: jiaxin96 <572673807@qq.com> Date: Sat, 22 May 2021 22:30:50 +0800 Subject: [PATCH] fix f401_rgb --- keyboards/yandrstudio/zv48/config.h | 44 +++++++++++++------ keyboards/yandrstudio/zv48/rules.mk | 6 ++- keyboards/yandrstudio/zv48/zv48.c | 67 +++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 15 deletions(-) diff --git a/keyboards/yandrstudio/zv48/config.h b/keyboards/yandrstudio/zv48/config.h index 15ff8c4e8438..588c02a52de2 100644 --- a/keyboards/yandrstudio/zv48/config.h +++ b/keyboards/yandrstudio/zv48/config.h @@ -40,8 +40,8 @@ */ #define MATRIX_COL_PINS { B15, B10, B0, A5, A4, A3 } #define MATRIX_ROW_PINS { A10, A15, B3, B4 } -#define MATRIX_COL_PINS_RIGHT { B10, B15, A10, A15, B3, B4 } -#define MATRIX_ROW_PINS_RIGHT { B0, A5, A4, A3 } +// #define MATRIX_COL_PINS_RIGHT { B10, B15, A10, A15, B3, B4 } +// #define MATRIX_ROW_PINS_RIGHT { B0, A5, A4, A3 } /* COL2ROW, ROW2COL*/ #define DIODE_DIRECTION COL2ROW @@ -59,17 +59,35 @@ #define ENCODERS_PAD_A { B5 } #define ENCODERS_PAD_B { A2 } -#define RGB_DI_PIN B1 -#define RGBLED_NUM 48 -#define RGBLED_SPLIT {24, 24} -#define RGBLIGHT_LIMIT_VAL 120 -#define RGBLIGHT_ANIMATIONS - -#define WS2812_PWM_DRIVER PWMD3 -#define WS2812_PWM_CHANNEL 4 -#define WS2812_PWM_PAL_MODE 2 -#define WS2812_DMA_STREAM STM32_DMA1_STREAM2 -#define WS2812_DMA_CHANNEL 5 +// #define RGB_DI_PIN A7 +// #define RGBLED_NUM 2 +// #define RGBLED_SPLIT {1, 1} +// #define RGBLIGHT_LIMIT_VAL 120 +// #define RGBLIGHT_ANIMATIONS + +/* RGN Matrix */ +#ifdef RGB_MATRIX_ENABLE + +# define RGB_DI_PIN A7 +# define RGBLED_NUM 2 +# define DRIVER_LED_TOTAL RGBLED_NUM + +# define WS2812_PWM_DRIVER PWMD3 +# define WS2812_PWM_CHANNEL 4 +# define WS2812_PWM_PAL_MODE 2 +# define WS2812_DMA_STREAM STM32_DMA1_STREAM2 +# define WS2812_DMA_CHANNEL 5 + +# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 180 +# define RGBLIGHT_VAL_STEP 18 +# define RGB_DISABLE_WHEN_USB_SUSPENDED true +# define RGB_MATRIX_CENTER { 32, 96 } +# define RGB_MATRIX_KEYPRESSES +# define RGB_MATRIX_FRAMEBUFFER_EFFECTS + +#endif + + /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ #define DEBOUNCE 5 diff --git a/keyboards/yandrstudio/zv48/rules.mk b/keyboards/yandrstudio/zv48/rules.mk index 86bcad8a0c8b..20c2a110f7ea 100644 --- a/keyboards/yandrstudio/zv48/rules.mk +++ b/keyboards/yandrstudio/zv48/rules.mk @@ -12,13 +12,15 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work NKRO_ENABLE = yes # USB Nkey Rollover BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality -RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow +# RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow +RGB_MATRIX_ENABLE = yes +RGB_MATRIX_DRIVER = WS2812 ENCODER_ENABLE = yes # Enable rotary encoder support MIDI_ENABLE = no # MIDI support BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID AUDIO_ENABLE = no # Audio output -SPLIT_KEYBOARD = yes +# SPLIT_KEYBOARD = yes SERIAL_DRIVER = usart WS2812_DRIVER = pwm diff --git a/keyboards/yandrstudio/zv48/zv48.c b/keyboards/yandrstudio/zv48/zv48.c index 3c3d1ab77793..4d88817d0e62 100644 --- a/keyboards/yandrstudio/zv48/zv48.c +++ b/keyboards/yandrstudio/zv48/zv48.c @@ -25,3 +25,70 @@ void keyboard_pre_init_kb(void){ keyboard_pre_init_user(); } + + +#ifdef RGB_MATRIX_ENABLE +led_config_t g_led_config = { + { + { 0, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, \ + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, \ + { NO_LED, 1, NO_LED, NO_LED, NO_LED, NO_LED }, \ + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, \ + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, \ + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, \ + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, \ + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED } \ + }, + { + // LED Index to Physical Position + {0, 0}, {16, 0} + + }, + { + // LED Index to Flag + 4, 4 + } +}; + +// void rgb_matrix_indicators_kb(void) { +// if (rgb_matrix_is_enabled()) { +// if (biton32(layer_state) == 1) { // UPPER_LAYER = BLUE +// rgb_matrix_set_color(57, 100, 0, 0); +// rgb_matrix_set_color(58, 0, 100, 0); +// rgb_matrix_set_color(60, 100, 0, 0); +// rgb_matrix_set_color(61, 100, 0, 0); +// } else if (biton32(layer_state) == 2) +// { +// rgb_matrix_set_color(57, 100, 0, 0); +// rgb_matrix_set_color(58, 100, 0, 0); +// rgb_matrix_set_color(60, 0, 100, 0); +// rgb_matrix_set_color(61, 100, 0, 0); +// } else if (biton32(layer_state) == 3) +// { +// rgb_matrix_set_color(57, 100, 0, 0); +// rgb_matrix_set_color(58, 100, 0, 0); +// rgb_matrix_set_color(60, 100, 0, 0); +// rgb_matrix_set_color(61, 0, 100, 0); +// } else if (biton32(layer_state) != 0) +// { +// rgb_matrix_set_color(57, 150, 0, 0); +// rgb_matrix_set_color(58, 150, 0, 0); +// rgb_matrix_set_color(60, 150, 0, 0); +// rgb_matrix_set_color(61, 150, 0, 0); +// } +// } +// } + +#endif + +#ifdef RGB_DISABLE_WHEN_USB_SUSPENDED +void suspend_power_down_kb(void) { + rgb_matrix_set_suspend_state(true); + suspend_power_down_user(); +} + +void suspend_wakeup_init_kb(void) { + rgb_matrix_set_suspend_state(false); + suspend_wakeup_init_user(); +} +#endif