[Keymap] Romain's Preonic layout (#7067)
[jackhill/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 # if defined(LCD_ENABLE) || defined(LCD_BACKLIGHT_ENABLE) || defined(BACKLIGHT_ENABLE)
35
36 static bool keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) {
37 # ifdef LCD_ENABLE
38 lcd_keyframe_enable(animation, state);
39 # endif
40 # ifdef LCD_BACKLIGHT_ENABLE
41 lcd_backlight_keyframe_enable(animation, state);
42 # endif
43 # ifdef BACKLIGHT_ENABLE
44 led_backlight_keyframe_enable(animation, state);
45 # endif
46 return false;
47 }
48
49 static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) {
50 # ifdef LCD_ENABLE
51 lcd_keyframe_disable(animation, state);
52 # endif
53 # ifdef LCD_BACKLIGHT_ENABLE
54 lcd_backlight_keyframe_disable(animation, state);
55 # endif
56 # ifdef BACKLIGHT_ENABLE
57 led_backlight_keyframe_disable(animation, state);
58 # endif
59 return false;
60 }
61
62 static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t* state) {
63 bool ret = false;
64 # ifdef LCD_BACKLIGHT_ENABLE
65 ret |= lcd_backlight_keyframe_animate_color(animation, state);
66 # endif
67 # ifdef BACKLIGHT_ENABLE
68 ret |= led_backlight_keyframe_fade_in_all(animation, state);
69 # endif
70 return ret;
71 }
72
73 static bool keyframe_fade_out(keyframe_animation_t* animation, visualizer_state_t* state) {
74 bool ret = false;
75 # ifdef LCD_BACKLIGHT_ENABLE
76 ret |= lcd_backlight_keyframe_animate_color(animation, state);
77 # endif
78 # ifdef BACKLIGHT_ENABLE
79 ret |= led_backlight_keyframe_fade_out_all(animation, state);
80 # endif
81 return ret;
82 }
83
84 // Don't worry, if the startup animation is long, you can use the keyboard like normal
85 // during that time
86 keyframe_animation_t default_startup_animation = {
87 # if LCD_ENABLE
88 .num_frames = 3,
89 # else
90 .num_frames = 2,
91 # endif
92 .loop = false,
93 .frame_lengths = {0,
94 # if LCD_ENABLE
95 0,
96 # endif
97 gfxMillisecondsToTicks(5000)},
98 .frame_functions =
99 {
100 keyframe_enable,
101 # if LCD_ENABLE
102 lcd_keyframe_draw_logo,
103 # endif
104 keyframe_fade_in,
105 },
106 };
107
108 keyframe_animation_t default_suspend_animation = {
109 # if LCD_ENABLE
110 .num_frames = 3,
111 # else
112 .num_frames = 2,
113 # endif
114 .loop = false,
115 .frame_lengths =
116 {
117 # if LCD_ENABLE
118 0,
119 # endif
120 gfxMillisecondsToTicks(1000), 0},
121 .frame_functions =
122 {
123 # if LCD_ENABLE
124 lcd_keyframe_display_layer_text,
125 # endif
126 keyframe_fade_out,
127 keyframe_disable,
128 },
129 };
130 # endif
131
132 # if defined(BACKLIGHT_ENABLE)
133 # define CROSSFADE_TIME 1000
134 # define GRADIENT_TIME 3000
135
136 keyframe_animation_t led_test_animation = {
137 .num_frames = 14,
138 .loop = true,
139 .frame_lengths =
140 {
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 {
159 led_backlight_keyframe_fade_in_all,
160 keyframe_no_operation,
161 led_backlight_keyframe_fade_out_all,
162 led_backlight_keyframe_crossfade,
163 led_backlight_keyframe_left_to_right_gradient,
164 led_backlight_keyframe_crossfade,
165 led_backlight_keyframe_top_to_bottom_gradient,
166 led_backlight_keyframe_mirror_orientation,
167 led_backlight_keyframe_crossfade,
168 led_backlight_keyframe_left_to_right_gradient,
169 led_backlight_keyframe_crossfade,
170 led_backlight_keyframe_top_to_bottom_gradient,
171 led_backlight_keyframe_normal_orientation,
172 led_backlight_keyframe_crossfade,
173 },
174 };
175 # endif
176
177 #endif