Skip to content

Commit

Permalink
Use RGB_MATRIX
Browse files Browse the repository at this point in the history
Apparently there's an issue
qmk/qmk_firmware#24725 where the RGB underglow
messes with split keyboards in newest master. This can be worked around
by a few things, one of them is just using RGB_MATRIX instead.

This setup now works like before, but using RGB_MATRIX
  • Loading branch information
callebjorkell committed Dec 18, 2024
1 parent 72bc1c1 commit d5a4d60
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 17 deletions.
22 changes: 20 additions & 2 deletions keyboards/splitkb/kyria/rev3/keymaps/nrgizer/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,23 @@
#endif
#endif

#ifdef RGB_MATRIX_ENABLE
#define ENABLE_RGB_MATRIX_BREATHING
#define ENABLE_RGB_MATRIX_SOLID_COLOR
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
#define ENABLE_RGB_MATRIX_TYPING_HEATMAP
#define ENABLE_RGB_MATRIX_RAINBOW_BEACON

#define RGB_MATRIX_TYPING_HEATMAP_DECREASE_DELAY_MS 50
#ifndef RGB_MATRIX_MAXIMUM_BRIGHTNESS
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 175
#endif
#define RGB_MATRIX_SLEEP
#endif

// https://docs.qmk.fm/config_options#behaviors-that-can-be-configured
#define TAPPING_TERM_PER_KEY
#define TAPPING_TERM 210
#define TAPPING_TERM 190

#define ENCODER_RESOLUTION 2

Expand All @@ -48,4 +63,7 @@

// Allows media codes to properly register in macros and rotary encoder code
#define TAP_CODE_DELAY 10
#define DYNAMIC_MACRO_NO_NESTING

// Dynamic macros https://docs.qmk.fm/features/dynamic_macros#customization
#define DYNAMIC_MACRO_NO_NESTING // Do not allow macros inside of macros
#define DYNAMIC_MACRO_SIZE 256 // Default 128
73 changes: 60 additions & 13 deletions keyboards/splitkb/kyria/rev3/keymaps/nrgizer/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

[_SHORT] = LAYOUT(
_______, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______,
#ifdef RGB_MATRIX_ENABLE
_______, _______, DM_REC1, DM_RSTP, DM_PLY1, _______, RM_TOGG, RM_SATU, RM_HUEU, RM_VALU, RM_NEXT, _______,
_______, _______, DM_REC2, DM_RSTP, DM_PLY2, _______,_______, _______, _______, _______, _______, RM_SATD, RM_HUED, RM_VALD, RM_PREV, _______,
#else
_______, _______, DM_REC1, DM_RSTP, DM_PLY1, _______, RGB_TOG, RGB_SAI, RGB_HUI, RGB_VAI, RGB_MOD, _______,
_______, _______, DM_REC2, DM_RSTP, DM_PLY2, _______,_______, _______, _______, _______, _______, RGB_SAD, RGB_HUD, RGB_VAD, RGB_RMOD, _______,
#endif
HUE_TOG, LOCK_1P, SHOW_1P,_______, _______, _______, _______, _______, _______, _______
),

Expand Down Expand Up @@ -211,27 +216,57 @@ tap_dance_action_t tap_dance_actions[] = {
[TD_LAYER] = ACTION_TAP_DANCE_FN(dance_lang),
};

#ifdef RGB_MATRIX_ENABLE
void keyboard_post_init_user(void) {
rgb_matrix_enable_noeeprom();
rgb_matrix_sethsv_noeeprom(HSV_BASE);
rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR);
}

layer_state_t layer_state_set_user(layer_state_t state) {
switch(get_highest_layer(state)) {
case _RUNNER:
rgb_matrix_mode_noeeprom(RGB_MATRIX_BREATHING); // Set to breathing mode
break;
default:
rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR); // Set to solid color mode
break;
}
return state;
}

// this is called every time the LEDs are to be refreshed. Changing modes here will cause issues, as it will
// cause another refresh.
bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
switch(get_highest_layer(layer_state|default_layer_state)) {
case _RUNNER:
rgb_matrix_sethsv_noeeprom(HSV_BLUE);
break;
case _SWE:
rgb_matrix_sethsv_noeeprom(HSV_SWE);
break;
case _DAN:
rgb_matrix_sethsv_noeeprom(HSV_DAN);
break;
default:
rgb_matrix_sethsv_noeeprom(HSV_BASE);
break;
}
return false;
}
#endif

uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case LT(_NAVS,KC_T):
return TAPPING_TERM - 45;
case LSFT_T(KC_A):
return TAPPING_TERM + 50;
return TAPPING_TERM + 40;
default:
return TAPPING_TERM;
}
}

void rgblight_set_hsv_and_mode(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode) {
rgblight_mode_noeeprom(mode);
wait_us(175); // Add a slight delay between color and mode to ensure it's processed correctly
rgblight_sethsv_noeeprom(hue, sat, val);
}

void keyboard_post_init_user(void){
rgblight_enable_noeeprom();
rgblight_set_hsv_and_mode(HSV_BASE, RGBLIGHT_MODE_STATIC_LIGHT);
}

#ifdef LEADER_ENABLE
void leader_end_user(void) {
Expand All @@ -248,10 +283,22 @@ void leader_end_user(void) {
}
#endif

#ifdef RGBLIGHT_ENABLE
void rgblight_set_hsv_and_mode(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode) {
rgblight_mode_noeeprom(mode);
rgblight_sethsv_noeeprom(hue, sat, val);
}

void keyboard_post_init_user(void){
rgblight_enable_noeeprom();
rgblight_set_hsv_and_mode(HSV_BASE, RGBLIGHT_MODE_STATIC_LIGHT);
}
#endif

uint8_t last_rgb_layer = _COLEMAK;

layer_state_t layer_state_set_user(layer_state_t state) {
#ifdef RGBLIGHT_ENABLE
layer_state_t layer_state_set_user(layer_state_t state) {
uint8_t layer = get_highest_layer(state);

if (last_rgb_layer != layer) {
Expand All @@ -274,9 +321,9 @@ layer_state_t layer_state_set_user(layer_state_t state) {
break;
}
}
#endif
return state;
}
#endif

#ifdef OLED_ENABLE
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
Expand Down
4 changes: 2 additions & 2 deletions keyboards/splitkb/kyria/rev3/keymaps/nrgizer/rules.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
OLED_ENABLE = yes
ENCODER_ENABLE = yes # Enables the use of one or more encoders
RGB_MATRIX_ENABLE = no # Disable keyboard RGB matrix, as it is enabled by default on rev3
RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
RGB_MATRIX_ENABLE = yes # Enable keyboard RGB matrix
RGBLIGHT_ENABLE = no # Disable keyboard RGB underglow
LEADER_ENABLE = yes # Enable the Leader Key feature
MOUSEKEY_ENABLE = no
TAP_DANCE_ENABLE = yes
Expand Down

0 comments on commit d5a4d60

Please sign in to comment.