]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/ergodox/infinity/animations.c
Fix typo in BACKLIGHT_ENABLE
[qmk_firmware.git] / keyboards / ergodox / infinity / 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 "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_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     backlight_keyframe_enable(animation, state);
43 #endif
44 #ifdef BACKLIGHT_ENABLE
45     led_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     backlight_keyframe_disable(animation, state);
56 #endif
57 #ifdef BACKLIGHT_ENABLE
58     led_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 |= backlight_keyframe_animate_color(animation, state);
67 #endif
68 #ifdef BACKLIGHT_ENABLE
69     ret |= led_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 |= backlight_keyframe_animate_color(animation, state);
78 #endif
79 #ifdef BACKLIGHT_ENABLE
80     ret |= led_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     .num_frames = 3,
90     .loop = false,
91     .frame_lengths = {0, 0, gfxMillisecondsToTicks(5000)},
92     .frame_functions = {
93             keyframe_enable,
94             lcd_keyframe_draw_logo,
95             keyframe_fade_in,
96     },
97 };
98
99 keyframe_animation_t default_suspend_animation = {
100     .num_frames = 3,
101     .loop = false,
102     .frame_lengths = {0, gfxMillisecondsToTicks(1000), 0},
103     .frame_functions = {
104             lcd_keyframe_display_layer_text,
105             keyframe_fade_out,
106             keyframe_disable,
107     },
108 };
109 #endif
110
111 #if defined(BACKLIGHT_ENABLE)
112 #define CROSSFADE_TIME 1000
113 #define GRADIENT_TIME 3000
114
115 keyframe_animation_t led_test_animation = {
116     .num_frames = 14,
117     .loop = true,
118     .frame_lengths = {
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
126         0,           // mirror leds
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
131         0,           // normal leds
132         gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
133
134     },
135     .frame_functions = {
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,
150     },
151 };
152 #endif
153
154 #endif