]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Create a file for shared Ergodox Infinity animations
authorFred Sundvik <fsundvik@gmail.com>
Sat, 8 Apr 2017 19:48:18 +0000 (22:48 +0300)
committerFred Sundvik <fsundvik@gmail.com>
Sun, 9 Apr 2017 15:34:59 +0000 (18:34 +0300)
keyboards/ergodox/infinity/animations.c [new file with mode: 0644]
keyboards/ergodox/infinity/animations.h [new file with mode: 0644]
keyboards/ergodox/infinity/rules.mk
keyboards/ergodox/infinity/visualizer.c
keyboards/ergodox/keymaps/default/visualizer.c

diff --git a/keyboards/ergodox/infinity/animations.c b/keyboards/ergodox/infinity/animations.c
new file mode 100644 (file)
index 0000000..54ab994
--- /dev/null
@@ -0,0 +1,54 @@
+/* Copyright 2017 Fred Sundvik
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "animations.h"
+#include "visualizer.h"
+#ifdef LCD_ENABLE
+#include "lcd_keyframes.h"
+#endif
+#ifdef LCD_BACKLIGHT_ENABLE
+#include "lcd_backlight_keyframes.h"
+#endif
+
+#if defined(VISUALIZER_ENABLE) && defined(LCD_ENABLE) && defined(LCD_BACKLIGHT_ENABLE)
+
+// Don't worry, if the startup animation is long, you can use the keyboard like normal
+// during that time
+keyframe_animation_t default_startup_animation = {
+    .num_frames = 4,
+    .loop = false,
+    .frame_lengths = {0, 0, 0, gfxMillisecondsToTicks(5000), 0},
+    .frame_functions = {
+            lcd_keyframe_enable,
+            backlight_keyframe_enable,
+            lcd_keyframe_draw_logo,
+            backlight_keyframe_animate_color,
+    },
+};
+
+keyframe_animation_t default_suspend_animation = {
+    .num_frames = 4,
+    .loop = false,
+    .frame_lengths = {0, gfxMillisecondsToTicks(1000), 0, 0},
+    .frame_functions = {
+            lcd_keyframe_display_layer_text,
+            backlight_keyframe_animate_color,
+            lcd_keyframe_disable,
+            backlight_keyframe_disable,
+    },
+};
+
+#endif
diff --git a/keyboards/ergodox/infinity/animations.h b/keyboards/ergodox/infinity/animations.h
new file mode 100644 (file)
index 0000000..0c441ff
--- /dev/null
@@ -0,0 +1,25 @@
+/* Copyright 2017 Fred Sundvik
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_
+#define KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_
+
+#include "visualizer.h"
+
+extern keyframe_animation_t default_startup_animation;
+extern keyframe_animation_t default_suspend_animation;
+
+#endif /* KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ */
index aaadfe34b5f1688c8a90f7aab6ef4e21edd45a8e..9e6170d89ae85eaee9f2c9fae56b488840bf5e00 100644 (file)
@@ -1,6 +1,7 @@
 # project specific files
 SRC =  matrix.c \
-       led.c
+       led.c \
+       animations.c
 
 ## chip/board settings
 # - the next two should match the directories in
@@ -72,4 +73,4 @@ endif
 
 ifdef LED_ENABLE
 include $(SUBPROJECT_PATH)/drivers/gdisp/IS31FL3731C/driver.mk
-endif
+endif
\ No newline at end of file
index 7ae371c5fc1b3836b34b02a1495732e7ed934daf..a4b09a34d0f7e50af01b0440ad769350511f3f28 100644 (file)
@@ -31,8 +31,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "lcd_keyframes.h"
 #include "lcd_backlight_keyframes.h"
 #include "system/serial_link.h"
-
-#include "resources/resources.h"
+#include "animations.h"
 
 static const uint32_t logo_background_color = LCD_COLOR(0x00, 0x00, 0xFF);
 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,
 
 // Feel free to modify the animations below, or even add new ones if needed
 
