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.

102 lines
3.8 KiB

[Keymap] Cleanup and updating of drashna keymap code (#11516) * Update other keyboards for rgb matrix changes * Remove customized bootmagic code * Fix corne layout compilation error * Fix compiler errors with all keymaps * Add Simple Visualizer for ergodox infinity * Fix compile issue with Corne * Fix keymap stuff * Add alias for mouse layer * Add Halmak Keyboard layout * Updates for Kyria * Add support for oled interval * Change RGB stuff [CHANGE] Fix coexistence issues * Fix rgb_stuff * Add custom ploopyco mouse keymap * Decrease default dwell time * Updates based on last breaking changes update * Disable command on dactyl * Update ergodox to use proper commands for rgb matrix indicators * Update all rgb matrix indicator functions * Update rules for dactyl-manuform * Reduce wait time for mouse layer off event * Add more info to logger * Add wrappers for get_tapping term * Move version.h include into only file that actually needs it * Update rgb sleep stuff * Update key print function * Change DM keymap settings * Change pin for DM Manuform * Add Proton C stuff for Corne keymap * more arm corne tinkering * Even more arm stuff for corne * Cleanup corne stuff * redirect default keymap to drashna because I am a very bad man * change corne rgb priority * Update tractyl manuform to not conflict * Add more secret stuff * more dactyl tweaks * Add more options to split transport * Changes of oled support * Change split settings * Improve keylogger formatting more * tweak oled stuff * Oled and such tweaks * Reduce brightness due to leds * Decrease brightness more * Only run layer code if master
3 years ago
[Keymap] Cleanup and updating of drashna keymap code (#11516) * Update other keyboards for rgb matrix changes * Remove customized bootmagic code * Fix corne layout compilation error * Fix compiler errors with all keymaps * Add Simple Visualizer for ergodox infinity * Fix compile issue with Corne * Fix keymap stuff * Add alias for mouse layer * Add Halmak Keyboard layout * Updates for Kyria * Add support for oled interval * Change RGB stuff [CHANGE] Fix coexistence issues * Fix rgb_stuff * Add custom ploopyco mouse keymap * Decrease default dwell time * Updates based on last breaking changes update * Disable command on dactyl * Update ergodox to use proper commands for rgb matrix indicators * Update all rgb matrix indicator functions * Update rules for dactyl-manuform * Reduce wait time for mouse layer off event * Add more info to logger * Add wrappers for get_tapping term * Move version.h include into only file that actually needs it * Update rgb sleep stuff * Update key print function * Change DM keymap settings * Change pin for DM Manuform * Add Proton C stuff for Corne keymap * more arm corne tinkering * Even more arm stuff for corne * Cleanup corne stuff * redirect default keymap to drashna because I am a very bad man * change corne rgb priority * Update tractyl manuform to not conflict * Add more secret stuff * more dactyl tweaks * Add more options to split transport * Changes of oled support * Change split settings * Improve keylogger formatting more * tweak oled stuff * Oled and such tweaks * Reduce brightness due to leds * Decrease brightness more * Only run layer code if master
3 years ago
[Keymap] Cleanup and updating of drashna keymap code (#11516) * Update other keyboards for rgb matrix changes * Remove customized bootmagic code * Fix corne layout compilation error * Fix compiler errors with all keymaps * Add Simple Visualizer for ergodox infinity * Fix compile issue with Corne * Fix keymap stuff * Add alias for mouse layer * Add Halmak Keyboard layout * Updates for Kyria * Add support for oled interval * Change RGB stuff [CHANGE] Fix coexistence issues * Fix rgb_stuff * Add custom ploopyco mouse keymap * Decrease default dwell time * Updates based on last breaking changes update * Disable command on dactyl * Update ergodox to use proper commands for rgb matrix indicators * Update all rgb matrix indicator functions * Update rules for dactyl-manuform * Reduce wait time for mouse layer off event * Add more info to logger * Add wrappers for get_tapping term * Move version.h include into only file that actually needs it * Update rgb sleep stuff * Update key print function * Change DM keymap settings * Change pin for DM Manuform * Add Proton C stuff for Corne keymap * more arm corne tinkering * Even more arm stuff for corne * Cleanup corne stuff * redirect default keymap to drashna because I am a very bad man * change corne rgb priority * Update tractyl manuform to not conflict * Add more secret stuff * more dactyl tweaks * Add more options to split transport * Changes of oled support * Change split settings * Improve keylogger formatting more * tweak oled stuff * Oled and such tweaks * Reduce brightness due to leds * Decrease brightness more * Only run layer code if master
3 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. #include "drashna.h"
  17. #include "rgb_matrix.h"
  18. #include "lib/lib8tion/lib8tion.h"
  19. extern led_config_t g_led_config;
  20. static uint32_t hypno_timer;
  21. #if defined(SPLIT_KEYBOARD) || defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_crkbd)
  22. # define RGB_MATRIX_REST_MODE RGB_MATRIX_CYCLE_OUT_IN_DUAL
  23. #else
  24. # define RGB_MATRIX_REST_MODE RGB_MATRIX_CYCLE_OUT_IN
  25. #endif
  26. void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode, uint8_t speed, uint8_t led_type, uint8_t led_min, uint8_t led_max) {
  27. HSV hsv = {hue, sat, val};
  28. if (hsv.v > rgb_matrix_get_val()) {
  29. hsv.v = rgb_matrix_get_val();
  30. }
  31. switch (mode) {
  32. case 1: // breathing
  33. {
  34. uint16_t time = scale16by8(g_rgb_timer, speed / 8);
  35. hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
  36. RGB rgb = hsv_to_rgb(hsv);
  37. for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
  38. if (HAS_FLAGS(g_led_config.flags[i], led_type)) {
  39. RGB_MATRIX_INDICATOR_SET_COLOR(i, rgb.r, rgb.g, rgb.b);
  40. }
  41. }
  42. break;
  43. }
  44. default: // Solid Color
  45. {
  46. RGB rgb = hsv_to_rgb(hsv);
  47. for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
  48. if (HAS_FLAGS(g_led_config.flags[i], led_type)) {
  49. RGB_MATRIX_INDICATOR_SET_COLOR(i, rgb.r, rgb.g, rgb.b);
  50. }
  51. }
  52. break;
  53. }
  54. }
  55. }
  56. __attribute__((weak)) void rgb_matrix_indicator_keymap(void) {}
  57. void matrix_scan_rgb_matrix(void) {
  58. #if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
  59. if (userspace_config.rgb_matrix_idle_anim && rgb_matrix_get_mode() == RGB_MATRIX_TYPING_HEATMAP && sync_timer_elapsed32(hypno_timer) > 15000) {
  60. rgb_matrix_mode_noeeprom(RGB_MATRIX_REST_MODE);
  61. }
  62. #endif
  63. rgb_matrix_indicator_keymap();
  64. }
  65. void keyboard_post_init_rgb_matrix(void) {
  66. #if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
  67. if (userspace_config.rgb_matrix_idle_anim) {
  68. rgb_matrix_mode_noeeprom(RGB_MATRIX_REST_MODE);
  69. }
  70. #endif
  71. }
  72. bool process_record_user_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
  73. #if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
  74. hypno_timer = sync_timer_read32();
  75. if (userspace_config.rgb_matrix_idle_anim && rgb_matrix_get_mode() == RGB_MATRIX_REST_MODE) {
  76. rgb_matrix_mode_noeeprom(RGB_MATRIX_TYPING_HEATMAP);
  77. }
  78. #endif
  79. switch (keycode) {
  80. case RGB_IDL: // This allows me to use underglow as layer indication, or as normal
  81. #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
  82. if (record->event.pressed) {
  83. userspace_config.rgb_matrix_idle_anim ^= 1;
  84. dprintf("RGB Matrix Idle Animation [EEPROM]: %u\n", userspace_config.rgb_matrix_idle_anim);
  85. eeconfig_update_user(userspace_config.raw);
  86. if (userspace_config.rgb_matrix_idle_anim) {
  87. rgb_matrix_mode_noeeprom(RGB_MATRIX_TYPING_HEATMAP);
  88. }
  89. }
  90. #endif
  91. break;
  92. }
  93. return true;
  94. }