]> git.donarmstrong.com Git - qmk_firmware.git/blob - quantum/visualizer/default_animations.c
qwerty_code_friendly: configurable left thumb
[qmk_firmware.git] / quantum / visualizer / default_animations.c
1 /* Copyright 2017 Fred Sundvik
2  *
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.
7  *
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.
12  *
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/>.
15  */
16
17 #if defined(VISUALIZER_ENABLE)
18
19 #include "default_animations.h"
20 #include "visualizer.h"
21 #ifdef LCD_ENABLE
22 #include "lcd_keyframes.h"
23 #endif
24 #ifdef LCD_BACKLIGHT_ENABLE
25 #include "lcd_backlight_keyframes.h"
26 #endif
27
28 #ifdef BACKLIGHT_ENABLE
29 #include "led_backlight_keyframes.h"
30 #endif
31
32 #include "visualizer_keyframes.h"
33
34
35 #if defined(LCD_ENABLE) || defined(LCD_BACKLIGHT_ENABLE) || defined(BACKLIGHT_ENABLE)
36
37 static bool keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) {
38 #ifdef LCD_ENABLE
39     lcd_keyframe_enable(animation, state);
40 #endif
41 #ifdef LCD_BACKLIGHT_ENABLE
42     lcd_backlight_keyframe_enable(animation, state);
43 #endif
44 #ifdef BACKLIGHT_ENABLE
45     led_backlight_keyframe_enable(animation, state);
46 #endif
47     return false;
48 }
49
50 static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) {
51 #ifdef LCD_ENABLE
52     lcd_keyframe_disable(animation, state);
53 #endif
54 #ifdef LCD_BACKLIGHT_ENABLE
55     lcd_backlight_keyframe_disable(animation, state);
56 #endif
57 #ifdef BACKLIGHT_ENABLE
58     led_backlight_keyframe_disable(animation, state);
59 #endif
60     return false;
61 }
62
63 static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t* state) {
64     bool ret = false;
65 #ifdef LCD_BACKLIGHT_ENABLE
66     ret |= lcd_backlight_keyframe_animate_color(animation, state);
67 #endif
68 #ifdef BACKLIGHT_ENABLE
69     ret |= led_backlight_keyframe_fade_in_all(animation, state);
70 #endif
71     return ret;
72 }
73
74 static bool keyframe_fade_out(keyframe_animation_t* animation, visualizer_state_t* state) {
75     bool ret = false;
76 #ifdef LCD_BACKLIGHT_ENABLE
77     ret |= lcd_backlight_keyframe_animate_color(animation, state);
78 #endif
79 #ifdef BACKLIGHT_ENABLE
80     ret |= led_backlight_keyframe_fade_out_all(animation, state);
81 #endif
82     return ret;
83 }
84
85
86 // Don't worry, if the startup animation is long, you can use the keyboard like normal
87 // during that time
88 keyframe_animation_t default_startup_animation = {
89 #if LCD_ENABLE
90     .num_frames = 3,
91 #else
92     .num_frames = 2,
93 #endif
94     .loop = false,
95     .frame_lengths = {
96         0, 
97 #if LCD_ENABLE
98         0, 
99 #endif
100         gfxMillisecondsToTicks(5000)},
101     .frame_functions = {
102             keyframe_enable,
103 #if LCD_ENABLE
104             lcd_keyframe_draw_logo,
105 #endif
106             keyframe_fade_in,
107     },
108 };
109
110 keyframe_animation_t default_suspend_animation = {
111 #if LCD_ENABLE
112     .num_frames = 3,
113 #else
114     .num_frames = 2,
115 #endif
116     .loop = false,
117     .frame_lengths = {
118 #if LCD_ENABLE
119         0, 
120 #endif
121         gfxMillisecondsToTicks(1000), 
122         0},
123     .frame_functions = {
124 #if LCD_ENABLE
125             lcd_keyframe_display_layer_text,
126 #endif
127             keyframe_fade_out,
128             keyframe_disable,
129     },
130 };
131 #endif
132
133 #if defined(BACKLIGHT_ENABLE)
134 #define CROSSFADE_TIME 1000
135 #define GRADIENT_TIME 3000
136
137 keyframe_animation_t led_test_animation = {
138     .num_frames = 14,
139     .loop = true,
140     .frame_lengths = {
141         gfxMillisecondsToTicks(1000), // fade in
142         gfxMillisecondsToTicks(1000), // no op (leds on)
143         gfxMillisecondsToTicks(1000), // fade out
144         gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
145         gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in)
146         gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
147         gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom
148         0,           // mirror leds
149         gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
150         gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out)
151         gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
152         gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom
153         0,           // normal leds
154         gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
155
156     },
157     .frame_functions = {
158         led_backlight_keyframe_fade_in_all,
159         keyframe_no_operation,
160         led_backlight_keyframe_fade_out_all,
161         led_backlight_keyframe_crossfade,
162         led_backlight_keyframe_left_to_right_gradient,
163         led_backlight_keyframe_crossfade,
164         led_backlight_keyframe_top_to_bottom_gradient,
165         led_backlight_keyframe_mirror_orientation,
166         led_backlight_keyframe_crossfade,
167         led_backlight_keyframe_left_to_right_gradient,
168         led_backlight_keyframe_crossfade,
169         led_backlight_keyframe_top_to_bottom_gradient,
170         led_backlight_keyframe_normal_orientation,
171         led_backlight_keyframe_crossfade,
172     },
173 };
174 #endif
175
176 #endif