logo

qmk_firmware

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

flower_blooming_anim.h (2188B)


  1. /* Copyright 2023 HorrorTroll <https://github.com/HorrorTroll>
  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 ENABLE_RGB_MATRIX_FLOWER_BLOOMING
  17. RGB_MATRIX_EFFECT(FLOWER_BLOOMING)
  18. # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
  19. typedef hsv_t (*flower_blooming_f)(hsv_t hsv, uint8_t i, uint8_t time);
  20. bool effect_runner_bloom(effect_params_t* params, flower_blooming_f effect_func) {
  21. RGB_MATRIX_USE_LIMITS(led_min, led_max);
  22. uint8_t time = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed / 10, 1));
  23. for (uint8_t i = led_min; i < led_max; i++) {
  24. RGB_MATRIX_TEST_LED_FLAGS();
  25. if (g_led_config.point[i].y > k_rgb_matrix_center.y) {
  26. rgb_t bgr = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time));
  27. rgb_matrix_set_color(i, bgr.b, bgr.g, bgr.r);
  28. } else {
  29. rgb_t rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time));
  30. rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
  31. }
  32. }
  33. return rgb_matrix_check_finished_leds(led_max);
  34. }
  35. static hsv_t FLOWER_BLOOMING_math(hsv_t hsv, uint8_t i, uint8_t time) {
  36. if (g_led_config.point[i].y > k_rgb_matrix_center.y)
  37. hsv.h = g_led_config.point[i].x * 3 - g_led_config.point[i].y * 3 + time;
  38. else
  39. hsv.h = g_led_config.point[i].x * 3 - g_led_config.point[i].y * 3 - time;
  40. return hsv;
  41. }
  42. bool FLOWER_BLOOMING(effect_params_t* params) {
  43. return effect_runner_bloom(params, &FLOWER_BLOOMING_math);
  44. }
  45. # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
  46. #endif // ENABLE_RGB_MATRIX_FLOWER_BLOOMING