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.

50 lines
2.0 KiB

  1. /* Copyright 2021 Choi Byungyoon <byungyoonc@gmail.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. #if defined(RGB_MATRIX_KEYPRESSES)
  17. RGB_MATRIX_EFFECT(saturated_solid_multisplash)
  18. # if defined(RGB_MATRIX_CUSTOM_EFFECT_IMPLS)
  19. static bool saturated_solid_multisplash(effect_params_t* params) {
  20. RGB_MATRIX_USE_LIMITS(led_min, led_max);
  21. uint8_t count = g_last_hit_tracker.count;
  22. for (uint8_t i = led_min; i < led_max; i++) {
  23. RGB_MATRIX_TEST_LED_FLAGS();
  24. HSV hsv = rgb_matrix_config.hsv;
  25. hsv.v = 0;
  26. for (uint8_t j = 0; j < count; j++) {
  27. int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
  28. int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
  29. uint8_t dist = sqrt16(dx * dx + dy * dy);
  30. uint16_t tick = scale16by8(g_last_hit_tracker.tick[j], qadd8(rgb_matrix_config.speed, 1));
  31. uint16_t effect = tick - dist;
  32. if (effect > 255) effect = 255;
  33. uint16_t vdiff = scale16by8(255 - effect, 255 - dist);
  34. hsv.v = qadd8(hsv.v, vdiff);
  35. hsv.s = qsub8(hsv.s, qsub8(127, effect));
  36. }
  37. hsv.v = scale8(hsv.v, rgb_matrix_config.hsv.v);
  38. RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
  39. rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
  40. }
  41. return led_max < DRIVER_LED_TOTAL;
  42. }
  43. # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
  44. #endif // RGB_MATRIX_KEYPRESSES