diff options
| author | Fred Sundvik <fsundvik@gmail.com> | 2016-04-24 16:19:31 +0300 |
|---|---|---|
| committer | Fred Sundvik <fsundvik@gmail.com> | 2016-04-24 16:19:31 +0300 |
| commit | 891edbd533acdffec66416c59f4b6066e5e18aaa (patch) | |
| tree | e88c14219a4b83148f78d047ced1d6d631644169 | |
| parent | 444132edd056cd52a60e3551d1f6c1a07909c040 (diff) | |
| download | qmk_firmware-891edbd533acdffec66416c59f4b6066e5e18aaa.tar.gz qmk_firmware-891edbd533acdffec66416c59f4b6066e5e18aaa.zip | |
Add function for running the next keyframe
| -rw-r--r-- | visualizer.c | 15 | ||||
| -rw-r--r-- | visualizer.h | 3 |
2 files changed, 18 insertions, 0 deletions
diff --git a/visualizer.c b/visualizer.c index 219d44cd3..2ec6e34f5 100644 --- a/visualizer.c +++ b/visualizer.c | |||
| @@ -178,6 +178,21 @@ static bool update_keyframe_animation(keyframe_animation_t* animation, visualize | |||
| 178 | return true; | 178 | return true; |
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | void run_next_keyframe(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 182 | int next_frame = animation->current_frame + 1; | ||
| 183 | if (next_frame == animation->num_frames) { | ||
| 184 | next_frame = 0; | ||
| 185 | } | ||
| 186 | keyframe_animation_t temp_animation = *animation; | ||
| 187 | temp_animation.current_frame = next_frame; | ||
| 188 | temp_animation.time_left_in_frame = animation->frame_lengths[next_frame]; | ||
| 189 | temp_animation.first_update_of_frame = true; | ||
| 190 | temp_animation.last_update_of_frame = false; | ||
| 191 | temp_animation.need_update = false; | ||
| 192 | visualizer_state_t temp_state = *state; | ||
| 193 | (*temp_animation.frame_functions[next_frame])(&temp_animation, &temp_state); | ||
| 194 | } | ||
| 195 | |||
| 181 | bool keyframe_no_operation(keyframe_animation_t* animation, visualizer_state_t* state) { | 196 | bool keyframe_no_operation(keyframe_animation_t* animation, visualizer_state_t* state) { |
| 182 | (void)animation; | 197 | (void)animation; |
| 183 | (void)state; | 198 | (void)state; |
diff --git a/visualizer.h b/visualizer.h index 82d7a71d3..5375e0130 100644 --- a/visualizer.h +++ b/visualizer.h | |||
| @@ -106,6 +106,9 @@ extern GDisplay* LED_DISPLAY; | |||
| 106 | 106 | ||
| 107 | void start_keyframe_animation(keyframe_animation_t* animation); | 107 | void start_keyframe_animation(keyframe_animation_t* animation); |
| 108 | void stop_keyframe_animation(keyframe_animation_t* animation); | 108 | void stop_keyframe_animation(keyframe_animation_t* animation); |
| 109 | // This runs the next keyframe, but does not update the animation state | ||
| 110 | // Useful for crossfades for example | ||
| 111 | void run_next_keyframe(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 109 | 112 | ||
| 110 | // Some predefined keyframe functions that can be used by the user code | 113 | // Some predefined keyframe functions that can be used by the user code |
| 111 | // Does nothing, useful for adding delays | 114 | // Does nothing, useful for adding delays |
