Rename led test to led_keyframes and move animation to Ergodox

This commit is contained in:
Fred Sundvik 2017-04-08 23:04:27 +03:00
parent 306353bf06
commit c5d2b7ff16
5 changed files with 78 additions and 61 deletions

View File

@ -14,6 +14,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#if defined(VISUALIZER_ENABLE)
#include "animations.h" #include "animations.h"
#include "visualizer.h" #include "visualizer.h"
#ifdef LCD_ENABLE #ifdef LCD_ENABLE
@ -23,7 +25,14 @@
#include "lcd_backlight_keyframes.h" #include "lcd_backlight_keyframes.h"
#endif #endif
#if defined(VISUALIZER_ENABLE) && defined(LCD_ENABLE) && defined(LCD_BACKLIGHT_ENABLE) #ifdef LED_ENABLE
#include "led_keyframes.h"
#endif
#include "visualizer_keyframes.h"
#if defined(LCD_ENABLE) && defined(LCD_BACKLIGHT_ENABLE)
// Don't worry, if the startup animation is long, you can use the keyboard like normal // Don't worry, if the startup animation is long, you can use the keyboard like normal
// during that time // during that time
@ -50,5 +59,49 @@ keyframe_animation_t default_suspend_animation = {
backlight_keyframe_disable, backlight_keyframe_disable,
}, },
}; };
#endif
#if defined(LED_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_keyframe_fade_in_all,
keyframe_no_operation,
led_keyframe_fade_out_all,
led_keyframe_crossfade,
led_keyframe_left_to_right_gradient,
led_keyframe_crossfade,
led_keyframe_top_to_bottom_gradient,
led_keyframe_mirror_orientation,
led_keyframe_crossfade,
led_keyframe_left_to_right_gradient,
led_keyframe_crossfade,
led_keyframe_top_to_bottom_gradient,
led_keyframe_normal_orientation,
led_keyframe_crossfade,
},
};
#endif
#endif #endif

View File

@ -19,7 +19,12 @@
#include "visualizer.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_startup_animation;
extern keyframe_animation_t default_suspend_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_ */ #endif /* KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ */

View File

