logo

qmk_firmware

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

starlight_anim.h (1364B)


  1. #ifdef ENABLE_RGB_MATRIX_STARLIGHT
  2. RGB_MATRIX_EFFECT(STARLIGHT)
  3. # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
  4. static void set_starlight_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. rgb_t rgb = rgb_matrix_hsv_to_rgb(hsv);
  10. rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
  11. }
  12. bool STARLIGHT(effect_params_t* params) {
  13. static uint16_t index = RGB_MATRIX_LED_COUNT + 1;
  14. // Periodic trigger for LED change
  15. if ((params->iter == 0) && (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 5)) % 5 == 0)) {
  16. index = random8_max(RGB_MATRIX_LED_COUNT);
  17. }
  18. RGB_MATRIX_USE_LIMITS(led_min, led_max);
  19. if (params->init) {
  20. for (uint8_t i = led_min; i < led_max; i++) {
  21. set_starlight_color(i, params);
  22. }
  23. }
  24. // Change LED once and set index out of range till next trigger
  25. else if (led_min <= index && index < led_max) {
  26. set_starlight_color(index, params);
  27. index = RGB_MATRIX_LED_COUNT + 1;
  28. }
  29. return rgb_matrix_check_finished_leds(led_max);
  30. }
  31. # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
  32. #endif // ENABLE_RGB_MATRIX_STARLIGHT