jellybean_raindrops_anim.h 935 B

123456789101112131415161718192021222324252627282930
  1. #pragma once
  2. #ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
  3. extern rgb_counters_t g_rgb_counters;
  4. extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
  5. extern rgb_config_t rgb_matrix_config;
  6. static void jellybean_raindrops_set_color(int i) {
  7. HSV hsv = { rand() & 0xFF , rand() & 0xFF, rgb_matrix_config.val };
  8. RGB rgb = hsv_to_rgb(hsv);
  9. rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
  10. }
  11. bool rgb_matrix_jellybean_raindrops(effect_params_t* params) {
  12. if (!params->init) {
  13. // Change one LED every tick, make sure speed is not 0
  14. if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 5 == 0) {
  15. jellybean_raindrops_set_color(rand() % DRIVER_LED_TOTAL);
  16. }
  17. return false;
  18. }
  19. RGB_MATRIX_USE_LIMITS(led_min, led_max);
  20. for (int i = led_min; i < led_max; i++) {
  21. jellybean_raindrops_set_color(i);
  22. }
  23. return led_max < DRIVER_LED_TOTAL;
  24. }
  25. #endif // DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS