solid_reactive_nexus.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
  2. #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS)
  3. #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
  4. RGB_MATRIX_EFFECT(SOLID_REACTIVE_NEXUS)
  5. #endif
  6. #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS
  7. RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTINEXUS)
  8. #endif
  9. #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
  10. static bool rgb_matrix_solid_reactive_multinexus_range(uint8_t start, effect_params_t* params) {
  11. RGB_MATRIX_USE_LIMITS(led_min, led_max);
  12. HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 };
  13. uint8_t count = g_last_hit_tracker.count;
  14. for (uint8_t i = led_min; i < led_max; i++) {
  15. hsv.v = 0;
  16. for (uint8_t j = start; j < count; j++) {
  17. RGB_MATRIX_TEST_LED_FLAGS();
  18. int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
  19. int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
  20. uint8_t dist = sqrt16(dx * dx + dy * dy);
  21. int16_t dist2 = 8;
  22. uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist;
  23. if (effect > 255)
  24. effect = 255;
  25. if (dist > 72)
  26. effect = 255;
  27. if ((dx > dist2 || dx < -dist2) && (dy > dist2 || dy < -dist2))
  28. effect = 255;
  29. hsv.v = qadd8(hsv.v, 255 - effect);
  30. hsv.h = rgb_matrix_config.hue + dy / 4;
  31. }
  32. hsv.v = scale8(hsv.v, rgb_matrix_config.val);
  33. RGB rgb = hsv_to_rgb(hsv);
  34. rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
  35. }
  36. return led_max < DRIVER_LED_TOTAL;
  37. }
  38. bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) {
  39. return rgb_matrix_solid_reactive_multinexus_range(0, params);
  40. }
  41. bool SOLID_REACTIVE_NEXUS(effect_params_t* params) {
  42. return rgb_matrix_solid_reactive_multinexus_range(qsub8(g_last_hit_tracker.count, 1), params);
  43. }
  44. #endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
  45. #endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS)
  46. #endif // RGB_MATRIX_KEYREACTIVE_ENABLED