summaryrefslogtreecommitdiff
path: root/users/drashna/rgb_stuff.c
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2021-07-26 17:59:49 -0700
committerGitHub <noreply@github.com>2021-07-26 17:59:49 -0700
commiteb46c954dcf99d842967cc6095827316ffddd291 (patch)
tree69f0a5ade629b63731c246888c0e067312e0970f /users/drashna/rgb_stuff.c
parent368efb5d2b834d995ba24cd23349327bab02918b (diff)
[Keymap] Drashna's Defaults cleanup (#13722)
Diffstat (limited to 'users/drashna/rgb_stuff.c')
-rw-r--r--users/drashna/rgb_stuff.c94
1 files changed, 66 insertions, 28 deletions
diff --git a/users/drashna/rgb_stuff.c b/users/drashna/rgb_stuff.c
index 1665638cf1..8a0866539e 100644
--- a/users/drashna/rgb_stuff.c
+++ b/users/drashna/rgb_stuff.c
@@ -28,7 +28,7 @@ void rgblight_sethsv_default_helper(uint8_t index) { rgblight_sethsv_at(rgblight
static rgblight_fadeout lights[RGBLED_NUM];
/* Handler for fading/twinkling effect */
-void scan_rgblight_fadeout(void) { // Don't effing change this function .... rgblight_sethsv is supppppper intensive
+void scan_rgblight_fadeout(void) { // Don't effing change this function .... rgblight_sethsv is supppppper intensive
bool litup = false;
for (uint8_t light_index = 0; light_index < RGBLED_NUM; ++light_index) {
@@ -38,15 +38,21 @@ void scan_rgblight_fadeout(void) { // Don't effing change this function .... rgb
if (light->life) {
light->life -= 1;
- if (get_highest_layer(layer_state) == 0) { sethsv(light->hue + rand() % 0xF, 255, light->life, (LED_TYPE *)&led[light_index]); }
+ if (get_highest_layer(layer_state) == 0) {
+ sethsv(light->hue + rand() % 0xF, 255, light->life, (LED_TYPE *)&led[light_index]);
+ }
light->timer = sync_timer_read();
} else {
- if (light->enabled && get_highest_layer(layer_state) == 0) { rgblight_sethsv_default_helper(light_index); }
+ if (light->enabled && get_highest_layer(layer_state) == 0) {
+ rgblight_sethsv_default_helper(light_index);
+ }
litup = light->enabled = false;
}
}
}
- if (litup && get_highest_layer(layer_state) == 0) { rgblight_set(); }
+ if (litup && get_highest_layer(layer_state) == 0) {
+ rgblight_set();
+ }
}
/* Triggers a LED to fade/twinkle.
@@ -92,7 +98,9 @@ void start_rgb_light(void) {
bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record) {
uint16_t temp_keycode = keycode;
// Filter out the actual keycode from MT and LT keys.
- if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { temp_keycode &= 0xFF; }
+ if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
+ temp_keycode &= 0xFF;
+ }
switch (temp_keycode) {
# ifdef RGBLIGHT_TWINKLE
@@ -102,9 +110,11 @@ bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record) {
case KC_KP_SLASH ... KC_KP_DOT:
case KC_F13 ... KC_F24:
case KC_AUDIO_MUTE ... KC_MEDIA_REWIND:
- if (record->event.pressed) { start_rgb_light(); }
+ if (record->event.pressed) {
+ start_rgb_light();
+ }
break;
-# endif // RGBLIGHT_TWINKLE
+# endif // RGBLIGHT_TWINKLE
}
return true;
}
@@ -119,7 +129,9 @@ static uint16_t rgblight_startup_loop_timer;
void keyboard_post_init_rgb_light(void) {
# if defined(RGBLIGHT_STARTUP_ANIMATION)
is_enabled = rgblight_is_enabled();
- if (userspace_config.rgb_layer_change) { rgblight_enable_noeeprom(); }
+ if (userspace_config.rgb_layer_change) {
+ rgblight_enable_noeeprom();
+ }
if (rgblight_is_enabled()) {
layer_state_set_rgb_light(layer_state);
old_hue = rgblight_get_hue();
@@ -133,7 +145,7 @@ void keyboard_post_init_rgb_light(void) {
void matrix_scan_rgb_light(void) {
# ifdef RGBLIGHT_TWINKLE
scan_rgblight_fadeout();
-# endif // RGBLIGHT_ENABLE
+# endif // RGBLIGHT_ENABLE
# if defined(RGBLIGHT_STARTUP_ANIMATION)
if (is_rgblight_startup && is_keyboard_master()) {
@@ -144,8 +156,12 @@ void matrix_scan_rgb_light(void) {
rgblight_startup_loop_timer = sync_timer_read();
if (counter == 255) {
is_rgblight_startup = false;
- if (!is_enabled) { rgblight_disable_noeeprom(); }
- if (userspace_config.rgb_layer_change) { layer_state_set_rgb_light(layer_state); }
+ if (!is_enabled) {
+ rgblight_disable_noeeprom();
+ }
+ if (userspace_config.rgb_layer_change) {
+ layer_state_set_rgb_light(layer_state);
+ }
}
}
}
@@ -162,26 +178,48 @@ layer_state_t layer_state_set_rgb_light(layer_state_t state) {
# ifdef RGBLIGHT_ENABLE
if (userspace_config.rgb_layer_change) {
switch (get_highest_layer(state | default_layer_state)) {
- case _MACROS: // mouse
- if (!layer_state_cmp(state, _GAMEPAD) && !layer_state_cmp(state, _DIABLO)) { rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_BREATHING + 3); }
+ case _MOUSE: // mouse
+ if (!layer_state_cmp(state, _GAMEPAD) && !layer_state_cmp(state, _DIABLO)) {
+# if defined(RGBLIGHT_EFFECT_TWINKLE)
+ rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_TWINKLE + 5);
+# else
+ rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_BREATHING + 3);
+# endif
+ }
+ break;
+ case _MEDIA:
+ rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_KNIGHT + 1);
+ break;
+ case _GAMEPAD:
+ rgblight_set_hsv_and_mode(HSV_ORANGE, RGBLIGHT_MODE_SNAKE + 2);
+ break;
+ case _DIABLO:
+ rgblight_set_hsv_and_mode(HSV_RED, RGBLIGHT_MODE_BREATHING + 3);
+ break;
+ case _RAISE:
+ rgblight_set_hsv_and_mode(HSV_YELLOW, RGBLIGHT_MODE_BREATHING + 3);
+ break;
+ case _LOWER:
+ rgblight_set_hsv_and_mode(HSV_GREEN, RGBLIGHT_MODE_BREATHING + 3);
+ break;
+ case _ADJUST:
+ rgblight_set_hsv_and_mode(HSV_RED, RGBLIGHT_MODE_KNIGHT + 2);
+ break;
+ case _DEFAULT_LAYER_1:
+ rgblight_set_hsv_and_mode(DEFAULT_LAYER_1_HSV, RGBLIGHT_MODE_STATIC_LIGHT);
+ break;
+ case _DEFAULT_LAYER_2:
+ rgblight_set_hsv_and_mode(DEFAULT_LAYER_2_HSV, RGBLIGHT_MODE_STATIC_LIGHT);
+ break;
+ case _DEFAULT_LAYER_3:
+ rgblight_set_hsv_and_mode(DEFAULT_LAYER_3_HSV, RGBLIGHT_MODE_STATIC_LIGHT);
+ break;
+ case _DEFAULT_LAYER_4:
+ rgblight_set_hsv_and_mode(DEFAULT_LAYER_4_HSV, RGBLIGHT_MODE_STATIC_LIGHT);
break;
- case _MEDIA: rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_KNIGHT + 1); break;
- case _GAMEPAD: rgblight_set_hsv_and_mode(HSV_ORANGE, RGBLIGHT_MODE_SNAKE + 2); break;
- case _DIABLO: rgblight_set_hsv_and_mode(HSV_RED, RGBLIGHT_MODE_BREATHING + 3); break;
- case _RAISE: rgblight_set_hsv_and_mode(HSV_YELLOW, RGBLIGHT_MODE_BREATHING + 3); break;
- case _LOWER: rgblight_set_hsv_and_mode(HSV_GREEN, RGBLIGHT_MODE_BREATHING + 3); break;
- case _ADJUST: rgblight_set_hsv_and_mode(HSV_RED, RGBLIGHT_MODE_KNIGHT + 2); break;
- case _COLEMAK: rgblight_set_hsv_and_mode(HSV_MAGENTA, RGBLIGHT_MODE_STATIC_LIGHT); break;
- case _DVORAK: rgblight_set_hsv_and_mode(HSV_SPRINGGREEN, RGBLIGHT_MODE_STATIC_LIGHT); break;
- case _WORKMAN: rgblight_set_hsv_and_mode(HSV_GOLDENROD, RGBLIGHT_MODE_STATIC_LIGHT); break;
- case _NORMAN: rgblight_set_hsv_and_mode(HSV_CORAL, RGBLIGHT_MODE_STATIC_LIGHT); break;
- case _MALTRON: rgblight_set_hsv_and_mode(HSV_YELLOW, RGBLIGHT_MODE_STATIC_LIGHT); break;
- case _EUCALYN: rgblight_set_hsv_and_mode(HSV_PINK, RGBLIGHT_MODE_STATIC_LIGHT); break;
- case _CARPLAX: rgblight_set_hsv_and_mode(HSV_BLUE, RGBLIGHT_MODE_STATIC_LIGHT); break;
- default: rgblight_set_hsv_and_mode(HSV_CYAN, RGBLIGHT_MODE_STATIC_LIGHT); break;
}
}
-# endif // RGBLIGHT_ENABLE
+# endif // RGBLIGHT_ENABLE
return state;
}