diff options
| author | Fred Sundvik <fsundvik@gmail.com> | 2017-04-08 22:48:18 +0300 |
|---|---|---|
| committer | Fred Sundvik <fsundvik@gmail.com> | 2017-04-09 18:34:59 +0300 |
| commit | 306353bf06e5e5a76890ffb0c48a4dcca76c4399 (patch) | |
| tree | d2563b3523b5ca189c86a3bd675d165481933902 | |
| parent | c6ca996f4eaa4cce90e02c123230e1e655c9465a (diff) | |
| download | qmk_firmware-306353bf06e5e5a76890ffb0c48a4dcca76c4399.tar.gz qmk_firmware-306353bf06e5e5a76890ffb0c48a4dcca76c4399.zip | |
Create a file for shared Ergodox Infinity animations
| -rw-r--r-- | keyboards/ergodox/infinity/animations.c | 54 | ||||
| -rw-r--r-- | keyboards/ergodox/infinity/animations.h | 25 | ||||
| -rw-r--r-- | keyboards/ergodox/infinity/rules.mk | 5 | ||||
| -rw-r--r-- | keyboards/ergodox/infinity/visualizer.c | 38 | ||||
| -rw-r--r-- | keyboards/ergodox/keymaps/default/visualizer.c | 45 |
5 files changed, 90 insertions, 77 deletions
diff --git a/keyboards/ergodox/infinity/animations.c b/keyboards/ergodox/infinity/animations.c new file mode 100644 index 000000000..54ab99460 --- /dev/null +++ b/keyboards/ergodox/infinity/animations.c | |||
| @@ -0,0 +1,54 @@ | |||
| 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 | #include "animations.h" | ||
| 18 | #include "visualizer.h" | ||
| 19 | #ifdef LCD_ENABLE | ||
| 20 | #include "lcd_keyframes.h" | ||
| 21 | #endif | ||
| 22 | #ifdef LCD_BACKLIGHT_ENABLE | ||
| 23 | #include "lcd_backlight_keyframes.h" | ||
| 24 | #endif | ||
| 25 | |||
| 26 | #if defined(VISUALIZER_ENABLE) && defined(LCD_ENABLE) && defined(LCD_BACKLIGHT_ENABLE) | ||
| 27 | |||
| 28 | // Don't worry, if the startup animation is long, you can use the keyboard like normal | ||
| 29 | // during that time | ||
| 30 | keyframe_animation_t default_startup_animation = { | ||
| 31 | .num_frames = 4, | ||
| 32 | .loop = false, | ||
| 33 | .frame_lengths = {0, 0, 0, gfxMillisecondsToTicks(5000), 0}, | ||
| 34 | .frame_functions = { | ||
| 35 | lcd_keyframe_enable, | ||
| 36 | backlight_keyframe_enable, | ||
| 37 | lcd_keyframe_draw_logo, | ||
| 38 | backlight_keyframe_animate_color, | ||
| 39 | }, | ||
| 40 | }; | ||
| 41 | |||
| 42 | keyframe_animation_t default_suspend_animation = { | ||
| 43 | .num_frames = 4, | ||
| 44 | .loop = false, | ||
| 45 | .frame_lengths = {0, gfxMillisecondsToTicks(1000), 0, 0}, | ||
| 46 | .frame_functions = { | ||
| 47 | lcd_keyframe_display_layer_text, | ||
| 48 | backlight_keyframe_animate_color, | ||
| 49 | lcd_keyframe_disable, | ||
| 50 | backlight_keyframe_disable, | ||
| 51 | }, | ||
| 52 | }; | ||
| 53 | |||
| 54 | #endif | ||
diff --git a/keyboards/ergodox/infinity/animations.h b/keyboards/ergodox/infinity/animations.h new file mode 100644 index 000000000..0c441ff7e --- /dev/null +++ b/keyboards/ergodox/infinity/animations.h | |||
| @@ -0,0 +1,25 @@ | |||
| 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 | #ifndef KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ | ||
| 18 | #define KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ | ||
| 19 | |||
| 20 | #include "visualizer.h" | ||
| 21 | |||
| 22 | extern keyframe_animation_t default_startup_animation; | ||
| 23 | extern keyframe_animation_t default_suspend_animation; | ||
| 24 | |||
| 25 | #endif /* KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ */ | ||
diff --git a/keyboards/ergodox/infinity/rules.mk b/keyboards/ergodox/infinity/rules.mk index aaadfe34b..9e6170d89 100644 --- a/keyboards/ergodox/infinity/rules.mk +++ b/keyboards/ergodox/infinity/rules.mk | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | # project specific files | 1 | # project specific files |
| 2 | SRC = matrix.c \ | 2 | SRC = matrix.c \ |
| 3 | led.c | 3 | led.c \ |
| 4 | animations.c | ||
| 4 | 5 | ||
| 5 | ## chip/board settings | 6 | ## chip/board settings |
| 6 | # - the next two should match the directories in | 7 | # - the next two should match the directories in |
| @@ -72,4 +73,4 @@ endif | |||
| 72 | 73 | ||
| 73 | ifdef LED_ENABLE | 74 | ifdef LED_ENABLE |
| 74 | include $(SUBPROJECT_PATH)/drivers/gdisp/IS31FL3731C/driver.mk | 75 | include $(SUBPROJECT_PATH)/drivers/gdisp/IS31FL3731C/driver.mk |
| 75 | endif | 76 | endif \ No newline at end of file |
diff --git a/keyboards/ergodox/infinity/visualizer.c b/keyboards/ergodox/infinity/visualizer.c index 7ae371c5f..a4b09a34d 100644 --- a/keyboards/ergodox/infinity/visualizer.c +++ b/keyboards/ergodox/infinity/visualizer.c | |||
| @@ -31,8 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 31 | #include "lcd_keyframes.h" | 31 | #include "lcd_keyframes.h" |
| 32 | #include "lcd_backlight_keyframes.h" | 32 | #include "lcd_backlight_keyframes.h" |
| 33 | #include "system/serial_link.h" | 33 | #include "system/serial_link.h" |
| 34 | 34 | #include "animations.h" | |
| 35 | #include "resources/resources.h" | ||
| 36 | 35 | ||
| 37 | static const uint32_t logo_background_color = LCD_COLOR(0x00, 0x00, 0xFF); | 36 | static const uint32_t logo_background_color = LCD_COLOR(0x00, 0x00, 0xFF); |
| 38 | static const uint32_t initial_color = LCD_COLOR(0, 0, 0); | 37 | static const uint32_t initial_color = LCD_COLOR(0, 0, 0); |
| @@ -74,19 +73,6 @@ _Static_assert(sizeof(visualizer_user_data_t) <= VISUALIZER_USER_DATA_SIZE, | |||
| 74 | 73 | ||
| 75 | // Feel free to modify the animations below, or even add new ones if needed | 74 | // Feel free to modify the animations below, or even add new ones if needed |
| 76 | 75 | ||
| 77 | // Don't worry, if the startup animation is long, you can use the keyboard like normal | ||
| 78 | // during that time | ||
| 79 | static keyframe_animation_t startup_animation = { | ||
| 80 | .num_frames = 4, | ||
| 81 | .loop = false, | ||
| 82 | .frame_lengths = {0, 0, 0, gfxMillisecondsToTicks(10000), 0}, | ||
| 83 | .frame_functions = { | ||
| 84 | lcd_keyframe_enable, | ||
| 85 | backlight_keyframe_enable, | ||
| 86 | lcd_keyframe_draw_logo, | ||
| 87 | backlight_keyframe_animate_color, | ||
| 88 | }, | ||
| 89 | }; | ||
| 90 | 76 | ||
| 91 | // The color animation animates the LCD color when you change layers | 77 | // The color animation animates the LCD color when you change layers |
| 92 | static keyframe_animation_t one_led_color = { | 78 | static keyframe_animation_t one_led_color = { |
| @@ -127,18 +113,6 @@ static keyframe_animation_t lcd_bitmap_leds_animation = { | |||
| 127 | .frame_functions = {lcd_keyframe_display_layer_bitmap, lcd_keyframe_display_led_states}, | 113 | .frame_functions = {lcd_keyframe_display_layer_bitmap, lcd_keyframe_display_led_states}, |
| 128 | }; | 114 | }; |
| 129 | 115 | ||
| 130 | static keyframe_animation_t suspend_animation = { | ||
| 131 | .num_frames = 4, | ||
| 132 | .loop = false, | ||
| 133 | .frame_lengths = {0, gfxMillisecondsToTicks(1000), 0, 0}, | ||
| 134 | .frame_functions = { | ||
| 135 | lcd_keyframe_display_layer_text, | ||
| 136 | backlight_keyframe_animate_color, | ||
| 137 | lcd_keyframe_disable, | ||
| 138 | backlight_keyframe_disable, | ||
| 139 | }, | ||
| 140 | }; | ||
| 141 | |||
| 142 | void initialize_user_visualizer(visualizer_state_t* state) { | 116 | void initialize_user_visualizer(visualizer_state_t* state) { |
| 143 | // The brightness will be dynamically adjustable in the future | 117 | // The brightness will be dynamically adjustable in the future |
| 144 | // But for now, change it here. | 118 | // But for now, change it here. |
| @@ -146,13 +120,9 @@ void initialize_user_visualizer(visualizer_state_t* state) { | |||
| 146 | state->current_lcd_color = initial_color; | 120 | state->current_lcd_color = initial_color; |
| 147 | state->target_lcd_color = logo_background_color; | 121 | state->target_lcd_color = logo_background_color; |
| 148 | lcd_state = LCD_STATE_INITIAL; | 122 | lcd_state = LCD_STATE_INITIAL; |
| 149 | start_keyframe_animation(&startup_animation); | 123 | start_keyframe_animation(&default_startup_animation); |
| 150 | } | 124 | } |
| 151 | 125 | ||
| 152 | static const uint32_t red; | ||
| 153 | static const uint32_t green; | ||
| 154 | static const uint32_t blue; | ||
| 155 | |||
| 156 | inline bool is_led_on(visualizer_user_data_t* user_data, uint8_t num) { | 126 | inline bool is_led_on(visualizer_user_data_t* user_data, uint8_t num) { |
| 157 | return user_data->led_on & (1u << num); | 127 | return user_data->led_on & (1u << num); |
| 158 | } | 128 | } |
| @@ -295,14 +265,14 @@ void user_visualizer_suspend(visualizer_state_t* state) { | |||
| 295 | uint8_t hue = LCD_HUE(state->current_lcd_color); | 265 | uint8_t hue = LCD_HUE(state->current_lcd_color); |
| 296 | uint8_t sat = LCD_SAT(state->current_lcd_color); | 266 | uint8_t sat = LCD_SAT(state->current_lcd_color); |
| 297 | state->target_lcd_color = LCD_COLOR(hue, sat, 0); | 267 | state->target_lcd_color = LCD_COLOR(hue, sat, 0); |
| 298 | start_keyframe_animation(&suspend_animation); | 268 | start_keyframe_animation(&default_suspend_animation); |
| 299 | } | 269 | } |
| 300 | 270 | ||
| 301 | void user_visualizer_resume(visualizer_state_t* state) { | 271 | void user_visualizer_resume(visualizer_state_t* state) { |
| 302 | state->current_lcd_color = initial_color; | 272 | state->current_lcd_color = initial_color; |
| 303 | state->target_lcd_color = logo_background_color; | 273 | state->target_lcd_color = logo_background_color; |
| 304 | lcd_state = LCD_STATE_INITIAL; | 274 | lcd_state = LCD_STATE_INITIAL; |
| 305 | start_keyframe_animation(&startup_animation); | 275 | start_keyframe_animation(&default_startup_animation); |
| 306 | } | 276 | } |
| 307 | 277 | ||
| 308 | void ergodox_board_led_on(void){ | 278 | void ergodox_board_led_on(void){ |
diff --git a/keyboards/ergodox/keymaps/default/visualizer.c b/keyboards/ergodox/keymaps/default/visualizer.c index 6a7178968..779de0050 100644 --- a/keyboards/ergodox/keymaps/default/visualizer.c +++ b/keyboards/ergodox/keymaps/default/visualizer.c | |||
| @@ -32,8 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 32 | #include "lcd_backlight_keyframes.h" | 32 | #include "lcd_backlight_keyframes.h" |
| 33 | #include "system/serial_link.h" | 33 | #include "system/serial_link.h" |
| 34 | #include "led.h" | 34 | #include "led.h" |
| 35 | 35 | #include "animations.h" | |
| 36 | #include "resources/resources.h" | ||
| 37 | 36 | ||
| 38 | static const uint32_t logo_background_color = LCD_COLOR(0x00, 0x00, 0xFF); | 37 | static const uint32_t logo_background_color = LCD_COLOR(0x00, 0x00, 0xFF); |
| 39 | static const uint32_t initial_color = LCD_COLOR(0, 0, 0); | 38 | static const uint32_t initial_color = LCD_COLOR(0, 0, 0); |
| @@ -48,18 +47,6 @@ static lcd_state_t lcd_state = LCD_STATE_INITIAL; | |||
| 48 | 47 | ||
| 49 | // Feel free to modify the animations below, or even add new ones if needed | 48 | // Feel free to modify the animations below, or even add new ones if needed |
| 50 | 49 | ||
| 51 | // Don't worry, if the startup animation is long, you can use the keyboard like normal | ||
| 52 | // during that time | ||
| 53 | static keyframe_animation_t startup_animation = { | ||
| 54 | .num_frames = 2, | ||
| 55 | .loop = false, | ||
| 56 | .frame_lengths = {0, gfxMillisecondsToTicks(10000), 0}, | ||
| 57 | .frame_functions = { | ||
| 58 | lcd_keyframe_draw_logo, | ||
| 59 | backlight_keyframe_animate_color, | ||
| 60 | }, | ||
| 61 | }; | ||
| 62 | |||
| 63 | static keyframe_animation_t lcd_layer_display = { | 50 | static keyframe_animation_t lcd_layer_display = { |
| 64 | .num_frames = 1, | 51 | .num_frames = 1, |
| 65 | .loop = false, | 52 | .loop = false, |
| @@ -67,30 +54,6 @@ static keyframe_animation_t lcd_layer_display = { | |||
| 67 | .frame_functions = {lcd_keyframe_display_layer_and_led_states} | 54 | .frame_functions = {lcd_keyframe_display_layer_and_led_states} |
| 68 | }; | 55 | }; |
| 69 | 56 | ||
| 70 | static keyframe_animation_t suspend_animation = { | ||
| 71 | .num_frames = 4, | ||
| 72 | .loop = false, | ||
| 73 | .frame_lengths = {0, gfxMillisecondsToTicks(1000), 0, 0}, | ||
| 74 | .frame_functions = { | ||
| 75 | lcd_keyframe_display_layer_text, | ||
| 76 | backlight_keyframe_animate_color, | ||
| 77 | lcd_keyframe_disable, | ||
| 78 | backlight_keyframe_disable, | ||
| 79 | }, | ||
| 80 | }; | ||
| 81 | |||
| 82 | static keyframe_animation_t resume_animation = { | ||
| 83 | .num_frames = 4, | ||
| 84 | .loop = false, | ||
| 85 | .frame_lengths = {0, 0, 0, gfxMillisecondsToTicks(10000), 0}, | ||
| 86 | .frame_functions = { | ||
| 87 | lcd_keyframe_enable, | ||
| 88 | backlight_keyframe_enable, | ||
| 89 | lcd_keyframe_draw_logo, | ||
| 90 | backlight_keyframe_animate_color, | ||
| 91 | }, | ||
| 92 | }; | ||
| 93 | |||
| 94 | // The color animation animates the LCD color when you change layers | 57 | // The color animation animates the LCD color when you change layers |
| 95 | static keyframe_animation_t color_animation = { | 58 | static keyframe_animation_t color_animation = { |
| 96 | .num_frames = 2, | 59 | .num_frames = 2, |
| @@ -109,7 +72,7 @@ void initialize_user_visualizer(visualizer_state_t* state) { | |||
| 109 | state->current_lcd_color = initial_color; | 72 | state->current_lcd_color = initial_color; |
| 110 | state->target_lcd_color = logo_background_color; | 73 | state->target_lcd_color = logo_background_color; |
| 111 | lcd_state = LCD_STATE_INITIAL; | 74 | lcd_state = LCD_STATE_INITIAL; |
| 112 | start_keyframe_animation(&startup_animation); | 75 | start_keyframe_animation(&default_startup_animation); |
| 113 | } | 76 | } |
| 114 | 77 | ||
| 115 | void update_user_visualizer_state(visualizer_state_t* state, visualizer_keyboard_status_t* prev_status) { | 78 | void update_user_visualizer_state(visualizer_state_t* state, visualizer_keyboard_status_t* prev_status) { |
| @@ -156,12 +119,12 @@ void user_visualizer_suspend(visualizer_state_t* state) { | |||
| 156 | uint8_t hue = LCD_HUE(state->current_lcd_color); | 119 | uint8_t hue = LCD_HUE(state->current_lcd_color); |
| 157 | uint8_t sat = LCD_SAT(state->current_lcd_color); | 120 | uint8_t sat = LCD_SAT(state->current_lcd_color); |
| 158 | state->target_lcd_color = LCD_COLOR(hue, sat, 0); | 121 | state->target_lcd_color = LCD_COLOR(hue, sat, 0); |
| 159 | start_keyframe_animation(&suspend_animation); | 122 | start_keyframe_animation(&default_suspend_animation); |
| 160 | } | 123 | } |
| 161 | 124 | ||
| 162 | void user_visualizer_resume(visualizer_state_t* state) { | 125 | void user_visualizer_resume(visualizer_state_t* state) { |
| 163 | state->current_lcd_color = initial_color; | 126 | state->current_lcd_color = initial_color; |
| 164 | state->target_lcd_color = logo_background_color; | 127 | state->target_lcd_color = logo_background_color; |
| 165 | lcd_state = LCD_STATE_INITIAL; | 128 | lcd_state = LCD_STATE_INITIAL; |
| 166 | start_keyframe_animation(&resume_animation); | 129 | start_keyframe_animation(&default_startup_animation); |
| 167 | } | 130 | } |
