Skip to content

Commit

Permalink
Fixing replace conditions
Browse files Browse the repository at this point in the history
- Was not exiting switch/case correctly (might have fallen through
unexpectedly)
- Added condition to replace:state where the index must also be matched
(should make it more useful)
- Should fix Issue #306
  • Loading branch information
haata committed Mar 17, 2019
1 parent ff26c9d commit 51b1fb2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Macro/PixelMap/pixel.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ uint8_t Pixel_addAnimation( AnimationStackElement *element, CapabilityState csta
found->state = element->state;
return 0;
}
break;

// Replace on press and release
// Press starts the animation
Expand All @@ -834,7 +835,7 @@ uint8_t Pixel_addAnimation( AnimationStackElement *element, CapabilityState csta
// Press
case CapabilityState_Initial:
// If found, modify stack element
if ( found )
if ( found && found->trigger == element->trigger )
{
found->pos = element->pos;
found->subpos = element->subpos;
Expand All @@ -852,7 +853,7 @@ uint8_t Pixel_addAnimation( AnimationStackElement *element, CapabilityState csta
// Release
case CapabilityState_Last:
// Only need to do something if the animation was found (which is stop)
if ( found )
if ( found && found->trigger == element->trigger )
{
found->state = AnimationPlayState_Stop;
}
Expand All @@ -861,6 +862,7 @@ uint8_t Pixel_addAnimation( AnimationStackElement *element, CapabilityState csta
default:
break;
}
break;

// Clear all current animations from stack before adding new animation
case AnimationReplaceType_Clear:
Expand Down

0 comments on commit 51b1fb2

Please sign in to comment.