MCPcopy Create free account
hub / github.com/kiibohd/controller / Pixel_animationProcess

Function Pixel_animationProcess

Macro/PixelMap/pixel.c:2061–2157  ·  view source on GitHub ↗

Process the animation stack element - Returns 1 if the animation should be re-added to the stack - Returns 0 if the animation is finished (clean-up memory)

Source from the content-addressed store, hash-verified

2059// - Returns 1 if the animation should be re-added to the stack
2060// - Returns 0 if the animation is finished (clean-up memory)
2061uint8_t Pixel_animationProcess( AnimationStackElement *elem )
2062{
2063 // Skip if index has been invalidate (unset)
2064 if ( elem->index == 0xFFFF )
2065 {
2066 return 0;
2067 }
2068
2069 // Check the play state
2070 switch ( elem->state & 0x7F )
2071 {
2072 // Pause animation (paused animations will take up animation stack memory)
2073 case AnimationPlayState_Pause:
2074 return 1;
2075
2076 // Stopping animation (frees animation from stack memory)
2077 case AnimationPlayState_Stop:
2078 // Indicate animation slot is free
2079 elem->index = 0xFFFF;
2080 return 0;
2081
2082 // Single frame of the animation
2083 // Set to paused afterwards
2084 case AnimationPlayState_Single:
2085 elem->state = AnimationPlayState_Pause;
2086 break;
2087
2088 // Do nothing
2089 case AnimationPlayState_Start:
2090 default:
2091 break;
2092 }
2093
2094 // Lookup animation frame to make sure we have something to do
2095 // TODO Make sure animation index exists -HaaTa
2096 const uint8_t *data = Pixel_Animations[elem->index][elem->pos];
2097
2098 // If there is no frame data, that means we either stop, or restart
2099 if ( data == 0 )
2100 {
2101 // Check if we still have more loops, one signifies stop, 0 is infinite
2102 if ( elem->loops == 0 || elem->loops-- > 1 )
2103 {
2104 elem->pos = 0;
2105
2106 // Signal that animation is repeating
2107 Macro_animationState( elem->index, ScheduleType_Repeat );
2108
2109 return Pixel_animationProcess( elem );
2110 }
2111 // Stop animation
2112 else
2113 {
2114 // Indicate animation slot is free
2115 elem->index = 0xFFFF;
2116 return 0;
2117 }
2118 }

Callers 1

Pixel_stackProcessFunction · 0.85

Calls 3

Macro_animationStateFunction · 0.85
Pixel_frameTweenStandardFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…