Skip to content

Commit be03ec6

Browse files
mdoersamMakuna
authored andcommitted
improve readability of fadeInOut-example (#235)
1 parent 6ca7319 commit be03ec6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Diff for: examples/animations/NeoPixelFunFadeInOut/NeoPixelFunFadeInOut.ino

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
2222

2323
NeoPixelAnimator animations(AnimationChannels); // NeoPixel animation management object
2424

25-
uint16_t effectState = 0; // general purpose variable used to store effect state
25+
boolean fadeToColor = true; // general purpose variable used to store effect state
2626

2727

2828
// what is stored for state is specific to the need, in this case, the colors.
@@ -75,7 +75,7 @@ void BlendAnimUpdate(const AnimationParam& param)
7575

7676
void FadeInFadeOutRinseRepeat(float luminance)
7777
{
78-
if (effectState == 0)
78+
if (fadeToColor)
7979
{
8080
// Fade upto a random color
8181
// we use HslColor object as it allows us to easily pick a hue
@@ -89,7 +89,7 @@ void FadeInFadeOutRinseRepeat(float luminance)
8989

9090
animations.StartAnimation(0, time, BlendAnimUpdate);
9191
}
92-
else if (effectState == 1)
92+
else
9393
{
9494
// fade to black
9595
uint16_t time = random(600, 700);
@@ -101,7 +101,7 @@ void FadeInFadeOutRinseRepeat(float luminance)
101101
}
102102

103103
// toggle to the next effect state
104-
effectState = (effectState + 1) % 2;
104+
fadeToColor = !fadeToColor;
105105
}
106106

107107
void setup()

0 commit comments

Comments
 (0)