logo

qmk_firmware

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

raindrops_anim.h (1469B)


  1. #ifdef ENABLE_RGB_MATRIX_RAINDROPS
  2. RGB_MATRIX_EFFECT(RAINDROPS)
  3. # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
  4. static void raindrops_set_color(uint8_t i, effect_params_t* params) {
  5. if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return;
  6. hsv_t hsv = rgb_matrix_config.hsv;
  7. // Take the shortest path between hues
  8. int16_t deltaH = ((hsv.h + 180) % 360 - hsv.h) / 4;
  9. if (deltaH > 127) {
  10. deltaH -= 256;
  11. } else if (deltaH < -127) {
  12. deltaH += 256;
  13. }
  14. hsv.h += (deltaH * random8_max(3));
  15. rgb_t rgb = rgb_matrix_hsv_to_rgb(hsv);
  16. rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
  17. }
  18. bool RAINDROPS(effect_params_t* params) {
  19. static uint16_t index = RGB_MATRIX_LED_COUNT + 1;
  20. // Periodic trigger for LED change
  21. if ((params->iter == 0) && (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0)) {
  22. index = random8_max(RGB_MATRIX_LED_COUNT);
  23. }
  24. RGB_MATRIX_USE_LIMITS(led_min, led_max);
  25. if (params->init) {
  26. for (uint8_t i = led_min; i < led_max; i++) {
  27. raindrops_set_color(i, params);
  28. }
  29. }
  30. // Change LED once and set index out of range till next trigger
  31. else if (led_min <= index && index < led_max) {
  32. raindrops_set_color(index, params);
  33. index = RGB_MATRIX_LED_COUNT + 1;
  34. }
  35. return rgb_matrix_check_finished_leds(led_max);
  36. }
  37. # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
  38. #endif // ENABLE_RGB_MATRIX_RAINDROPS