@ -21,50 +21,9 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#include "led_test.h"
#include "gfx.h" #include "gfx.h"
#include "math.h" #include "math.h"
#include "led_keyframes.h"
#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 = {
keyframe_fade_in_all_leds,
keyframe_no_operation,
keyframe_fade_out_all_leds,
keyframe_led_crossfade,
keyframe_led_left_to_right_gradient,
keyframe_led_crossfade,
keyframe_led_top_to_bottom_gradient,
keyframe_mirror_led_orientation,
keyframe_led_crossfade,
keyframe_led_left_to_right_gradient,
keyframe_led_crossfade,
keyframe_led_top_to_bottom_gradient,
keyframe_normal_led_orientation,
keyframe_led_crossfade,
},
};
static uint8_t fade_led_color(keyframe_animation_t* animation, int from, int to) { static uint8_t fade_led_color(keyframe_animation_t* animation, int from, int to) {
int frame_length = animation->frame_lengths[animation->current_frame]; 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) {
return (uint8_t)(255.0f * v); return (uint8_t)(255.0f * v);
} }
bool keyframe_fade_in_all_leds(keyframe_animation_t* animation, visualizer_state_t* state) { bool led_keyframe_fade_in_all(keyframe_animation_t* animation, visualizer_state_t* state) {
(void)state; (void)state;
keyframe_fade_all_leds_from_to(animation, 0, 255); keyframe_fade_all_leds_from_to(animation, 0, 255);
return true; return true;
} }
bool keyframe_fade_out_all_leds(keyframe_animation_t* animation, visualizer_state_t* state) { bool led_keyframe_fade_out_all(keyframe_animation_t* animation, visualizer_state_t* state) {
(void)state; (void)state;
keyframe_fade_all_leds_from_to(animation, 255, 0); keyframe_fade_all_leds_from_to(animation, 255, 0);
return true; return true;
} }
bool keyframe_led_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { bool led_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state) {
(void)state; (void)state;
float frame_length = animation->frame_lengths[animation->current_frame]; float frame_length = animation->frame_lengths[animation->current_frame];
float current_pos = frame_length - animation->time_left_in_frame; 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
return true; return true;
} }
bool keyframe_led_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { bool led_keyframe_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state) {
(void)state; (void)state;
float frame_length = animation->frame_lengths[animation->current_frame]; float frame_length = animation->frame_lengths[animation->current_frame];
float current_pos = frame_length - animation->time_left_in_frame; float current_pos = frame_length - animation->time_left_in_frame;
@ -139,7 +98,7 @@ static void copy_current_led_state(uint8_t* dest) {
} }
} }
} }
bool keyframe_led_crossfade(keyframe_animation_t* animation, visualizer_state_t* state) { bool led_keyframe_crossfade(keyframe_animation_t* animation, visualizer_state_t* state) {
(void)state; (void)state;
if (animation->first_update_of_frame) { if (animation->first_update_of_frame) {
copy_current_led_state(&crossfade_start_frame[0][0]); copy_current_led_state(&crossfade_start_frame[0][0]);
@ -155,14 +114,14 @@ bool keyframe_led_crossfade(keyframe_animation_t* animation, visualizer_state_t*
return true; return true;
} }
bool keyframe_mirror_led_orientation(keyframe_animation_t* animation, visualizer_state_t* state) { bool led_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state) {
(void)state; (void)state;
(void)animation; (void)animation;
gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_180); gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_180);
return false; return false;
} }
bool keyframe_normal_led_orientation(keyframe_animation_t* animation, visualizer_state_t* state) { bool led_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state) {
(void)state; (void)state;
(void)animation; (void)animation;
gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_0); gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_0);

View File

@ -22,20 +22,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#ifndef TMK_VISUALIZER_LED_TEST_H_ #ifndef LED_KEYFRAMES_H
#define TMK_VISUALIZER_LED_TEST_H_ #define LED_KEYFRAMES_H
#include "visualizer.h" #include "visualizer.h"
bool keyframe_fade_in_all_leds(keyframe_animation_t* animation, visualizer_state_t* state); bool led_keyframe_fade_in_all(keyframe_animation_t* animation, visualizer_state_t* state);
bool keyframe_fade_out_all_leds(keyframe_animation_t* animation, visualizer_state_t* state); bool led_keyframe_fade_out_all(keyframe_animation_t* animation, visualizer_state_t* state);
bool keyframe_led_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state); bool led_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state);
bool keyframe_led_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state); bool led_keyframe_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state);
bool keyframe_led_crossfade(keyframe_animation_t* animation, visualizer_state_t* state); bool led_keyframe_crossfade(keyframe_animation_t* animation, visualizer_state_t* state);
bool keyframe_mirror_led_orientation(keyframe_animation_t* animation, visualizer_state_t* state); bool led_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state);
bool keyframe_normal_led_orientation(keyframe_animation_t* animation, visualizer_state_t* state); bool led_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state);
extern keyframe_animation_t led_test_animation; extern keyframe_animation_t led_test_animation;
#endif /* TMK_VISUALIZER_LED_TEST_H_ */ #endif /* LED_KEYFRAMES_H */

View File

@ -43,7 +43,7 @@ OPT_DEFS += -DLCD_BACKLIGHT_ENABLE
endif endif
ifeq ($(strip $(LED_ENABLE)), yes) ifeq ($(strip $(LED_ENABLE)), yes)
SRC += $(VISUALIZER_DIR)/led_test.c SRC += $(VISUALIZER_DIR)/led_keyframes.c
OPT_DEFS += -DLED_ENABLE OPT_DEFS += -DLED_ENABLE
endif endif