From 4da3b19603255115f71812964383ee7b518637be Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sun, 9 Jul 2017 17:50:01 +0300 Subject: [PATCH] Shared default animations --- keyboards/ergodox/infinity/rules.mk | 3 +- .../ergodox/infinity/simple_visualizer.h | 2 +- keyboards/ergodox/infinity/visualizer.c | 2 +- keyboards/whitefox/animations.c | 128 ------------------ keyboards/whitefox/animations.h | 30 ---- keyboards/whitefox/rules.mk | 3 +- keyboards/whitefox/visualizer.c | 2 +- .../visualizer/default_animations.c | 28 +++- .../visualizer/default_animations.h | 6 +- quantum/visualizer/visualizer.mk | 2 + 10 files changed, 35 insertions(+), 171 deletions(-) delete mode 100644 keyboards/whitefox/animations.c delete mode 100644 keyboards/whitefox/animations.h rename keyboards/ergodox/infinity/animations.c => quantum/visualizer/default_animations.c (92%) rename keyboards/ergodox/infinity/animations.h => quantum/visualizer/default_animations.h (87%) diff --git a/keyboards/ergodox/infinity/rules.mk b/keyboards/ergodox/infinity/rules.mk index 18171560d..2ccf98b8c 100644 --- a/keyboards/ergodox/infinity/rules.mk +++ b/keyboards/ergodox/infinity/rules.mk @@ -1,7 +1,6 @@ # project specific files SRC = matrix.c \ - led.c \ - animations.c + led.c ## chip/board settings # - the next two should match the directories in diff --git a/keyboards/ergodox/infinity/simple_visualizer.h b/keyboards/ergodox/infinity/simple_visualizer.h index 88e96f2af..73d0e0887 100644 --- a/keyboards/ergodox/infinity/simple_visualizer.h +++ b/keyboards/ergodox/infinity/simple_visualizer.h @@ -34,7 +34,7 @@ #include "lcd_backlight_keyframes.h" #include "system/serial_link.h" #include "led.h" -#include "animations.h" +#include "default_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); diff --git a/keyboards/ergodox/infinity/visualizer.c b/keyboards/ergodox/infinity/visualizer.c index 047a1119c..4b16021ab 100644 --- a/keyboards/ergodox/infinity/visualizer.c +++ b/keyboards/ergodox/infinity/visualizer.c @@ -31,7 +31,7 @@ along with this program. If not, see . #include "lcd_keyframes.h" #include "lcd_backlight_keyframes.h" #include "system/serial_link.h" -#include "animations.h" +#include "default_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); diff --git a/keyboards/whitefox/animations.c b/keyboards/whitefox/animations.c deleted file mode 100644 index a15d46ccd..000000000 --- a/keyboards/whitefox/animations.c +++ /dev/null @@ -1,128 +0,0 @@ -/* 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 . - */ - -#if defined(VISUALIZER_ENABLE) - -#include "animations.h" -#include "visualizer.h" - -#ifdef BACKLIGHT_ENABLE -#include "led_backlight_keyframes.h" -#endif - -#include "visualizer_keyframes.h" - - -#if defined(LCD_ENABLE) || defined(LCD_BACKLIGHT_ENABLE) || defined(BACKLIGHT_ENABLE) - -static bool keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { -#ifdef BACKLIGHT_ENABLE - led_backlight_keyframe_enable(animation, state); -#endif - return false; -} - -static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { -#ifdef BACKLIGHT_ENABLE - led_backlight_keyframe_disable(animation, state); -#endif - return false; -} - -static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t* state) { - bool ret = false; -#ifdef BACKLIGHT_ENABLE - ret |= led_backlight_keyframe_fade_in_all(animation, state); -#endif - return ret; -} - -static bool keyframe_fade_out(keyframe_animation_t* animation, visualizer_state_t* state) { - bool ret = false; -#ifdef BACKLIGHT_ENABLE - ret |= led_backlight_keyframe_fade_out_all(animation, state); -#endif - return ret; -} - - -// 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 = 2, - .loop = false, - .frame_lengths = {0, gfxMillisecondsToTicks(5000)}, - .frame_functions = { - keyframe_enable, - keyframe_fade_in, - }, -}; - -keyframe_animation_t default_suspend_animation = { - .num_frames = 2, - .loop = false, - .frame_lengths = {gfxMillisecondsToTicks(1000), 0}, - .frame_functions = { - keyframe_fade_out, - keyframe_disable, - }, -}; -#endif - -#if defined(BACKLIGHT_ENABLE) -#define CROSSFADE_TIME 1000 -#define GRADIENT_TIME 3000 - -keyframe_animation_t led_test_animation = { - .num_frames = 14, - .loop = true, - .frame_lengths = { - gfxMillisecondsToTicks(1000), // fade in - gfxMillisecondsToTicks(1000), // no op (leds on) - gfxMillisecondsToTicks(1000), // fade out - gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade - gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in) - gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade - gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom - 0, // mirror leds - gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade - gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out) - gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade - gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom - 0, // normal leds - gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade - - }, - .frame_functions = { - led_backlight_keyframe_fade_in_all, - keyframe_no_operation, - led_backlight_keyframe_fade_out_all, - led_backlight_keyframe_crossfade, - led_backlight_keyframe_left_to_right_gradient, - led_backlight_keyframe_crossfade, - led_backlight_keyframe_top_to_bottom_gradient, - led_backlight_keyframe_mirror_orientation, - led_backlight_keyframe_crossfade, - led_backlight_keyframe_left_to_right_gradient, - led_backlight_keyframe_crossfade, - led_backlight_keyframe_top_to_bottom_gradient, - led_backlight_keyframe_normal_orientation, - led_backlight_keyframe_crossfade, - }, -}; -#endif - -#endif diff --git a/keyboards/whitefox/animations.h b/keyboards/whitefox/animations.h deleted file mode 100644 index 6d8b9830d..000000000 --- a/keyboards/whitefox/animations.h +++ /dev/null @@ -1,30 +0,0 @@ -/* 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 . - */ - -#ifndef KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ -#define KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ - -#include "visualizer.h" - -// You can use these default animations, but of course you can also write your own custom ones instead -extern keyframe_animation_t default_startup_animation; -extern keyframe_animation_t default_suspend_animation; - -// An animation for testing and demonstrating the led support, should probably not be used for real world -// cases -extern keyframe_animation_t led_test_animation; - -#endif /* KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ */ diff --git a/keyboards/whitefox/rules.mk b/keyboards/whitefox/rules.mk index c0effcb7b..391148071 100644 --- a/keyboards/whitefox/rules.mk +++ b/keyboards/whitefox/rules.mk @@ -1,7 +1,6 @@ # project specific files SRC = matrix.c \ - led.c \ - animations.c + led.c ## chip/board settings # - the next two should match the directories in diff --git a/keyboards/whitefox/visualizer.c b/keyboards/whitefox/visualizer.c index 167e0ec4d..e5bafcbe9 100644 --- a/keyboards/whitefox/visualizer.c +++ b/keyboards/whitefox/visualizer.c @@ -20,7 +20,7 @@ #include "visualizer.h" #include "visualizer_keyframes.h" #include "led.h" -#include "animations.h" +#include "default_animations.h" static bool initial_update = true; diff --git a/keyboards/ergodox/infinity/animations.c b/quantum/visualizer/default_animations.c similarity index 92% rename from keyboards/ergodox/infinity/animations.c rename to quantum/visualizer/default_animations.c index faac96215..2d0327372 100644 --- a/keyboards/ergodox/infinity/animations.c +++ b/quantum/visualizer/default_animations.c @@ -16,7 +16,7 @@ #if defined(VISUALIZER_ENABLE) -#include "animations.h" +#include "default_animations.h" #include "visualizer.h" #ifdef LCD_ENABLE #include "lcd_keyframes.h" @@ -86,22 +86,44 @@ static bool keyframe_fade_out(keyframe_animation_t* animation, visualizer_state_ // 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 = { +#if LCD_ENABLE .num_frames = 3, +#else + .num_frames = 2, +#endif .loop = false, - .frame_lengths = {0, 0, gfxMillisecondsToTicks(5000)}, + .frame_lengths = { + 0, +#if LCD_ENABLE + 0, +#endif + gfxMillisecondsToTicks(5000)}, .frame_functions = { keyframe_enable, +#if LCD_ENABLE lcd_keyframe_draw_logo, +#endif keyframe_fade_in, }, }; keyframe_animation_t default_suspend_animation = { +#if LCD_ENABLE .num_frames = 3, +#else + .num_frames = 2, +#endif .loop = false, - .frame_lengths = {0, gfxMillisecondsToTicks(1000), 0}, + .frame_lengths = { +#if LCD_ENABLE + 0, +#endif + gfxMillisecondsToTicks(1000), + 0}, .frame_functions = { +#if LCD_ENABLE lcd_keyframe_display_layer_text, +#endif keyframe_fade_out, keyframe_disable, }, diff --git a/keyboards/ergodox/infinity/animations.h b/quantum/visualizer/default_animations.h similarity index 87% rename from keyboards/ergodox/infinity/animations.h rename to quantum/visualizer/default_animations.h index 6d8b9830d..51320b8b8 100644 --- a/keyboards/ergodox/infinity/animations.h +++ b/quantum/visualizer/default_animations.h @@ -14,8 +14,8 @@ * along with this program. If not, see . */ -#ifndef KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ -#define KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ +#ifndef DEFAULT_ANIMATIONS_H_ +#define DEFAULT_ANIMATIONS_H_ #include "visualizer.h" @@ -27,4 +27,4 @@ extern keyframe_animation_t default_suspend_animation; // cases extern keyframe_animation_t led_test_animation; -#endif /* KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ */ +#endif /* DEFAULT_ANIMATIONS_H_ */ diff --git a/quantum/visualizer/visualizer.mk b/quantum/visualizer/visualizer.mk index a04c9775f..3a0f771bc 100644 --- a/quantum/visualizer/visualizer.mk +++ b/quantum/visualizer/visualizer.mk @@ -46,6 +46,8 @@ ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) SRC += $(VISUALIZER_DIR)/led_backlight_keyframes.c endif +SRC += $(VISUALIZER_DIR)/default_animations.c + include $(GFXLIB)/gfx.mk # For the common_gfxconf.h GFXINC += quantum/visualizer