diff --git a/Neopixel_Goggles.ino b/Neopixel_Goggles.ino --- a/Neopixel_Goggles.ino +++ b/Neopixel_Goggles.ino @@ -27,6 +27,9 @@ #define BLINK_MIN_INTERVAL 250 #define BLINK_MAX_INTERVAL 500 +#define SPINNER_PIXELS_MIN 1 +#define SPINNER_PIXELS_MAX 10 + // End config section enum pattern { @@ -38,7 +41,8 @@ enum pattern { RANDOM, DOUBLE_RANDOM, BLINK, - DOT + DOT, + SPINNER }; class NeoPatterns : public Adafruit_NeoPixel { @@ -50,6 +54,7 @@ class NeoPatterns : public Adafruit_NeoP uint32_t PixelColor; uint16_t TotalSteps; uint16_t Index; + uint8_t SpinnerPixels; void (*OnComplete)(); @@ -88,6 +93,9 @@ class NeoPatterns : public Adafruit_NeoP case DOT: DotUpdate(); break; + case SPINNER: + SpinnerUpdate(); + break; default: break; } @@ -251,6 +259,25 @@ class NeoPatterns : public Adafruit_NeoP Increment(); } + void Spinner(uint32_t color, uint16_t spinner_pixels, uint16_t interval) { + ActivePattern = SPINNER; + Interval = interval; + TotalSteps = 32; + PixelColor = color; + Index = 0; + SpinnerPixels = spinner_pixels; + } + + void SpinnerUpdate() { + ColorSet(Color(0, 0, 0)); + for (int i = 0; i < numPixels() / 2; i++) { + if ((Index + i) % SpinnerPixels == 0) { + DoubleSet(i, PixelColor); + } + } + Increment(); + } + uint32_t DimColor(uint32_t color) { return Color(((color >> 16) & 0xFF) >> 1, ((color >> 8) & 0xFF) >> 1, (color & 0xFF) >> 1); } @@ -346,6 +373,9 @@ void RingsComplete() { case 8: Rings.Dot(color, steps, slow_interval); break; + case 9: + Rings.Spinner(color, random(SPINNER_PIXELS_MIN, SPINNER_PIXELS_MAX + 1), slow_interval); + break; default: break; }