|
@@ -24,35 +24,40 @@
|
|
|
#define RAINBOW_CYCLE_MIN_INTERVAL 1
|
|
|
#define RAINBOW_CYCLE_MAX_INTERVAL 10
|
|
|
|
|
|
#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 {
|
|
|
RAINBOW_CYCLE,
|
|
|
COLOR_WIPE,
|
|
|
DOUBLE_COLOR_WIPE,
|
|
|
SCANNER,
|
|
|
DOUBLE_SCANNER,
|
|
|
RANDOM,
|
|
|
DOUBLE_RANDOM,
|
|
|
BLINK,
|
|
|
DOT
|
|
|
DOT,
|
|
|
SPINNER
|
|
|
};
|
|
|
|
|
|
class NeoPatterns : public Adafruit_NeoPixel {
|
|
|
public:
|
|
|
pattern ActivePattern;
|
|
|
|
|
|
uint16_t Interval;
|
|
|
unsigned long lastUpdate;
|
|
|
uint32_t PixelColor;
|
|
|
uint16_t TotalSteps;
|
|
|
uint16_t Index;
|
|
|
uint8_t SpinnerPixels;
|
|
|
|
|
|
void (*OnComplete)();
|
|
|
|
|
|
NeoPatterns(uint16_t pixels, uint8_t pin, uint8_t type, void (*callback)()) : Adafruit_NeoPixel(pixels, pin, type) {
|
|
|
OnComplete = callback;
|
|
|
}
|
|
@@ -85,12 +90,15 @@ class NeoPatterns : public Adafruit_NeoP
|
|
|
case BLINK:
|
|
|
BlinkUpdate();
|
|
|
break;
|
|
|
case DOT:
|
|
|
DotUpdate();
|
|
|
break;
|
|
|
case SPINNER:
|
|
|
SpinnerUpdate();
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -248,12 +256,31 @@ class NeoPatterns : public Adafruit_NeoP
|
|
|
ColorSet(Color(0, 0, 0));
|
|
|
show();
|
|
|
setPixelColor(random(numPixels()), PixelColor);
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
uint32_t Wheel(byte WheelPos) {
|
|
|
WheelPos = 255 - WheelPos;
|
|
@@ -343,10 +370,13 @@ void RingsComplete() {
|
|
|
case 7:
|
|
|
Rings.Blink(color, steps, random(BLINK_MIN_INTERVAL, BLINK_MAX_INTERVAL + 1));
|
|
|
break;
|
|
|
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;
|
|
|
}
|
|
|
}
|