fix: neopattern example wdt reset
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
NeoPattern::NeoPattern(uint16_t pixels, uint8_t pin, uint8_t type, void (*callback)(int))
|
||||
: Adafruit_NeoPixel(pixels, pin, type)
|
||||
{
|
||||
frameBuffer = (uint8_t *)malloc(768);
|
||||
OnComplete = callback;
|
||||
TotalSteps = numPixels();
|
||||
begin();
|
||||
@@ -13,40 +12,21 @@ NeoPattern::NeoPattern(uint16_t pixels, uint8_t pin, uint8_t type, void (*callba
|
||||
NeoPattern::NeoPattern(uint16_t pixels, uint8_t pin, uint8_t type)
|
||||
: Adafruit_NeoPixel(pixels, pin, type)
|
||||
{
|
||||
frameBuffer = (uint8_t *)malloc(768);
|
||||
TotalSteps = numPixels();
|
||||
begin();
|
||||
}
|
||||
|
||||
NeoPattern::~NeoPattern() {
|
||||
if (frameBuffer) {
|
||||
free(frameBuffer);
|
||||
}
|
||||
// No frameBuffer to clean up
|
||||
}
|
||||
|
||||
void NeoPattern::handleStream(uint8_t *data, size_t len)
|
||||
{
|
||||
//const uint16_t *data16 = (uint16_t *)data;
|
||||
bufferSize = len;
|
||||
memcpy(frameBuffer, data, len);
|
||||
}
|
||||
|
||||
void NeoPattern::drawFrameBuffer(int w, uint8_t *frame, int length)
|
||||
{
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
uint8_t r = frame[i];
|
||||
uint8_t g = frame[i + 1];
|
||||
uint8_t b = frame[i + 2];
|
||||
setPixelColor(i, r, g, b);
|
||||
}
|
||||
}
|
||||
// Removed unused handleStream and drawFrameBuffer functions
|
||||
|
||||
void NeoPattern::onCompleteDefault(int pixels)
|
||||
{
|
||||
//Serial.println("onCompleteDefault");
|
||||
// FIXME no specific code
|
||||
if (ActivePattern == THEATER_CHASE)
|
||||
if (ActivePattern == THEATER_CHASE || ActivePattern == RAINBOW_CYCLE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -127,7 +107,12 @@ void NeoPattern::RainbowCycleUpdate()
|
||||
setPixelColor(i, Wheel(((i * 256 / numPixels()) + Index) & 255));
|
||||
}
|
||||
show();
|
||||
Increment();
|
||||
// RainbowCycle is continuous, just increment Index
|
||||
Index++;
|
||||
if (Index >= 255)
|
||||
{
|
||||
Index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize for a Theater Chase
|
||||
|
||||
Reference in New Issue
Block a user