aboutsummaryrefslogtreecommitdiff
path: root/quantum/visualizer/visualizer.c
diff options
context:
space:
mode:
authorFred Sundvik <fsundvik@gmail.com>2017-04-05 08:48:30 +0300
committerFred Sundvik <fsundvik@gmail.com>2017-04-09 18:34:59 +0300
commit5ba228b684a32c1099efc6207842a56ff102961a (patch)
treea68e2930b8dc1d661e097574b5a51ff49b465216 /quantum/visualizer/visualizer.c
parent5815c5d317b02d688990980fdf01848e81247c21 (diff)
downloadqmk_firmware-5ba228b684a32c1099efc6207842a56ff102961a.tar.gz
qmk_firmware-5ba228b684a32c1099efc6207842a56ff102961a.zip
Move LCD backlight keyframes to its own file
Diffstat (limited to 'quantum/visualizer/visualizer.c')
-rw-r--r--quantum/visualizer/visualizer.c46
1 files changed, 0 insertions, 46 deletions
diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c
index 514d7c44e..6ebd806e4 100644
--- a/quantum/visualizer/visualizer.c
+++ b/quantum/visualizer/visualizer.c
@@ -228,52 +228,6 @@ bool keyframe_no_operation(keyframe_animation_t* animation, visualizer_state_t*
228 return false; 228 return false;
229} 229}
230 230
231#ifdef LCD_BACKLIGHT_ENABLE
232bool keyframe_animate_backlight_color(keyframe_animation_t* animation, visualizer_state_t* state) {
233 int frame_length = animation->frame_lengths[animation->current_frame];
234 int current_pos = frame_length - animation->time_left_in_frame;
235 uint8_t t_h = LCD_HUE(state->target_lcd_color);
236 uint8_t t_s = LCD_SAT(state->target_lcd_color);
237 uint8_t t_i = LCD_INT(state->target_lcd_color);
238 uint8_t p_h = LCD_HUE(state->prev_lcd_color);
239 uint8_t p_s = LCD_SAT(state->prev_lcd_color);
240 uint8_t p_i = LCD_INT(state->prev_lcd_color);
241
242 uint8_t d_h1 = t_h - p_h; //Modulo arithmetic since we want to wrap around
243 int d_h2 = t_h - p_h;
244 // Chose the shortest way around
245 int d_h = abs(d_h2) < d_h1 ? d_h2 : d_h1;
246 int d_s = t_s - p_s;
247 int d_i = t_i - p_i;
248
249 int hue = (d_h * current_pos) / frame_length;
250 int sat = (d_s * current_pos) / frame_length;
251 int intensity = (d_i * current_pos) / frame_length;
252 //dprintf("%X -> %X = %X\n", p_h, t_h, hue);
253 hue += p_h;
254 sat += p_s;
255 intensity += p_i;
256 state->current_lcd_color = LCD_COLOR(hue, sat, intensity);
257 lcd_backlight_color(
258 LCD_HUE(state->current_lcd_color),
259 LCD_SAT(state->current_lcd_color),
260 LCD_INT(state->current_lcd_color));
261
262 return true;
263}
264
265bool keyframe_set_backlight_color(keyframe_animation_t* animation, visualizer_state_t* state) {
266 (void)animation;
267 state->prev_lcd_color = state->target_lcd_color;
268 state->current_lcd_color = state->target_lcd_color;
269 lcd_backlight_color(
270 LCD_HUE(state->current_lcd_color),
271 LCD_SAT(state->current_lcd_color),
272 LCD_INT(state->current_lcd_color));
273 return false;
274}
275#endif // LCD_BACKLIGHT_ENABLE
276
277bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state) { 231bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state) {
278 (void)animation; 232 (void)animation;
279 (void)state; 233 (void)state;