diff options
author | Fred Sundvik <fsundvik@gmail.com> | 2017-04-08 23:04:27 +0300 |
---|---|---|
committer | Fred Sundvik <fsundvik@gmail.com> | 2017-04-09 18:34:59 +0300 |
commit | c5d2b7ff16f81a8061127e0ec636cf9b914725c5 (patch) | |
tree | 8a4095bd3ae22fd79384d88416648129bb6176df | |
parent | 306353bf06e5e5a76890ffb0c48a4dcca76c4399 (diff) | |
download | qmk_firmware-c5d2b7ff16f81a8061127e0ec636cf9b914725c5.tar.gz qmk_firmware-c5d2b7ff16f81a8061127e0ec636cf9b914725c5.zip |
Rename led test to led_keyframes and move animation to Ergodox
-rw-r--r-- | keyboards/ergodox/infinity/animations.c | 55 | ||||
-rw-r--r-- | keyboards/ergodox/infinity/animations.h | 5 | ||||
-rw-r--r-- | quantum/visualizer/led_keyframes.c (renamed from quantum/visualizer/led_test.c) | 57 | ||||
-rw-r--r-- | quantum/visualizer/led_keyframes.h (renamed from quantum/visualizer/led_test.h) | 20 | ||||
-rw-r--r-- | quantum/visualizer/visualizer.mk | 2 |
5 files changed, 78 insertions, 61 deletions
diff --git a/keyboards/ergodox/infinity/animations.c b/keyboards/ergodox/infinity/animations.c index 54ab99460..4c9f6d9c8 100644 --- a/keyboards/ergodox/infinity/animations.c +++ b/keyboards/ergodox/infinity/animations.c | |||
@@ -14,6 +14,8 @@ | |||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #if defined(VISUALIZER_ENABLE) | ||
18 | |||
17 | #include "animations.h" | 19 | #include "animations.h" |
18 | #include "visualizer.h" | 20 | #include "visualizer.h" |
19 | #ifdef LCD_ENABLE | 21 | #ifdef LCD_ENABLE |
@@ -23,7 +25,14 @@ | |||
23 | #include "lcd_backlight_keyframes.h" | 25 | #include "lcd_backlight_keyframes.h" |
24 | #endif | 26 | #endif |
25 | 27 | ||
26 | #if defined(VISUALIZER_ENABLE) && defined(LCD_ENABLE) && defined(LCD_BACKLIGHT_ENABLE) | 28 | #ifdef LED_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) | ||
27 | 36 | ||
28 | // Don't worry, if the startup animation is long, you can use the keyboard like normal | 37 | // Don't worry, if the startup animation is long, you can use the keyboard like normal |
29 | // during that time | 38 | // during that time |
@@ -50,5 +59,49 @@ keyframe_animation_t default_suspend_animation = { | |||
50 | backlight_keyframe_disable, | 59 | backlight_keyframe_disable, |
51 | }, | 60 | }, |
52 | }; | 61 | }; |
62 | #endif | ||
63 | |||
64 | #if defined(LED_ENABLE) | ||
65 | #define CROSSFADE_TIME 1000 | ||
66 | #define GRADIENT_TIME 3000 | ||
67 | |||
68 | keyframe_animation_t led_test_animation = { | ||
69 | .num_frames = 14, | ||
70 | .loop = true, | ||
71 | .frame_lengths = { | ||
72 | gfxMillisecondsToTicks(1000), // fade in | ||
73 | gfxMillisecondsToTicks(1000), // no op (leds on) | ||
74 | gfxMillisecondsToTicks(1000), // fade out | ||
75 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade | ||
76 | gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in) | ||
77 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade | ||
78 | gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom | ||
79 | 0, // mirror leds | ||
80 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade | ||
81 | gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out) | ||
82 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade | ||
83 | gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom | ||
84 | 0, // normal leds | ||
85 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade | ||
86 | |||
87 | }, | ||
88 | .frame_functions = { | ||
89 | led_keyframe_fade_in_all, | ||
90 | keyframe_no_operation, | ||
91 | led_keyframe_fade_out_all, | ||
92 | led_keyframe_crossfade, | ||
93 | led_keyframe_left_to_right_gradient, | ||
94 | led_keyframe_crossfade, | ||
95 | led_keyframe_top_to_bottom_gradient, | ||
96 | led_keyframe_mirror_orientation, | ||
97 | led_keyframe_crossfade, | ||
98 | led_keyframe_left_to_right_gradient, | ||
99 | led_keyframe_crossfade, | ||
100 | led_keyframe_top_to_bottom_gradient, | ||
101 | led_keyframe_normal_orientation, | ||
102 | led_keyframe_crossfade, | ||
103 | }, | ||
104 | }; | ||
105 | #endif | ||
53 | 106 | ||
54 | #endif | 107 | #endif |
diff --git a/keyboards/ergodox/infinity/animations.h b/keyboards/ergodox/infinity/animations.h index 0c441ff7e..6d8b9830d 100644 --- a/keyboards/ergodox/infinity/animations.h +++ b/keyboards/ergodox/infinity/animations.h | |||
@@ -19,7 +19,12 @@ | |||
19 | 19 | ||
20 | #include "visualizer.h" | 20 | #include "visualizer.h" |
21 | 21 | ||
22 | // You can use these default animations, but of course you can also write your own custom ones instead | ||
22 | extern keyframe_animation_t default_startup_animation; | 23 | extern keyframe_animation_t default_startup_animation; |
23 | extern keyframe_animation_t default_suspend_animation; | 24 | extern keyframe_animation_t default_suspend_animation; |
24 | 25 | ||
26 | // An animation for testing and demonstrating the led support, should probably not be used for real world | ||
27 | // cases | ||
28 | extern keyframe_animation_t led_test_animation; | ||
29 | |||
25 | #endif /* KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ */ | 30 | #endif /* KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ */ |
diff --git a/quantum/visualizer/led_test.c b/quantum/visualizer/led_keyframes.c index a9abace8d..2dacd990d 100644 --- a/quantum/visualizer/led_test.c +++ b/quantum/visualizer/led_keyframes.c | |||
@@ -21,50 +21,9 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
22 | SOFTWARE. | 22 | SOFTWARE. |
23 | */ | 23 | */ |
24 | #include "led_test.h" | ||
25 | #include "gfx.h" | 24 | #include "gfx.h" |
26 | #include "math.h" | 25 | #include "math.h" |
27 | 26 | #include "led_keyframes.h" | |
28 | #define CROSSFADE_TIME 1000 | ||
29 | #define GRADIENT_TIME 3000 | ||
30 | |||
31 | keyframe_animation_t led_test_animation = { | ||
32 | .num_frames = 14, | ||
33 | .loop = true, | ||
34 | .frame_lengths = { | ||
35 | gfxMillisecondsToTicks(1000), // fade in | ||
36 | gfxMillisecondsToTicks(1000), // no op (leds on) | ||
37 | gfxMillisecondsToTicks(1000), // fade out | ||
38 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade | ||
39 | gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in) | ||
40 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade | ||
41 | gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom | ||
42 | 0, // mirror leds | ||
43 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade | ||
44 | gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out) | ||
45 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade | ||
46 | gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom | ||
47 | 0, // normal leds | ||
48 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade | ||
49 | |||
50 | }, | ||
51 | .frame_functions = { | ||
52 | keyframe_fade_in_all_leds, | ||
53 | keyframe_no_operation, | ||
54 | keyframe_fade_out_all_leds, | ||
55 | keyframe_led_crossfade, | ||
56 | keyframe_led_left_to_right_gradient, | ||
57 | keyframe_led_crossfade, | ||
58 | keyframe_led_top_to_bottom_gradient, | ||
59 | keyframe_mirror_led_orientation, | ||
60 | keyframe_led_crossfade, | ||
61 | keyframe_led_left_to_right_gradient, | ||
62 | keyframe_led_crossfade, | ||
63 | keyframe_led_top_to_bottom_gradient, | ||
64 | keyframe_normal_led_orientation, | ||
65 | keyframe_led_crossfade, | ||
66 | }, | ||
67 | }; | ||
68 | 27 | ||
69 | static uint8_t fade_led_color(keyframe_animation_t* animation, int from, int to) { | 28 | static uint8_t fade_led_color(keyframe_animation_t* animation, int from, int to) { |
70 | int frame_length = animation->frame_lengths[animation->current_frame]; | 29 | int frame_length = animation->frame_lengths[animation->current_frame]; |
@@ -96,19 +55,19 @@ static uint8_t compute_gradient_color(float t, float index, float num) { | |||
96 | return (uint8_t)(255.0f * v); | 55 | return (uint8_t)(255.0f * v); |
97 | } | 56 | } |
98 | 57 | ||
99 | bool keyframe_fade_in_all_leds(keyframe_animation_t* animation, visualizer_state_t* state) { | 58 | bool led_keyframe_fade_in_all(keyframe_animation_t* animation, visualizer_state_t* state) { |
100 | (void)state; | 59 | (void)state; |
101 | keyframe_fade_all_leds_from_to(animation, 0, 255); | 60 | keyframe_fade_all_leds_from_to(animation, 0, 255); |
102 | return true; | 61 | return true; |
103 | } | 62 | } |
104 | 63 | ||
105 | bool keyframe_fade_out_all_leds(keyframe_animation_t* animation, visualizer_state_t* state) { | 64 | bool led_keyframe_fade_out_all(keyframe_animation_t* animation, visualizer_state_t* state) { |
106 | (void)state; | 65 | (void)state; |
107 | keyframe_fade_all_leds_from_to(animation, 255, 0); | 66 | keyframe_fade_all_leds_from_to(animation, 255, 0); |
108 | return true; | 67 | return true; |
109 | } | 68 | } |
110 | 69 | ||
111 | bool keyframe_led_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { | 70 | bool led_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { |
112 | (void)state; | 71 | (void)state; |
113 | float frame_length = animation->frame_lengths[animation->current_frame]; | 72 | float frame_length = animation->frame_lengths[animation->current_frame]; |
114 | float current_pos = frame_length - animation->time_left_in_frame; | 73 | float current_pos = frame_length - animation->time_left_in_frame; |
@@ -120,7 +79,7 @@ bool keyframe_led_left_to_right_gradient(keyframe_animation_t* animation, visual | |||
120 | return true; | 79 | return true; |
121 | } | 80 | } |
122 | 81 | ||
123 | bool keyframe_led_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { | 82 | bool led_keyframe_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { |
124 | (void)state; | 83 | (void)state; |
125 | float frame_length = animation->frame_lengths[animation->current_frame]; | 84 | float frame_length = animation->frame_lengths[animation->current_frame]; |
126 | float current_pos = frame_length - animation->time_left_in_frame; | 85 | float current_pos = frame_length - animation->time_left_in_frame; |
@@ -139,7 +98,7 @@ static void copy_current_led_state(uint8_t* dest) { | |||
139 | } | 98 | } |
140 | } | 99 | } |
141 | } | 100 | } |
142 | bool keyframe_led_crossfade(keyframe_animation_t* animation, visualizer_state_t* state) { | 101 | bool led_keyframe_crossfade(keyframe_animation_t* animation, visualizer_state_t* state) { |
143 | (void)state; | 102 | (void)state; |
144 | if (animation->first_update_of_frame) { | 103 | if (animation->first_update_of_frame) { |
145 | copy_current_led_state(&crossfade_start_frame[0][0]); | 104 | copy_current_led_state(&crossfade_start_frame[0][0]); |
@@ -155,14 +114,14 @@ bool keyframe_led_crossfade(keyframe_animation_t* animation, visualizer_state_t* | |||
155 | return true; | 114 | return true; |
156 | } | 115 | } |
157 | 116 | ||
158 | bool keyframe_mirror_led_orientation(keyframe_animation_t* animation, visualizer_state_t* state) { | 117 | bool led_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state) { |
159 | (void)state; | 118 | (void)state; |
160 | (void)animation; | 119 | (void)animation; |
161 | gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_180); | 120 | gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_180); |
162 | return false; | 121 | return false; |
163 | } | 122 | } |
164 | 123 | ||
165 | bool keyframe_normal_led_orientation(keyframe_animation_t* animation, visualizer_state_t* state) { | 124 | bool led_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state) { |
166 | (void)state; | 125 | (void)state; |
167 | (void)animation; | 126 | (void)animation; |
168 | gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_0); | 127 | gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_0); |
diff --git a/quantum/visualizer/led_test.h b/quantum/visualizer/led_keyframes.h index 5e2325753..a68943041 100644 --- a/quantum/visualizer/led_test.h +++ b/quantum/visualizer/led_keyframes.h | |||
@@ -22,20 +22,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |||
22 | SOFTWARE. | 22 | SOFTWARE. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #ifndef TMK_VISUALIZER_LED_TEST_H_ | 25 | #ifndef LED_KEYFRAMES_H |
26 | #define TMK_VISUALIZER_LED_TEST_H_ | 26 | #define LED_KEYFRAMES_H |
27 | 27 | ||
28 | #include "visualizer.h" | 28 | #include "visualizer.h" |
29 | 29 | ||
30 | bool keyframe_fade_in_all_leds(keyframe_animation_t* animation, visualizer_state_t* state); | 30 | bool led_keyframe_fade_in_all(keyframe_animation_t* animation, visualizer_state_t* state); |
31 | bool keyframe_fade_out_all_leds(keyframe_animation_t* animation, visualizer_state_t* state); | 31 | bool led_keyframe_fade_out_all(keyframe_animation_t* animation, visualizer_state_t* state); |
32 | bool keyframe_led_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state); | 32 | bool led_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state); |
33 | bool keyframe_led_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state); | 33 | bool led_keyframe_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state); |
34 | bool keyframe_led_crossfade(keyframe_animation_t* animation, visualizer_state_t* state); | 34 | bool led_keyframe_crossfade(keyframe_animation_t* animation, visualizer_state_t* state); |
35 | bool keyframe_mirror_led_orientation(keyframe_animation_t* animation, visualizer_state_t* state); | 35 | bool led_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state); |
36 | bool keyframe_normal_led_orientation(keyframe_animation_t* animation, visualizer_state_t* state); | 36 | bool led_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state); |
37 | 37 | ||
38 | extern keyframe_animation_t led_test_animation; | 38 | extern keyframe_animation_t led_test_animation; |
39 | 39 | ||
40 | 40 | ||
41 | #endif /* TMK_VISUALIZER_LED_TEST_H_ */ | 41 | #endif /* LED_KEYFRAMES_H */ |
diff --git a/quantum/visualizer/visualizer.mk b/quantum/visualizer/visualizer.mk index 7c8e98d67..5f710124b 100644 --- a/quantum/visualizer/visualizer.mk +++ b/quantum/visualizer/visualizer.mk | |||
@@ -43,7 +43,7 @@ OPT_DEFS += -DLCD_BACKLIGHT_ENABLE | |||
43 | endif | 43 | endif |
44 | 44 | ||
45 | ifeq ($(strip $(LED_ENABLE)), yes) | 45 | ifeq ($(strip $(LED_ENABLE)), yes) |
46 | SRC += $(VISUALIZER_DIR)/led_test.c | 46 | SRC += $(VISUALIZER_DIR)/led_keyframes.c |
47 | OPT_DEFS += -DLED_ENABLE | 47 | OPT_DEFS += -DLED_ENABLE |
48 | endif | 48 | endif |
49 | 49 | ||