]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/whitefox/animations.c
Whitefox LED control (#1432)
[qmk_firmware.git] / keyboards / whitefox / 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
22 #ifdef BACKLIGHT_ENABLE
23 #include "led_keyframes.h"
24 #endif
25
26 #include "visualizer_keyframes.h"
27
28
29 #if defined(LCD_ENABLE) || defined(LCD_BACKLIGHT_ENABLE) || defined(BACKLIGHT_ENABLE)
30
31 static bool keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) {
32 #ifdef BACKLIGHT_ENABLE
33     led_keyframe_enable(animation, state);
34 #endif
35     return false;
36 }
37
38 static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) {
39 #ifdef BACKLIGHT_ENABLE
40     led_keyframe_disable(animation, state);
41 #endif
42     return false;
43 }
44
45 static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t* state) {
46     bool ret = false;
47 #ifdef BACKLIGHT_ENABLE
48     ret |= led_keyframe_fade_in_all(animation, state);
49 #endif
50     return ret;
51 }
52
53 static bool keyframe_fade_out(keyframe_animation_t* animation, visualizer_state_t* state) {
54     bool ret = false;
55 #ifdef BACKLIGHT_ENABLE
56     ret |= led_keyframe_fade_out_all(animation, state);
57 #endif
58     return ret;
59 }
60
61
62 // Don't worry, if the startup animation is long, you can use the keyboard like normal
63 // during that time
64 keyframe_animation_t default_startup_animation = {
65     .num_frames = 2,
66     .loop = false,
67     .frame_lengths = {0, gfxMillisecondsToTicks(5000)},
68     .frame_functions = {
69             keyframe_enable,
70             keyframe_fade_in,
71     },
72 };
73
74 keyframe_animation_t default_suspend_animation = {
75     .num_frames = 2,
76     .loop = false,
77     .frame_lengths = {gfxMillisecondsToTicks(1000), 0},
78     .frame_functions = {
79             keyframe_fade_out,
80             keyframe_disable,
81     },
82 };
83 #endif
84
85 #if defined(BACKLIGHT_ENABLE)
86 #define CROSSFADE_TIME 1000
87 #define GRADIENT_TIME 3000
88
89 keyframe_animation_t led_test_animation = {
90     .num_frames = 14,
91     .loop = true,
92     .frame_lengths = {
93         gfxMillisecondsToTicks(1000), // fade in
94         gfxMillisecondsToTicks(1000), // no op (leds on)
95         gfxMillisecondsToTicks(1000), // fade out
96         gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
97         gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in)
98         gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
99         gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom
100         0,           // mirror leds
101         gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
102         gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out)
103         gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
104         gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom
105         0,           // normal leds
106         gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
107
108     },
109     .frame_functions = {
110         led_keyframe_fade_in_all,
111         keyframe_no_operation,
112         led_keyframe_fade_out_all,
113         led_keyframe_crossfade,
114         led_keyframe_left_to_right_gradient,
115         led_keyframe_crossfade,
116         led_keyframe_top_to_bottom_gradient,
117         led_keyframe_mirror_orientation,
118         led_keyframe_crossfade,
119         led_keyframe_left_to_right_gradient,
120         led_keyframe_crossfade,
121         led_keyframe_top_to_bottom_gradient,
122         led_keyframe_normal_orientation,
123         led_keyframe_crossfade,
124     },
125 };
126 #endif
127
128 #endif