Skip to content

Commit 51b1fb2

Browse files
committed
Fixing replace conditions
- 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
1 parent ff26c9d commit 51b1fb2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: Macro/PixelMap/pixel.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,7 @@ uint8_t Pixel_addAnimation( AnimationStackElement *element, CapabilityState csta
822822
found->state = element->state;
823823
return 0;
824824
}
825+
break;
825826

826827
// Replace on press and release
827828
// Press starts the animation
@@ -834,7 +835,7 @@ uint8_t Pixel_addAnimation( AnimationStackElement *element, CapabilityState csta
834835
// Press
835836
case CapabilityState_Initial:
836837
// If found, modify stack element
837-
if ( found )
838+
if ( found && found->trigger == element->trigger )
838839
{
839840
found->pos = element->pos;
840841
found->subpos = element->subpos;
@@ -852,7 +853,7 @@ uint8_t Pixel_addAnimation( AnimationStackElement *element, CapabilityState csta
852853
// Release
853854
case CapabilityState_Last:
854855
// Only need to do something if the animation was found (which is stop)
855-
if ( found )
856+
if ( found && found->trigger == element->trigger )
856857
{
857858
found->state = AnimationPlayState_Stop;
858859
}
@@ -861,6 +862,7 @@ uint8_t Pixel_addAnimation( AnimationStackElement *element, CapabilityState csta
861862
default:
862863
break;
863864
}
865+
break;
864866

865867
// Clear all current animations from stack before adding new animation
866868
case AnimationReplaceType_Clear:

0 commit comments

Comments
 (0)