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 b6de4d39e..d238c2065 100644 --- a/users/drashna/rgb_stuff.c +++ b/users/drashna/rgb_stuff.c | |||
| @@ -2,8 +2,11 @@ | |||
| 2 | #include "rgb_stuff.h" | 2 | #include "rgb_stuff.h" |
| 3 | #include "eeprom.h" | 3 | #include "eeprom.h" |
| 4 | 4 | ||
| 5 | #if defined(RGBLIGHT_ENABLE) | ||
| 5 | extern rgblight_config_t rgblight_config; | 6 | extern rgblight_config_t rgblight_config; |
| 6 | extern userspace_config_t userspace_config; | 7 | #elif defined(RGB_MATRIX_ENABLE) |
| 8 | extern rgb_config_t rgb_matrix_config; | ||
| 9 | #endif | ||
| 7 | 10 | ||
| 8 | #ifdef RGBLIGHT_ENABLE | 11 | #ifdef RGBLIGHT_ENABLE |
| 9 | void rgblight_sethsv_default_helper(uint8_t index) { | 12 | void rgblight_sethsv_default_helper(uint8_t index) { |
| @@ -209,7 +212,7 @@ bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) { | |||
| 209 | return true; break; | 212 | return true; break; |
| 210 | #endif // RGBLIGHT_TWINKLE | 213 | #endif // RGBLIGHT_TWINKLE |
| 211 | case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal | 214 | case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal |
| 212 | #ifdef RGBLIGHT_ENABLE | 215 | #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) |
| 213 | if (record->event.pressed) { | 216 | if (record->event.pressed) { |
| 214 | userspace_config.rgb_layer_change ^= 1; | 217 | userspace_config.rgb_layer_change ^= 1; |
| 215 | xprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change); | 218 | 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) { | |||
| 237 | 240 | ||
| 238 | 241 | ||
| 239 | 242 | ||
| 240 | void matrix_init_rgb(void) { | 243 | void matrix_init_rgb(void) { |
| 241 | 244 | ||
| 242 | if (userspace_config.rgb_layer_change) { | 245 | // #ifdef RGBLIGHT_ENABLE |
| 243 | rgblight_init(); | 246 | // if (userspace_config.rgb_layer_change) { |
| 244 | rgblight_enable_noeeprom(); | 247 | // rgblight_enable_noeeprom(); |
| 245 | switch (biton32(eeconfig_read_default_layer())) { | 248 | // switch (biton32(eeconfig_read_default_layer())) { |
| 246 | case _COLEMAK: | 249 | // case _COLEMAK: |
| 247 | rgblight_sethsv_noeeprom_magenta(); break; | 250 | // rgblight_sethsv_noeeprom_magenta(); break; |
| 248 | case _DVORAK: | 251 | // case _DVORAK: |
| 249 | rgblight_sethsv_noeeprom_springgreen(); break; | 252 | // rgblight_sethsv_noeeprom_springgreen(); break; |
| 250 | case _WORKMAN: | 253 | // case _WORKMAN: |
| 251 | rgblight_sethsv_noeeprom_goldenrod(); break; | 254 | // rgblight_sethsv_noeeprom_goldenrod(); break; |
| 252 | default: | 255 | // default: |
| 253 | rgblight_sethsv_noeeprom_cyan(); break; | 256 | // rgblight_sethsv_noeeprom_cyan(); break; |
| 254 | } | 257 | // } |
| 255 | rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT); | 258 | // rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT); |
| 256 | } | 259 | // } |
| 257 | } | 260 | // #endif |
| 261 | } | ||
| 258 | 262 | ||
| 259 | void matrix_scan_rgb(void) { | 263 | void matrix_scan_rgb(void) { |
| 260 | #ifdef RGBLIGHT_TWINKLE | 264 | #ifdef RGBLIGHT_TWINKLE |
| @@ -270,7 +274,6 @@ void matrix_scan_rgb(void) { | |||
| 270 | 274 | ||
| 271 | uint32_t layer_state_set_rgb(uint32_t state) { | 275 | uint32_t layer_state_set_rgb(uint32_t state) { |
| 272 | #ifdef RGBLIGHT_ENABLE | 276 | #ifdef RGBLIGHT_ENABLE |
| 273 | static bool has_ran; | ||
| 274 | if (userspace_config.rgb_layer_change) { | 277 | if (userspace_config.rgb_layer_change) { |
| 275 | switch (biton32(state)) { | 278 | switch (biton32(state)) { |
| 276 | case _MACROS: | 279 | case _MACROS: |
| @@ -312,12 +315,7 @@ uint32_t layer_state_set_rgb(uint32_t state) { | |||
| 312 | default: | 315 | default: |
| 313 | rgblight_sethsv_noeeprom_cyan(); break; | 316 | rgblight_sethsv_noeeprom_cyan(); break; |
| 314 | } | 317 | } |
| 315 | if (has_ran) { | 318 | 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 |
| 316 | biton32(state) == _MODS ? rgblight_mode(RGBLIGHT_MODE_BREATHING) : rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT); // if _MODS layer is on, then breath to denote it | ||
| 317 | } else { | ||
| 318 | 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 | ||
| 319 | has_ran = true; | ||
| 320 | } | ||
| 321 | break; | 319 | break; |
| 322 | } | 320 | } |
| 323 | // layer_state_set_indicator(); // Runs every scan, so need to call this here .... since I can't get it working "right" anyhow | 321 | // 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) { | |||
| 326 | 324 | ||
| 327 | return state; | 325 | return state; |
| 328 | } | 326 | } |
| 327 | |||
| 328 | uint32_t default_layer_state_set_rgb(uint32_t state) { | ||
| 329 | #ifdef RGBLIGHT_ENABLE | ||
| 330 | if (userspace_config.rgb_layer_change) { | ||
| 331 | rgblight_config_t temp_rgblight_config = rgblight_config; | ||
| 332 | switch (biton32(state)) { | ||
| 333 | case _COLEMAK: | ||
| 334 | temp_rgblight_config.hue = 300; | ||
| 335 | temp_rgblight_config.val = 255; | ||
| 336 | temp_rgblight_config.sat = 255; | ||
| 337 | temp_rgblight_config.mode = 1; | ||
| 338 | break; | ||
| 339 | case _DVORAK: | ||
| 340 | temp_rgblight_config.hue = 150; | ||
| 341 | temp_rgblight_config.val = 255; | ||
| 342 | temp_rgblight_config.sat = 255; | ||
| 343 | temp_rgblight_config.mode = 1; | ||
| 344 | case _WORKMAN: | ||
| 345 | temp_rgblight_config.hue = 43; | ||
| 346 | temp_rgblight_config.val = 218; | ||
| 347 | temp_rgblight_config.sat = 218; | ||
| 348 | temp_rgblight_config.mode = 1; | ||
| 349 | default: | ||
| 350 | temp_rgblight_config.hue = 180; | ||
| 351 | temp_rgblight_config.val = 255; | ||
| 352 | temp_rgblight_config.sat = 255; | ||
| 353 | temp_rgblight_config.mode = 1; | ||
| 354 | } | ||
| 355 | if (temp_rgblight_config.raw != eeconfig_read_rgblight()) { | ||
| 356 | 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); | ||
| 357 | eeconfig_update_rgblight(temp_rgblight_config.raw); | ||
| 358 | } | ||
| 359 | } | ||
| 360 | #endif // RGBLIGHT_ENABLE | ||
| 361 | return state; | ||
| 362 | } | ||
