aboutsummaryrefslogtreecommitdiffstats
path: root/users/drashna/rgb_stuff.c
diff options
context:
space:
mode:
authorGravatar Drashna Jaelre <drashna@live.com>2019-05-06 22:34:09 -0700
committerGravatar MechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-05-06 22:34:09 -0700
commitf3d5b1091d364468cd9f5510aef9e723d8542279 (patch)
tree762b8f562b1e96e42657f872fd4b04c8efaaa829 /users/drashna/rgb_stuff.c
parent7a751f114114bf3b78d5d8fc8bedf2b42b665dba (diff)
downloadqmk_firmware-f3d5b1091d364468cd9f5510aef9e723d8542279.tar.gz
[Keymap] RGB Changes for Drashna Keyboards (#5803)
* Disable a bunch of reactive modes * Enable rgb matrix for Corne Keyboard * Convert CRKBD to rgb matrix * Add Gergo keyboard layout * Make Diablo 3 tap dance better * Add basic support for Planck EZ * Fix RGB Matrix stuff * Fix keycodes for Planck EZ * Update CRKBD OLED stuff * Fix typo for sleep on ergodox glow * Improve my gergo layout * Scrolling OLED key logger! * Change gergo layout * Hnadle unicode keycodes if unicode is disabled * Disable COMMAND/CONSOLE for gergo * Fix right side control * Re-enable LTO for all platforms Since I got updated arm gcc binaries that no longer error out on lto * Update formatting to match newer community standards Poor 2 space * Re-alight startup animation to use new HUE range * Streamline gitlab ci scripts * Disabled Space Cadet * Add support for breathing table * Enable new LTO Option And clean up defines that will now be repeatitive * Remove vscode settings * Additional formatting cleanup of config.h files
Diffstat (limited to 'users/drashna/rgb_stuff.c')
-rw-r--r--users/drashna/rgb_stuff.c441
1 files changed, 202 insertions, 239 deletions
diff --git a/users/drashna/rgb_stuff.c b/users/drashna/rgb_stuff.c
index b5e145842..38e86ae0e 100644
--- a/users/drashna/rgb_stuff.c
+++ b/users/drashna/rgb_stuff.c
@@ -11,80 +11,80 @@ extern rgb_config_t rgb_matrix_config;
#ifdef RGBLIGHT_ENABLE
void rgblight_sethsv_default_helper(uint8_t index) {
- rgblight_sethsv_at(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, index);
+ rgblight_sethsv_at(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, index);
}
#endif // RGBLIGHT_ENABLE
#ifdef INDICATOR_LIGHTS
void set_rgb_indicators(uint8_t this_mod, uint8_t this_led, uint8_t this_osm) {
- if (userspace_config.rgb_layer_change && biton32(layer_state) == 0) {
- if ( (this_mod | this_osm) & MOD_MASK_SHIFT || this_led & (1<<USB_LED_CAPS_LOCK) ) {
- #ifdef SHFT_LED1
- rgblight_sethsv_at(120, 255, 255, SHFT_LED1);
- #endif // SHFT_LED1
- #ifdef SHFT_LED2
- rgblight_sethsv_at(120, 255, 255, SHFT_LED2);
- #endif // SHFT_LED2
- } else {
- #ifdef SHFT_LED1
- rgblight_sethsv_default_helper(SHFT_LED1);
- #endif // SHFT_LED1
- #ifdef SHFT_LED2
- rgblight_sethsv_default_helper(SHFT_LED2);
- #endif // SHFT_LED2
- }
- if ( (this_mod | this_osm) & MOD_MASK_CTRL) {
- #ifdef CTRL_LED1
- rgblight_sethsv_at(0, 255, 255, CTRL_LED1);
- #endif // CTRL_LED1
- #ifdef CTRL_LED2
- rgblight_sethsv_at(0, 255, 255, CTRL_LED2);
- #endif // CTRL_LED2
- } else {
- #ifdef CTRL_LED1
- rgblight_sethsv_default_helper(CTRL_LED1);
- #endif // CTRL_LED1
- #ifdef CTRL_LED2
- rgblight_sethsv_default_helper(CTRL_LED2);
- #endif // CTRL_LED2
- }
- if ( (this_mod | this_osm) & MOD_MASK_GUI) {
- #ifdef GUI_LED1
- rgblight_sethsv_at(51, 255, 255, GUI_LED1);
- #endif // GUI_LED1
- #ifdef GUI_LED2
- rgblight_sethsv_at(51, 255, 255, GUI_LED2);
- #endif // GUI_LED2
- } else {
- #ifdef GUI_LED1
- rgblight_sethsv_default_helper(GUI_LED1);
- #endif // GUI_LED1
- #ifdef GUI_LED2
- rgblight_sethsv_default_helper(GUI_LED2);
- #endif // GUI_LED2
- }
- if ( (this_mod | this_osm) & MOD_MASK_ALT) {
- #ifdef ALT_LED1
- rgblight_sethsv_at(240, 255, 255, ALT_LED1);
- #endif // ALT_LED1
- #ifdef GUI_LED2
- rgblight_sethsv_at(240, 255, 255, ALT_LED2);
- #endif // GUI_LED2
- } else {
- #ifdef GUI_LED1
- rgblight_sethsv_default_helper(ALT_LED1);
- #endif // GUI_LED1
- #ifdef GUI_LED2
- rgblight_sethsv_default_helper(ALT_LED2);
- #endif // GUI_LED2
+ if (userspace_config.rgb_layer_change && biton32(layer_state) == 0) {
+ if ( (this_mod | this_osm) & MOD_MASK_SHIFT || this_led & (1<<USB_LED_CAPS_LOCK) ) {
+ #ifdef SHFT_LED1
+ rgblight_sethsv_at(120, 255, 255, SHFT_LED1);
+ #endif // SHFT_LED1
+ #ifdef SHFT_LED2
+ rgblight_sethsv_at(120, 255, 255, SHFT_LED2);
+ #endif // SHFT_LED2
+ } else {
+ #ifdef SHFT_LED1
+ rgblight_sethsv_default_helper(SHFT_LED1);
+ #endif // SHFT_LED1
+ #ifdef SHFT_LED2
+ rgblight_sethsv_default_helper(SHFT_LED2);
+ #endif // SHFT_LED2
+ }
+ if ( (this_mod | this_osm) & MOD_MASK_CTRL) {
+ #ifdef CTRL_LED1
+ rgblight_sethsv_at(0, 255, 255, CTRL_LED1);
+ #endif // CTRL_LED1
+ #ifdef CTRL_LED2
+ rgblight_sethsv_at(0, 255, 255, CTRL_LED2);
+ #endif // CTRL_LED2
+ } else {
+ #ifdef CTRL_LED1
+ rgblight_sethsv_default_helper(CTRL_LED1);
+ #endif // CTRL_LED1
+ #ifdef CTRL_LED2
+ rgblight_sethsv_default_helper(CTRL_LED2);
+ #endif // CTRL_LED2
+ }
+ if ( (this_mod | this_osm) & MOD_MASK_GUI) {
+ #ifdef GUI_LED1
+ rgblight_sethsv_at(51, 255, 255, GUI_LED1);
+ #endif // GUI_LED1
+ #ifdef GUI_LED2
+ rgblight_sethsv_at(51, 255, 255, GUI_LED2);
+ #endif // GUI_LED2
+ } else {
+ #ifdef GUI_LED1
+ rgblight_sethsv_default_helper(GUI_LED1);
+ #endif // GUI_LED1
+ #ifdef GUI_LED2
+ rgblight_sethsv_default_helper(GUI_LED2);
+ #endif // GUI_LED2
+ }
+ if ( (this_mod | this_osm) & MOD_MASK_ALT) {
+ #ifdef ALT_LED1
+ rgblight_sethsv_at(240, 255, 255, ALT_LED1);
+ #endif // ALT_LED1
+ #ifdef GUI_LED2
+ rgblight_sethsv_at(240, 255, 255, ALT_LED2);
+ #endif // GUI_LED2
+ } else {
+ #ifdef GUI_LED1
+ rgblight_sethsv_default_helper(ALT_LED1);
+ #endif // GUI_LED1
+ #ifdef GUI_LED2
+ rgblight_sethsv_default_helper(ALT_LED2);
+ #endif // GUI_LED2
+ }
}
- }
}
void matrix_scan_indicator(void) {
- if (has_initialized) {
- set_rgb_indicators(get_mods(), host_keyboard_leds(), get_oneshot_mods());
- }
+ if (has_initialized) {
+ set_rgb_indicators(get_mods(), host_keyboard_leds(), get_oneshot_mods());
+ }
}
#endif //INDICATOR_LIGHTS
@@ -95,69 +95,71 @@ __attribute__ ((weak))
bool rgblight_twinkle_is_led_used_keymap(uint8_t index) { return false; }
bool rgblight_twinkle_is_led_used(uint8_t index) {
- switch (index) {
+ switch (index) {
#ifdef INDICATOR_LIGHTS
#ifdef SHFT_LED1
- case SHFT_LED1:
- return true;
+ case SHFT_LED1:
+ return true;
#endif //SHFT_LED1
#ifdef SHFT_LED2
- case SHFT_LED2:
- return true;
+ case SHFT_LED2:
+ return true;
#endif //SHFT_LED2
#ifdef CTRL_LED1
- case CTRL_LED1:
- return true;
+ case CTRL_LED1:
+ return true;
#endif //CTRL_LED1
#ifdef CTRL_LED2
- case CTRL_LED2:
- return true;
+ case CTRL_LED2:
+ return true;
#endif //CTRL_LED2
#ifdef GUI_LED1
- case GUI_LED1:
- return true;
+ case GUI_LED1:
+ return true;
#endif //GUI_LED1
#ifdef GUI_LED2
- case GUI_LED2:
- return true;
+ case GUI_LED2:
+ return true;
#endif //GUI_LED2
#ifdef ALT_LED1
- case ALT_LED1:
- return true;
+ case ALT_LED1:
+ return true;
#endif //ALT_LED1
#ifdef ALT_LED2
- case ALT_LED2:
- return true;
+ case ALT_LED2:
+ return true;
#endif //ALT_LED2
#endif //INDICATOR_LIGHTS
- default:
- return rgblight_twinkle_is_led_used_keymap(index);
+ default:
+ return rgblight_twinkle_is_led_used_keymap(index);
}
}
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 ) {
- if (lights[light_index].enabled && timer_elapsed(lights[light_index].timer) > 10) {
- rgblight_fadeout *light = &lights[light_index];
- litup = true;
+ bool litup = false;
+ for (uint8_t light_index = 0 ; light_index < RGBLED_NUM ; ++light_index ) {
+ if (lights[light_index].enabled && timer_elapsed(lights[light_index].timer) > 10) {
+ rgblight_fadeout *light = &lights[light_index];
+ litup = true;
- if (light->life) {
- light->life -= 1;
- if (biton32(layer_state) == 0) {
- sethsv(light->hue + rand() % 0xF, 255, light->life, (LED_TYPE *)&led[light_index]);
+ if (light->life) {
+ light->life -= 1;
+ if (biton32(layer_state) == 0) {
+ sethsv(light->hue + rand() % 0xF, 255, light->life, (LED_TYPE *)&led[light_index]);
+ }
+ light->timer = timer_read();
+ }
+ else {
+ if (light->enabled && biton32(layer_state) == 0) {
+ rgblight_sethsv_default_helper(light_index);
+ }
+ litup = light->enabled = false;
+ }
}
- light->timer = timer_read();
- }
- else {
- if (light->enabled && biton32(layer_state) == 0) { rgblight_sethsv_default_helper(light_index); }
- litup = light->enabled = false;
- }
}
- }
- if (litup && biton32(layer_state) == 0) {
- rgblight_set();
- }
+ if (litup && biton32(layer_state) == 0) {
+ rgblight_set();
+ }
}
void start_rgb_light(void) {
@@ -203,42 +205,42 @@ void start_rgb_light(void) {
bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) {
- if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
- keycode = keycode & 0xFF;
- }
- switch (keycode) {
+ if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
+ keycode = keycode & 0xFF;
+ }
+ switch (keycode) {
#ifdef RGBLIGHT_TWINKLE
- case KC_A ... KC_SLASH:
- case KC_F1 ... KC_F12:
- case KC_INSERT ... KC_UP:
- 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(); }
- return true; break;
+ case KC_A ... KC_SLASH:
+ case KC_F1 ... KC_F12:
+ case KC_INSERT ... KC_UP:
+ 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(); }
+ return true; break;
#endif // RGBLIGHT_TWINKLE
- case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal
+ case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal
#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);
- eeconfig_update_user(userspace_config.raw);
- if (userspace_config.rgb_layer_change) {
- layer_state_set(layer_state); // This is needed to immediately set the layer color (looks better)
- }
- }
+ if (record->event.pressed) {
+ userspace_config.rgb_layer_change ^= 1;
+ xprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change);
+ eeconfig_update_user(userspace_config.raw);
+ if (userspace_config.rgb_layer_change) {
+ layer_state_set(layer_state); // This is needed to immediately set the layer color (looks better)
+ }
+ }
#endif // RGBLIGHT_ENABLE
- return false; break;
+ return false; break;
#ifdef RGBLIGHT_ENABLE
- case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // quantum_keycodes.h L400 for definitions
- if (record->event.pressed) { //This disables layer indication, as it's assumed that if you're changing this ... you want that disabled
- if (userspace_config.rgb_layer_change) {
- userspace_config.rgb_layer_change = false;
- xprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change);
- eeconfig_update_user(userspace_config.raw);
- }
- }
- return true; break;
+ case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // quantum_keycodes.h L400 for definitions
+ if (record->event.pressed) { //This disables layer indication, as it's assumed that if you're changing this ... you want that disabled
+ if (userspace_config.rgb_layer_change) {
+ userspace_config.rgb_layer_change = false;
+ xprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change);
+ eeconfig_update_user(userspace_config.raw);
+ }
+ }
+ return true; break;
#endif // RGBLIGHT_ENABLE
}
return true;
@@ -248,28 +250,28 @@ bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) {
void keyboard_post_init_rgb(void) {
#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_STARTUP_ANIMATION)
- if (userspace_config.rgb_layer_change) { rgblight_enable_noeeprom(); }
- if (rgblight_config.enable) {
- layer_state_set_user(layer_state);
- uint16_t old_hue = rgblight_config.hue;
- rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
- for (uint16_t i = 360; i > 0; i--) {
- rgblight_sethsv_noeeprom( ( i + old_hue) % 360, 255, 255);
- matrix_scan();
- wait_ms(10);
+ if (userspace_config.rgb_layer_change) { rgblight_enable_noeeprom(); }
+ if (rgblight_config.enable) {
+ layer_state_set_user(layer_state);
+ uint16_t old_hue = rgblight_config.hue;
+ rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
+ for (uint16_t i = 255; i > 0; i--) {
+ rgblight_sethsv_noeeprom( ( i + old_hue) % 255, 255, 255);
+ matrix_scan();
+ wait_ms(10);
+ }
}
- }
#endif
- layer_state_set_user(layer_state);
+ layer_state_set_user(layer_state);
}
void matrix_scan_rgb(void) {
#ifdef RGBLIGHT_TWINKLE
- scan_rgblight_fadeout();
+ scan_rgblight_fadeout();
#endif // RGBLIGHT_ENABLE
#ifdef INDICATOR_LIGHTS
- matrix_scan_indicator();
+ matrix_scan_indicator();
#endif
}
@@ -277,99 +279,60 @@ void matrix_scan_rgb(void) {
uint32_t layer_state_set_rgb(uint32_t state) {
#ifdef RGBLIGHT_ENABLE
- if (userspace_config.rgb_layer_change) {
- switch (biton32(state)) {
- case _MACROS:
- rgblight_sethsv_noeeprom_orange();
- userspace_config.is_overwatch ? rgblight_mode_noeeprom(RGBLIGHT_MODE_SNAKE + 2) : rgblight_mode_noeeprom(RGBLIGHT_MODE_SNAKE + 3);
- break;
- case _MEDIA:
- rgblight_sethsv_noeeprom_chartreuse();
- rgblight_mode_noeeprom(RGBLIGHT_MODE_KNIGHT + 1);
- break;
- case _GAMEPAD:
- rgblight_sethsv_noeeprom_orange();
- rgblight_mode_noeeprom(RGBLIGHT_MODE_SNAKE + 2);
- break;
- case _DIABLO:
- rgblight_sethsv_noeeprom_red();
- rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3);
- break;
- case _RAISE:
- rgblight_sethsv_noeeprom_yellow();
- rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3);
- break;
- case _LOWER:
- rgblight_sethsv_noeeprom_green();
- rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3);
- break;
- case _ADJUST:
- rgblight_sethsv_noeeprom_red();
- rgblight_mode_noeeprom(RGBLIGHT_MODE_KNIGHT + 2);
- break;
- default: // for any other layers, or the default layer
- switch (biton32(default_layer_state)) {
- case _COLEMAK:
- rgblight_sethsv_noeeprom_magenta(); break;
- case _DVORAK:
- rgblight_sethsv_noeeprom_springgreen(); break;
- case _WORKMAN:
- rgblight_sethsv_noeeprom_goldenrod(); break;
- case _NORMAN:
- rgblight_sethsv_noeeprom_coral(); break;
- case _MALTRON:
- rgblight_sethsv_noeeprom_yellow(); break;
- case _EUCALYN:
- rgblight_sethsv_noeeprom_pink(); break;
- case _CARPLAX:
- rgblight_sethsv_noeeprom_blue(); break;
- default:
- rgblight_sethsv_noeeprom_cyan(); break;
- }
- 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;
+ if (userspace_config.rgb_layer_change) {
+ switch (biton32(state)) {
+ case _MACROS:
+ rgblight_sethsv_noeeprom_orange();
+ userspace_config.is_overwatch ? rgblight_mode_noeeprom(RGBLIGHT_MODE_SNAKE + 2) : rgblight_mode_noeeprom(RGBLIGHT_MODE_SNAKE + 3);
+ break;
+ case _MEDIA:
+ rgblight_sethsv_noeeprom_chartreuse();
+ rgblight_mode_noeeprom(RGBLIGHT_MODE_KNIGHT + 1);
+ break;
+ case _GAMEPAD:
+ rgblight_sethsv_noeeprom_orange();
+ rgblight_mode_noeeprom(RGBLIGHT_MODE_SNAKE + 2);
+ break;
+ case _DIABLO:
+ rgblight_sethsv_noeeprom_red();
+ rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3);
+ break;
+ case _RAISE:
+ rgblight_sethsv_noeeprom_yellow();
+ rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3);
+ break;
+ case _LOWER:
+ rgblight_sethsv_noeeprom_green();
+ rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3);
+ break;
+ case _ADJUST:
+ rgblight_sethsv_noeeprom_red();
+ rgblight_mode_noeeprom(RGBLIGHT_MODE_KNIGHT + 2);
+ break;
+ default: // for any other layers, or the default layer
+ switch (biton32(default_layer_state)) {
+ case _COLEMAK:
+ rgblight_sethsv_noeeprom_magenta(); break;
+ case _DVORAK:
+ rgblight_sethsv_noeeprom_springgreen(); break;
+ case _WORKMAN:
+ rgblight_sethsv_noeeprom_goldenrod(); break;
+ case _NORMAN:
+ rgblight_sethsv_noeeprom_coral(); break;
+ case _MALTRON:
+ rgblight_sethsv_noeeprom_yellow(); break;
+ case _EUCALYN:
+ rgblight_sethsv_noeeprom_pink(); break;
+ case _CARPLAX:
+ rgblight_sethsv_noeeprom_blue(); break;
+ default:
+ rgblight_sethsv_noeeprom_cyan(); break;
+ }
+ 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
- }
#endif // RGBLIGHT_ENABLE
- return state;
-}
-
-#if 0
-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;
+ return state;
}
-#endif