You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
4.9 KiB

[Keymap] Update to Drashna Keymaps (#5594) * Start to standardize macro timer * Update Fractal layout Specifically, limit the RGB Lighting, since it's too many for the power, and only have the KITT annimation on the front * Update Iris keymap to use I2C for transport * Remove TAP_CODE_DELAY from keyboard in favor of global setting * Remove Woodpad Since it\'s no longer in my possession * Only enable LTO on AVR boards * Run matrix_scans while doing startup light * Run matrix_scan to get split keyboard code synced properly * Fix rgb mode * Remove custom debouncing settings * Make RGB Light Startup Animation optional * Fix opt def * Remove extra tap code delay value * Fix references to keebio boards * Add support for LP Iris keyboard * Add backlight code * Make startup animation optional * Update gitlab ci script * Remove port declaration * Revert avrgcc changes to gitlab ci file * Don't re-set mods * Remove MACRO_TIMER define * Add custom name for crkbd * Add name for Prime M pad * Add names for ortho 4x12 boards * Add some additional handling for rgb init * Change thumb clusters on ergodox * Switch Orthodox to I2C * Fix Space in ergodox keymap * Use OSL for ergodox layout * Ugh, can't find a good layout * Fix typo * Fix up animation startup * Cries in AVR * Fix makefiles for ergodox ez boards * Add support for "secret songs" in my userspace * Reset debounce to 5ms for Ergodox EZ * Fix gitlab CI yaml file * More crying in AVR * Cannot use rgb light and rgb matrix at the same time due to the WS2812 rgb matrix PR until the "Coexistance" PR is merged * Update ODox for split common and i2c * Add split config * Impement Split code * Add support for xscorpion OLED code * Add OLED display config * Fix OLED screen font * Get OLED set up in vertical mode * Remove old OLED code * add per key support for crkbd * Fix split changes * RGB Tweeaks * More OLED tweaks * Fix rotation stuff * Fix more OLED stuff * Remove custom Debounce from Ergodox layout since it's no longer needed
5 years ago
  1. /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifdef RGBLIGHT_ENABLE
  17. # include "drashna.h"
  18. # include "rgb_stuff.h"
  19. # include "eeprom.h"
  20. bool has_initialized;
  21. void rgblight_sethsv_default_helper(uint8_t index) { rgblight_sethsv_at(rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val(), index); }
  22. void rgblight_set_hsv_and_mode(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode) {
  23. rgblight_sethsv_noeeprom(hue, sat, val);
  24. // wait_us(175); // Add a slight delay between color and mode to ensure it's processed correctly
  25. rgblight_mode_noeeprom(mode);
  26. }
  27. bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record) { return true; }
  28. # if defined(RGBLIGHT_STARTUP_ANIMATION)
  29. static bool is_enabled;
  30. static bool is_rgblight_startup;
  31. static HSV old_hsv;
  32. static uint8_t old_mode;
  33. static uint16_t rgblight_startup_loop_timer;
  34. # endif
  35. void keyboard_post_init_rgb_light(void) {
  36. # if defined(RGBLIGHT_STARTUP_ANIMATION)
  37. is_enabled = rgblight_is_enabled();
  38. if (userspace_config.rgb_layer_change) {
  39. layer_state_set_rgb_light(layer_state);
  40. }
  41. old_hsv = rgblight_get_hsv();
  42. old_mode = rgblight_get_mode();
  43. rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
  44. is_rgblight_startup = true;
  45. # endif
  46. if (userspace_config.rgb_layer_change) {
  47. layer_state_set_rgb_light(layer_state);
  48. }
  49. }
  50. void matrix_scan_rgb_light(void) {
  51. # if defined(RGBLIGHT_STARTUP_ANIMATION)
  52. if (is_rgblight_startup && is_keyboard_master()) {
  53. if (sync_timer_elapsed(rgblight_startup_loop_timer) > 10) {
  54. static uint8_t counter;
  55. counter++;
  56. rgblight_sethsv_noeeprom((counter + old_hsv.h) % 255, 255, 255);
  57. rgblight_startup_loop_timer = sync_timer_read();
  58. if (counter == 255) {
  59. is_rgblight_startup = false;
  60. if (userspace_config.rgb_layer_change) {
  61. layer_state_set_rgb_light(layer_state);
  62. } else {
  63. rgblight_set_hsv_and_mode(old_hsv.h, old_hsv.s, old_hsv.v, old_mode);
  64. }
  65. if (!is_enabled) {
  66. rgblight_disable_noeeprom();
  67. }
  68. }
  69. }
  70. }
  71. # endif
  72. }
  73. layer_state_t layer_state_set_rgb_light(layer_state_t state) {
  74. # ifdef RGBLIGHT_ENABLE
  75. if (userspace_config.rgb_layer_change) {
  76. switch (get_highest_layer(state | default_layer_state)) {
  77. case _MOUSE: // mouse
  78. if (!layer_state_cmp(state, _GAMEPAD) && !layer_state_cmp(state, _DIABLO)) {
  79. # if defined(RGBLIGHT_EFFECT_TWINKLE)
  80. rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_TWINKLE + 5);
  81. # else
  82. rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_BREATHING + 3);
  83. # endif
  84. }
  85. break;
  86. case _MEDIA:
  87. rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_KNIGHT + 1);
  88. break;
  89. case _GAMEPAD:
  90. rgblight_set_hsv_and_mode(HSV_ORANGE, RGBLIGHT_MODE_SNAKE + 2);
  91. break;
  92. case _DIABLO:
  93. rgblight_set_hsv_and_mode(HSV_RED, RGBLIGHT_MODE_BREATHING + 3);
  94. break;
  95. case _RAISE:
  96. rgblight_set_hsv_and_mode(HSV_YELLOW, RGBLIGHT_MODE_BREATHING + 3);
  97. break;
  98. case _LOWER:
  99. rgblight_set_hsv_and_mode(HSV_GREEN, RGBLIGHT_MODE_BREATHING + 3);
  100. break;
  101. case _ADJUST:
  102. rgblight_set_hsv_and_mode(HSV_RED, RGBLIGHT_MODE_KNIGHT + 2);
  103. break;
  104. case _DEFAULT_LAYER_1:
  105. rgblight_set_hsv_and_mode(DEFAULT_LAYER_1_HSV, RGBLIGHT_MODE_STATIC_LIGHT);
  106. break;
  107. case _DEFAULT_LAYER_2:
  108. rgblight_set_hsv_and_mode(DEFAULT_LAYER_2_HSV, RGBLIGHT_MODE_STATIC_LIGHT);
  109. break;
  110. case _DEFAULT_LAYER_3:
  111. rgblight_set_hsv_and_mode(DEFAULT_LAYER_3_HSV, RGBLIGHT_MODE_STATIC_LIGHT);
  112. break;
  113. case _DEFAULT_LAYER_4:
  114. rgblight_set_hsv_and_mode(DEFAULT_LAYER_4_HSV, RGBLIGHT_MODE_STATIC_LIGHT);
  115. break;
  116. }
  117. }
  118. # endif // RGBLIGHT_ENABLE
  119. return state;
  120. }
  121. #endif