logo

qmk_firmware

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

starlight_dual_sat_anim.h (1472B)


  1. #ifdef ENABLE_RGB_MATRIX_STARLIGHT_DUAL_SAT
  2. RGB_MATRIX_EFFECT(STARLIGHT_DUAL_SAT)
  3. # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
  4. static void set_starlight_dual_sat_color(uint8_t i, effect_params_t* params) {
  5. if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return;
  6. uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8);
  7. hsv_t hsv = rgb_matrix_config.hsv;
  8. hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
  9. hsv.s = hsv.s + random8_max(31);
  10. rgb_t rgb = rgb_matrix_hsv_to_rgb(hsv);
  11. rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
  12. }
  13. bool STARLIGHT_DUAL_SAT(effect_params_t* params) {
  14. static uint16_t index = RGB_MATRIX_LED_COUNT + 1;
  15. // Periodic trigger for LED change
  16. if ((params->iter == 0) && (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 5)) % 5 == 0)) {
  17. index = random8_max(RGB_MATRIX_LED_COUNT);
  18. }
  19. RGB_MATRIX_USE_LIMITS(led_min, led_max);
  20. if (params->init) {
  21. for (uint8_t i = led_min; i < led_max; i++) {
  22. set_starlight_dual_sat_color(i, params);
  23. }
  24. }
  25. // Change LED once and set index out of range till next trigger
  26. else if (led_min <= index && index < led_max) {
  27. set_starlight_dual_sat_color(index, params);
  28. index = RGB_MATRIX_LED_COUNT + 1;
  29. }
  30. return rgb_matrix_check_finished_leds(led_max);
  31. }
  32. # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
  33. #endif // ENABLE_RGB_MATRIX_STARLIGHT_DUAL_SAT