improve readability of fadeInOut-example (#235)

This commit is contained in:
Michael Dörsam
2018-11-09 11:05:42 +01:00
committed by Michael Miller
parent 6ca73195fb
commit be03ec62c7

View File

@@ -22,7 +22,7 @@ NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
NeoPixelAnimator animations(AnimationChannels); // NeoPixel animation management object NeoPixelAnimator animations(AnimationChannels); // NeoPixel animation management object
uint16_t effectState = 0; // general purpose variable used to store effect state boolean fadeToColor = true; // general purpose variable used to store effect state
// what is stored for state is specific to the need, in this case, the colors. // what is stored for state is specific to the need, in this case, the colors.
@@ -75,7 +75,7 @@ void BlendAnimUpdate(const AnimationParam& param)
void FadeInFadeOutRinseRepeat(float luminance) void FadeInFadeOutRinseRepeat(float luminance)
{ {
if (effectState == 0) if (fadeToColor)
{ {
// Fade upto a random color // Fade upto a random color
// we use HslColor object as it allows us to easily pick a hue // we use HslColor object as it allows us to easily pick a hue
@@ -89,7 +89,7 @@ void FadeInFadeOutRinseRepeat(float luminance)
animations.StartAnimation(0, time, BlendAnimUpdate); animations.StartAnimation(0, time, BlendAnimUpdate);
} }
else if (effectState == 1) else
{ {
// fade to black // fade to black
uint16_t time = random(600, 700); uint16_t time = random(600, 700);
@@ -101,7 +101,7 @@ void FadeInFadeOutRinseRepeat(float luminance)
} }
// toggle to the next effect state // toggle to the next effect state
effectState = (effectState + 1) % 2; fadeToColor = !fadeToColor;
} }
void setup() void setup()