logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

rgb_matrix_kb.inc (2365B)


  1. /*
  2. Copyright 2020 Evy Dekkers
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. RGB_MATRIX_EFFECT(indicator_gradient)
  15. RGB_MATRIX_EFFECT(indicator_cycle_all)
  16. RGB_MATRIX_EFFECT(indicator_static)
  17. #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
  18. static bool indicator_static(effect_params_t* params) {
  19. hsv_t hsv = rgb_matrix_config.hsv;
  20. rgb_t rgb = hsv_to_rgb(hsv);
  21. RGB_MATRIX_USE_LIMITS(led_min, led_max);
  22. for (uint8_t i = led_min; i < 74; i++) {
  23. rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
  24. }
  25. for (uint8_t i = 74; i < led_max; i++) {
  26. rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
  27. }
  28. return rgb_matrix_check_finished_leds(led_max);
  29. }
  30. bool effect_runner_indicator(effect_params_t* params, i_f effect_func) {
  31. RGB_MATRIX_USE_LIMITS(led_min, led_max);
  32. uint8_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 16);
  33. for (uint8_t i = led_min; i < led_max; i++) {
  34. if (i < 74) {
  35. rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
  36. } else {
  37. RGB_MATRIX_TEST_LED_FLAGS();
  38. rgb_t rgb = hsv_to_rgb(effect_func(rgb_matrix_config.hsv, (i - 74), time));
  39. rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
  40. }
  41. }
  42. return rgb_matrix_check_finished_leds(led_max);
  43. }
  44. static hsv_t indicator_gradient_math(hsv_t hsv, uint8_t i, uint8_t time) {
  45. hsv.h = g_led_config.point[i].x - time;
  46. return hsv;
  47. }
  48. bool indicator_gradient(effect_params_t* params) { return effect_runner_indicator(params, &indicator_gradient_math); }
  49. static hsv_t indicator_cycle_all_math(hsv_t hsv, uint8_t i, uint8_t time) {
  50. hsv.h = time;
  51. return hsv;
  52. }
  53. bool indicator_cycle_all(effect_params_t* params) { return effect_runner_indicator(params, &indicator_cycle_all_math); }
  54. #endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS