diff options
author | Florian Didron <fdidron@users.noreply.github.com> | 2019-05-20 15:56:09 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-20 15:56:09 +0900 |
commit | 5b346419c752a73a71e7490a1be02876cc196f25 (patch) | |
tree | 4ab9bbdeaf620f7948c390792af2d1967c45bc9a /quantum/rgb_matrix_animations/rainbow_beacon_anim.h | |
parent | fd7caea42e845127582fc16055cda412fe3aa22e (diff) | |
parent | 0315ef645b069b19bbd48e70504326a1ec3c8cef (diff) |
Merge branch 'master' into audio_click_delay
Diffstat (limited to 'quantum/rgb_matrix_animations/rainbow_beacon_anim.h')
-rw-r--r-- | quantum/rgb_matrix_animations/rainbow_beacon_anim.h | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h index 3c15e64ab6..061cac837c 100644 --- a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h @@ -1,24 +1,14 @@ -#pragma once #ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON +RGB_MATRIX_EFFECT(RAINBOW_BEACON) +#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -extern rgb_counters_t g_rgb_counters; -extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; -extern rgb_config_t rgb_matrix_config; - -bool rgb_matrix_rainbow_beacon(effect_params_t* params) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); +static void RAINBOW_BEACON_math(HSV* hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { + hsv->h = ((g_led_config.point[i].y - k_rgb_matrix_center.y) * 2 * cos + (g_led_config.point[i].x - k_rgb_matrix_center.x) * 2 * sin) / 128 + rgb_matrix_config.hue; +} - HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val }; - uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); - int16_t cos_value = 2 * (cos8(time) - 128); - int16_t sin_value = 2 * (sin8(time) - 128); - for (uint8_t i = led_min; i < led_max; i++) { - point_t point = g_rgb_leds[i].point; - hsv.h = ((point.y - 32) * cos_value + (point.x - 112) * sin_value) / 128 + rgb_matrix_config.hue; - RGB rgb = hsv_to_rgb(hsv); - rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); - } - return led_max < DRIVER_LED_TOTAL; +bool RAINBOW_BEACON(effect_params_t* params) { + return effect_runner_sin_cos_i(params, &RAINBOW_BEACON_math); } +#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS #endif // DISABLE_RGB_MATRIX_RAINBOW_BEACON |