ANIM
Description
Performs linear interpolations and holds at specific milisecond periods to
animate an initial uint32_t value. Use cases include LED vibrant
patterns and display flashes.
Design and development status
Feature-complete.
Changelog
Version |
Date* |
Author |
Comment |
|---|---|---|---|
1.0.0 |
2022.9.7 |
sgermino |
Initial release. |
* Date format is Year.Month.Day.
API reference
-
ANIM_REPEAT_FOREVER
Pass this value on the
repeatparameter ofANIM_Start()to perpetually repeat an animation.
-
enum ANIM_Type
Specifies the animation flow to follow through
begin,end,delay,phaseanddurationparameters ofANIM_Start().-
enumerator ANIM_Type_None
No animation / animation finished. Static value assigned.
-
enumerator ANIM_Type_Blink
Holds
vBeginvalue untildelaymilliseconds passed. Then linear interpolatesvBeginthroughvEndinphasemilliseconds.vEndvalue is on hold until completion of the animation timedurationalso in milliseconds.
-
enumerator ANIM_Type_PingPong
Holds
vBeginvalue untildelaymilliseconds passed. Then linear interpolatesvBeginthroughvEndinphasemilliseconds. Finally, there is a linear interpolation fromvEndtovBeginthrough the rest of the animation timeduration, also expressed inmilliseconds.
-
enumerator ANIM_Type_None
-
struct ANIM
The user should treat this as an opaque structure. No member should be directly accessed or modified.
-
void ANIM_Start(struct ANIM *const A, const enum ANIM_Type Type, const uint32_t VBegin, const uint32_t VEnd, const uint32_t Delay, const uint32_t Phase, const uint32_t Duration, const uint32_t Repeat)
Start to process an animation according to passed parameters.
- Parameters
Type – Animation flow to follow.
VBegin – Interpolated value initial state.
VEnd – Interpolated value end state.
Delay – Amount of milliseconds to stop at
VBegin.Phase –
VBegintoVEndperiod, in milliseconds.Duration – Total duration, including
DelayandPhase, in milliseconds. Depends on animation type, seeANIM_Type.Repeat – Animation repeat count. For infinite repeats use
ANIM_REPEAT_FOREVER.
-
void ANIM_TimeShift(struct ANIM *const A, const uint32_t Delta)
Used to fast-forward an animation. Repeatedly going back and forth in time may cause undefined behavior. You have been warned.
- Parameters
Delta – Amount of time to fast-forward the animation, in milliseconds.
-
void ANIM_Update(struct ANIM *const A)
Update animation state with millisecond granularity at most.
-
void ANIM_SetValue(struct ANIM *const A, const uint32_t Value)
Set a static current value. The animation type will be set to
ANIM_Type.ANIM_Type_None. This is usually used to stop an ongoing animation.- Parameters
Value – New current, static value.
-
uint32_t ANIM_GetValue(struct ANIM *const A)
Get current value.
- Returns
Animation current value. Depends on
ANIM_Type.
-
_Bool ANIM_Pending(struct ANIM *const A)
Get pending status. An animation is pending when its current type is other than
ANIM_Type.ANIM_Type_None.- Returns
trueif pending,falseotherwise.