-// Don't worry, if the startup animation is long, you can use the keyboard like normal
-// during that time
-static keyframe_animation_t startup_animation = {
-    .num_frames = 4,
-    .loop = false,
-    .frame_lengths = {0, 0, 0, gfxMillisecondsToTicks(10000), 0},
-    .frame_functions = {
-            lcd_keyframe_enable,
-            backlight_keyframe_enable,
-            lcd_keyframe_draw_logo,
-            backlight_keyframe_animate_color,
-    },
-};
 
 // The color animation animates the LCD color when you change layers
 static keyframe_animation_t one_led_color = {
@@ -127,18 +113,6 @@ static keyframe_animation_t lcd_bitmap_leds_animation = {
     .frame_functions = {lcd_keyframe_display_layer_bitmap, lcd_keyframe_display_led_states},
 };
 
-static keyframe_animation_t suspend_animation = {
-    .num_frames = 4,
-    .loop = false,
-    .frame_lengths = {0, gfxMillisecondsToTicks(1000), 0, 0},
-    .frame_functions = {
-            lcd_keyframe_display_layer_text,
-            backlight_keyframe_animate_color,
-            lcd_keyframe_disable,
-            backlight_keyframe_disable,
-    },
-};
-
 void initialize_user_visualizer(visualizer_state_t* state) {
     // The brightness will be dynamically adjustable in the future
     // But for now, change it here.
@@ -146,13 +120,9 @@ void initialize_user_visualizer(visualizer_state_t* state) {
     state->current_lcd_color = initial_color;
     state->target_lcd_color = logo_background_color;
     lcd_state = LCD_STATE_INITIAL;
-    start_keyframe_animation(&startup_animation);
+    start_keyframe_animation(&default_startup_animation);
 }
 
-static const uint32_t red;
-static const uint32_t green;
-static const uint32_t blue;
-
 inline bool is_led_on(visualizer_user_data_t* user_data, uint8_t num) {
     return user_data->led_on & (1u << num);
 }
@@ -295,14 +265,14 @@ void user_visualizer_suspend(visualizer_state_t* state) {
     uint8_t hue = LCD_HUE(state->current_lcd_color);
     uint8_t sat = LCD_SAT(state->current_lcd_color);
     state->target_lcd_color = LCD_COLOR(hue, sat, 0);
-    start_keyframe_animation(&suspend_animation);
+    start_keyframe_animation(&default_suspend_animation);
 }
 
 void user_visualizer_resume(visualizer_state_t* state) {
     state->current_lcd_color = initial_color;
     state->target_lcd_color = logo_background_color;
     lcd_state = LCD_STATE_INITIAL;
-    start_keyframe_animation(&startup_animation);
+    start_keyframe_animation(&default_startup_animation);
 }
 
 void ergodox_board_led_on(void){
index 6a7178968b105af1e67719a040995c779fe6c64f..779de00506d3b097b832e62b439b88daad08d278 100644 (file)
@@ -32,8 +32,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "lcd_backlight_keyframes.h"
 #include "system/serial_link.h"
 #include "led.h"
-
-#include "resources/resources.h"
+#include "animations.h"
 
 static const uint32_t logo_background_color = LCD_COLOR(0x00, 0x00, 0xFF);
 static const uint32_t initial_color = LCD_COLOR(0, 0, 0);
@@ -48,18 +47,6 @@ static lcd_state_t lcd_state = LCD_STATE_INITIAL;
 
 // Feel free to modify the animations below, or even add new ones if needed
 
-// Don't worry, if the startup animation is long, you can use the keyboard like normal
-// during that time
-static keyframe_animation_t startup_animation = {
-    .num_frames = 2,
-    .loop = false,
-    .frame_lengths = {0, gfxMillisecondsToTicks(10000), 0},
-    .frame_functions = {
-            lcd_keyframe_draw_logo,
-            backlight_keyframe_animate_color,
-    },
-};
-
 static keyframe_animation_t lcd_layer_display = {
     .num_frames = 1,
     .loop = false,
@@ -67,30 +54,6 @@ static keyframe_animation_t lcd_layer_display = {
     .frame_functions = {lcd_keyframe_display_layer_and_led_states}
 };
 
-static keyframe_animation_t suspend_animation = {
-    .num_frames = 4,
-    .loop = false,
-    .frame_lengths = {0, gfxMillisecondsToTicks(1000), 0, 0},
-    .frame_functions = {
-            lcd_keyframe_display_layer_text,
-            backlight_keyframe_animate_color,
-            lcd_keyframe_disable,
-            backlight_keyframe_disable,
-    },
-};
-
-static keyframe_animation_t resume_animation = {
-    .num_frames = 4,
-    .loop = false,
-    .frame_lengths = {0, 0, 0, gfxMillisecondsToTicks(10000), 0},
-    .frame_functions = {
-            lcd_keyframe_enable,
-            backlight_keyframe_enable,
-            lcd_keyframe_draw_logo,
-            backlight_keyframe_animate_color,
-    },
-};
-
 // The color animation animates the LCD color when you change layers
 static keyframe_animation_t color_animation = {
     .num_frames = 2,
@@ -109,7 +72,7 @@ void initialize_user_visualizer(visualizer_state_t* state) {
     state->current_lcd_color = initial_color;
     state->target_lcd_color = logo_background_color;
     lcd_state = LCD_STATE_INITIAL;
-    start_keyframe_animation(&startup_animation);
+    start_keyframe_animation(&default_startup_animation);
 }
 
 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) {
     uint8_t hue = LCD_HUE(state->current_lcd_color);
     uint8_t sat = LCD_SAT(state->current_lcd_color);
     state->target_lcd_color = LCD_COLOR(hue, sat, 0);
-    start_keyframe_animation(&suspend_animation);
+    start_keyframe_animation(&default_suspend_animation);
 }
 
 void user_visualizer_resume(visualizer_state_t* state) {
     state->current_lcd_color = initial_color;
     state->target_lcd_color = logo_background_color;
     lcd_state = LCD_STATE_INITIAL;
-    start_keyframe_animation(&resume_animation);
+    start_keyframe_animation(&default_startup_animation);
 }