aboutsummaryrefslogtreecommitdiff
path: root/quantum/visualizer/led_backlight_keyframes.c
diff options
context:
space:
mode:
authorskullY <skullydazed@gmail.com>2019-08-30 11:19:03 -0700
committerskullydazed <skullydazed@users.noreply.github.com>2019-08-30 15:01:52 -0700
commitb624f32f944acdc59dcb130674c09090c5c404cb (patch)
treebc13adbba137d122d9a2c2fb2fafcbb08ac10e25 /quantum/visualizer/led_backlight_keyframes.c
parent61af76a10d00aba185b8338604171de490a13e3b (diff)
downloadqmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.tar.gz
qmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.zip
clang-format changes
Diffstat (limited to 'quantum/visualizer/led_backlight_keyframes.c')
-rw-r--r--quantum/visualizer/led_backlight_keyframes.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/quantum/visualizer/led_backlight_keyframes.c b/quantum/visualizer/led_backlight_keyframes.c
index eb3f5561d..d81117d2b 100644
--- a/quantum/visualizer/led_backlight_keyframes.c
+++ b/quantum/visualizer/led_backlight_keyframes.c
@@ -27,15 +27,15 @@ SOFTWARE.
27 27
28static uint8_t fade_led_color(keyframe_animation_t* animation, int from, int to) { 28static uint8_t fade_led_color(keyframe_animation_t* animation, int from, int to) {
29 int frame_length = animation->frame_lengths[animation->current_frame]; 29 int frame_length = animation->frame_lengths[animation->current_frame];
30 int current_pos = frame_length - animation->time_left_in_frame; 30 int current_pos = frame_length - animation->time_left_in_frame;
31 int delta = to - from; 31 int delta = to - from;
32 int luma = (delta * current_pos) / frame_length; 32 int luma = (delta * current_pos) / frame_length;
33 luma += from; 33 luma += from;
34 return luma; 34 return luma;
35} 35}
36 36
37static void keyframe_fade_all_leds_from_to(keyframe_animation_t* animation, uint8_t from, uint8_t to) { 37static void keyframe_fade_all_leds_from_to(keyframe_animation_t* animation, uint8_t from, uint8_t to) {
38 uint8_t luma = fade_led_color(animation, from, to); 38 uint8_t luma = fade_led_color(animation, from, to);
39 color_t color = LUMA2COLOR(luma); 39 color_t color = LUMA2COLOR(luma);
40 gdispGClear(LED_DISPLAY, color); 40 gdispGClear(LED_DISPLAY, color);
41} 41}
@@ -48,10 +48,10 @@ static uint8_t crossfade_start_frame[NUM_ROWS][NUM_COLS];
48static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS]; 48static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS];
49 49
50static uint8_t compute_gradient_color(float t, float index, float num) { 50static uint8_t compute_gradient_color(float t, float index, float num) {
51 const float two_pi = M_PI * 2.0f; 51 const float two_pi = M_PI * 2.0f;
52 float normalized_index = (1.0f - index / (num - 1.0f)) * two_pi; 52 float normalized_index = (1.0f - index / (num - 1.0f)) * two_pi;
53 float x = t * two_pi + normalized_index; 53 float x = t * two_pi + normalized_index;
54 float v = 0.5 * (cosf(x) + 1.0f); 54 float v = 0.5 * (cosf(x) + 1.0f);
55 return (uint8_t)(255.0f * v); 55 return (uint8_t)(255.0f * v);
56} 56}
57 57
@@ -70,9 +70,9 @@ bool led_backlight_keyframe_fade_out_all(keyframe_animation_t* animation, visual
70bool led_backlight_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { 70bool led_backlight_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state) {
71 (void)state; 71 (void)state;
72 float frame_length = animation->frame_lengths[animation->current_frame]; 72 float frame_length = animation->frame_lengths[animation->current_frame];
73 float current_pos = frame_length - animation->time_left_in_frame; 73 float current_pos = frame_length - animation->time_left_in_frame;
74 float t = current_pos / frame_length; 74 float t = current_pos / frame_length;
75 for (int i=0; i< NUM_COLS; i++) { 75 for (int i = 0; i < NUM_COLS; i++) {
76 uint8_t color = compute_gradient_color(t, i, NUM_COLS); 76 uint8_t color = compute_gradient_color(t, i, NUM_COLS);
77 gdispGDrawLine(LED_DISPLAY, i, 0, i, NUM_ROWS - 1, LUMA2COLOR(color)); 77 gdispGDrawLine(LED_DISPLAY, i, 0, i, NUM_ROWS - 1, LUMA2COLOR(color));
78 } 78 }
@@ -82,9 +82,9 @@ bool led_backlight_keyframe_left_to_right_gradient(keyframe_animation_t* animati
82bool led_backlight_keyframe_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { 82bool led_backlight_keyframe_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state) {
83 (void)state; 83 (void)state;
84 float frame_length = animation->frame_lengths[animation->current_frame]; 84 float frame_length = animation->frame_lengths[animation->current_frame];
85 float current_pos = frame_length - animation->time_left_in_frame; 85 float current_pos = frame_length - animation->time_left_in_frame;
86 float t = current_pos / frame_length; 86 float t = current_pos / frame_length;
87 for (int i=0; i< NUM_ROWS; i++) { 87 for (int i = 0; i < NUM_ROWS; i++) {
88 uint8_t color = compute_gradient_color(t, i, NUM_ROWS); 88 uint8_t color = compute_gradient_color(t, i, NUM_ROWS);
89 gdispGDrawLine(LED_DISPLAY, 0, i, NUM_COLS - 1, i, LUMA2COLOR(color)); 89 gdispGDrawLine(LED_DISPLAY, 0, i, NUM_COLS - 1, i, LUMA2COLOR(color));
90 } 90 }
@@ -92,9 +92,9 @@ bool led_backlight_keyframe_top_to_bottom_gradient(keyframe_animation_t* animati
92} 92}
93 93
94static void copy_current_led_state(uint8_t* dest) { 94static void copy_current_led_state(uint8_t* dest) {
95 for (int i=0;i<NUM_ROWS;i++) { 95 for (int i = 0; i < NUM_ROWS; i++) {
96 for (int j=0;j<NUM_COLS;j++) { 96 for (int j = 0; j < NUM_COLS; j++) {
97 dest[i*NUM_COLS + j] = gdispGGetPixelColor(LED_DISPLAY, j, i); 97 dest[i * NUM_COLS + j] = gdispGGetPixelColor(LED_DISPLAY, j, i);
98 } 98 }
99 } 99 }
100} 100}
@@ -105,9 +105,9 @@ bool led_backlight_keyframe_crossfade(keyframe_animation_t* animation, visualize
105 run_next_keyframe(animation, state); 105 run_next_keyframe(animation, state);
106 copy_current_led_state(&crossfade_end_frame[0][0]); 106 copy_current_led_state(&crossfade_end_frame[0][0]);
107 } 107 }
108 for (int i=0;i<NUM_ROWS;i++) { 108 for (int i = 0; i < NUM_ROWS; i++) {
109 for (int j=0;j<NUM_COLS;j++) { 109 for (int j = 0; j < NUM_COLS; j++) {
110 color_t color = LUMA2COLOR(fade_led_color(animation, crossfade_start_frame[i][j], crossfade_end_frame[i][j])); 110 color_t color = LUMA2COLOR(fade_led_color(animation, crossfade_start_frame[i][j], crossfade_end_frame[i][j]));
111 gdispGDrawPixel(LED_DISPLAY, j, i, color); 111 gdispGDrawPixel(LED_DISPLAY, j, i, color);
112 } 112 }
113 } 113 }