]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Add function for running the next keyframe
authorFred Sundvik <fsundvik@gmail.com>
Sun, 24 Apr 2016 13:19:31 +0000 (16:19 +0300)
committerFred Sundvik <fsundvik@gmail.com>
Sun, 24 Apr 2016 13:19:31 +0000 (16:19 +0300)
visualizer.c
visualizer.h

index 219d44cd3cdd41ffa38b133e3702022dac77b13f..2ec6e34f5862b1d90477c26513210fe7a6543b62 100644 (file)
@@ -178,6 +178,21 @@ static bool update_keyframe_animation(keyframe_animation_t* animation, visualize
     return true;
 }
 
+void run_next_keyframe(keyframe_animation_t* animation, visualizer_state_t* state) {
+    int next_frame = animation->current_frame + 1;
+    if (next_frame == animation->num_frames) {
+        next_frame = 0;
+    }
+    keyframe_animation_t temp_animation = *animation;
+    temp_animation.current_frame = next_frame;
+    temp_animation.time_left_in_frame = animation->frame_lengths[next_frame];
+    temp_animation.first_update_of_frame = true;
+    temp_animation.last_update_of_frame = false;
+    temp_animation.need_update  = false;
+    visualizer_state_t temp_state = *state;
+    (*temp_animation.frame_functions[next_frame])(&temp_animation, &temp_state);
+}
+
 bool keyframe_no_operation(keyframe_animation_t* animation, visualizer_state_t* state) {
     (void)animation;
     (void)state;
index 82d7a71d37a80d61d5f6372e2d34bb0ccabfbdbe..5375e0130fbe66f61079bd3eb2eb8b837795d37a 100644 (file)
@@ -106,6 +106,9 @@ extern GDisplay* LED_DISPLAY;
 
 void start_keyframe_animation(keyframe_animation_t* animation);
 void stop_keyframe_animation(keyframe_animation_t* animation);
+// This runs the next keyframe, but does not update the animation state
+// Useful for crossfades for example
+void run_next_keyframe(keyframe_animation_t* animation, visualizer_state_t* state);
 
 // Some predefined keyframe functions that can be used by the user code
 // Does nothing, useful for adding delays