diff options
Diffstat (limited to 'users/drashna/rgb_stuff.c')
-rw-r--r-- | users/drashna/rgb_stuff.c | 86 |
1 files changed, 60 insertions, 26 deletions
diff --git a/users/drashna/rgb_stuff.c b/users/drashna/rgb_stuff.c index b6de4d39e5..d238c20651 100644 --- a/users/drashna/rgb_stuff.c +++ b/users/drashna/rgb_stuff.c @@ -2,8 +2,11 @@ #include "rgb_stuff.h" #include "eeprom.h" +#if defined(RGBLIGHT_ENABLE) extern rgblight_config_t rgblight_config; -extern userspace_config_t userspace_config; +#elif defined(RGB_MATRIX_ENABLE) +extern rgb_config_t rgb_matrix_config; +#endif #ifdef RGBLIGHT_ENABLE void rgblight_sethsv_default_helper(uint8_t index) { @@ -209,7 +212,7 @@ bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) { return true; break; #endif // RGBLIGHT_TWINKLE case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal -#ifdef RGBLIGHT_ENABLE +#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) if (record->event.pressed) { userspace_config.rgb_layer_change ^= 1; xprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change); @@ -237,24 +240,25 @@ bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) { -void matrix_init_rgb(void) { + void matrix_init_rgb(void) { - if (userspace_config.rgb_layer_change) { - rgblight_init(); - rgblight_enable_noeeprom(); - switch (biton32(eeconfig_read_default_layer())) { - case _COLEMAK: - rgblight_sethsv_noeeprom_magenta(); break; - case _DVORAK: - rgblight_sethsv_noeeprom_springgreen(); break; - case _WORKMAN: - rgblight_sethsv_noeeprom_goldenrod(); break; - default: - rgblight_sethsv_noeeprom_cyan(); break; - } - rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT); - } -} +// #ifdef RGBLIGHT_ENABLE +// if (userspace_config.rgb_layer_change) { +// rgblight_enable_noeeprom(); +// switch (biton32(eeconfig_read_default_layer())) { +// case _COLEMAK: +// rgblight_sethsv_noeeprom_magenta(); break; +// case _DVORAK: +// rgblight_sethsv_noeeprom_springgreen(); break; +// case _WORKMAN: +// rgblight_sethsv_noeeprom_goldenrod(); break; +// default: +// rgblight_sethsv_noeeprom_cyan(); break; +// } +// rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT); +// } +// #endif + } void matrix_scan_rgb(void) { #ifdef RGBLIGHT_TWINKLE @@ -270,7 +274,6 @@ void matrix_scan_rgb(void) { uint32_t layer_state_set_rgb(uint32_t state) { #ifdef RGBLIGHT_ENABLE - static bool has_ran; if (userspace_config.rgb_layer_change) { switch (biton32(state)) { case _MACROS: @@ -312,12 +315,7 @@ uint32_t layer_state_set_rgb(uint32_t state) { default: rgblight_sethsv_noeeprom_cyan(); break; } - if (has_ran) { - biton32(state) == _MODS ? rgblight_mode(RGBLIGHT_MODE_BREATHING) : rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT); // if _MODS layer is on, then breath to denote it - } else { - biton32(state) == _MODS ? rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING) : rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); // if _MODS layer is on, then breath to denote it - has_ran = true; - } + biton32(state) == _MODS ? rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING) : rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); // if _MODS layer is on, then breath to denote it break; } // layer_state_set_indicator(); // Runs every scan, so need to call this here .... since I can't get it working "right" anyhow @@ -326,3 +324,39 @@ uint32_t layer_state_set_rgb(uint32_t state) { return state; } + +uint32_t default_layer_state_set_rgb(uint32_t state) { +#ifdef RGBLIGHT_ENABLE + if (userspace_config.rgb_layer_change) { + rgblight_config_t temp_rgblight_config = rgblight_config; + switch (biton32(state)) { + case _COLEMAK: + temp_rgblight_config.hue = 300; + temp_rgblight_config.val = 255; + temp_rgblight_config.sat = 255; + temp_rgblight_config.mode = 1; + break; + case _DVORAK: + temp_rgblight_config.hue = 150; + temp_rgblight_config.val = 255; + temp_rgblight_config.sat = 255; + temp_rgblight_config.mode = 1; + case _WORKMAN: + temp_rgblight_config.hue = 43; + temp_rgblight_config.val = 218; + temp_rgblight_config.sat = 218; + temp_rgblight_config.mode = 1; + default: + temp_rgblight_config.hue = 180; + temp_rgblight_config.val = 255; + temp_rgblight_config.sat = 255; + temp_rgblight_config.mode = 1; + } + if (temp_rgblight_config.raw != eeconfig_read_rgblight()) { + xprintf("rgblight set default layer hsv [EEPROM]: %u,%u,%u,%u\n", temp_rgblight_config.hue, temp_rgblight_config.sat, temp_rgblight_config.val, temp_rgblight_config.mode); + eeconfig_update_rgblight(temp_rgblight_config.raw); + } + } +#endif // RGBLIGHT_ENABLE + return state; +} |