Skip to content

Commit

Permalink
fix f401_rgb
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaxin96 committed May 22, 2021
1 parent 4f29f66 commit bf24140
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 15 deletions.
44 changes: 31 additions & 13 deletions keyboards/yandrstudio/zv48/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions keyboards/yandrstudio/zv48/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
67 changes: 67 additions & 0 deletions keyboards/yandrstudio/zv48/zv48.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit bf24140

Please sign in to comment.