1 /* Copyright 2017 Fred Sundvik
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #if defined(VISUALIZER_ENABLE)
19 #include "animations.h"
20 #include "visualizer.h"
22 #include "lcd_keyframes.h"
24 #ifdef LCD_BACKLIGHT_ENABLE
25 #include "lcd_backlight_keyframes.h"
28 #ifdef BACKLIGHT_ENABLE
29 #include "led_keyframes.h"
32 #include "visualizer_keyframes.h"
35 #if defined(LCD_ENABLE) || defined(LCD_BACKLIGHT_ENABLE) || defined(BACKLIGHT_ENABLE)
37 static bool keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) {
39 lcd_keyframe_enable(animation, state);
41 #ifdef LCD_BACKLIGHT_ENABLE
42 backlight_keyframe_enable(animation, state);
44 #ifdef BACKLIGHT_ENABLE
45 led_keyframe_enable(animation, state);
50 static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) {
52 lcd_keyframe_disable(animation, state);
54 #ifdef LCD_BACKLIGHT_ENABLE
55 backlight_keyframe_disable(animation, state);
57 #ifdef BACKLIGHT_ENABLE
58 led_keyframe_disable(animation, state);
63 static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t* state) {
65 #ifdef LCD_BACKLIGHT_ENABLE
66 ret |= backlight_keyframe_animate_color(animation, state);
68 #ifdef BACKLIGHT_ENABLE
69 ret |= led_keyframe_fade_in_all(animation, state);
74 static bool keyframe_fade_out(keyframe_animation_t* animation, visualizer_state_t* state) {
76 #ifdef LCD_BACKLIGHT_ENABLE
77 ret |= backlight_keyframe_animate_color(animation, state);
79 #ifdef BACKLIGHT_ENABLE
80 ret |= led_keyframe_fade_out_all(animation, state);
86 // Don't worry, if the startup animation is long, you can use the keyboard like normal
88 keyframe_animation_t default_startup_animation = {
91 .frame_lengths = {0, 0, gfxMillisecondsToTicks(5000)},
94 lcd_keyframe_draw_logo,
99 keyframe_animation_t default_suspend_animation = {
102 .frame_lengths = {0, gfxMillisecondsToTicks(1000), 0},
104 lcd_keyframe_display_layer_text,
111 #if defined(BACKLIGHT_ENABLE)
112 #define CROSSFADE_TIME 1000
113 #define GRADIENT_TIME 3000
115 keyframe_animation_t led_test_animation = {
119 gfxMillisecondsToTicks(1000), // fade in
120 gfxMillisecondsToTicks(1000), // no op (leds on)
121 gfxMillisecondsToTicks(1000), // fade out
122 gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
123 gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in)
124 gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
125 gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom
127 gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
128 gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out)
129 gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
130 gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom
132 gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
136 led_keyframe_fade_in_all,
137 keyframe_no_operation,
138 led_keyframe_fade_out_all,
139 led_keyframe_crossfade,
140 led_keyframe_left_to_right_gradient,
141 led_keyframe_crossfade,
142 led_keyframe_top_to_bottom_gradient,
143 led_keyframe_mirror_orientation,
144 led_keyframe_crossfade,
145 led_keyframe_left_to_right_gradient,
146 led_keyframe_crossfade,
147 led_keyframe_top_to_bottom_gradient,
148 led_keyframe_normal_orientation,
149 led_keyframe_crossfade,