diff --git a/src/qpLayer.cpp b/src/qpLayer.cpp index 8e7145e..fd2dfd6 100644 --- a/src/qpLayer.cpp +++ b/src/qpLayer.cpp @@ -182,6 +182,21 @@ qpPattern &qpLayer::pattern(byte patternIndex) { return *this->lastReferencedPattern; } +byte qpLayer::numberOfPatterns() { + return this->patterns.numElements; +} + +void qpLayer::removePattern(byte patternIndex) { + qpPattern* pattern = this->patterns.getItem(patternIndex); + if (pattern == nullptr) { + return; + } + if(this->lastReferencedPattern == pattern) { + this->lastReferencedPattern = nullptr; + } + this->patterns.remove(patternIndex); +} + qpPattern &qpLayer::operator()(byte patternIndex) { return this->pattern(patternIndex); diff --git a/src/qpLayer.h b/src/qpLayer.h index f7aea19..c12cc04 100644 --- a/src/qpLayer.h +++ b/src/qpLayer.h @@ -65,6 +65,8 @@ class qpLayer { // Patterns qpPattern &pattern(byte patternIndex); qpPattern &samePattern() { return *this->lastReferencedPattern; } + byte numberOfPatterns(); + void removePattern(byte patternIndex); // Quick access operators qpPattern &operator()(byte patternIndex); diff --git a/src/qpLinkedList.h b/src/qpLinkedList.h index 196fbac..c666757 100644 --- a/src/qpLinkedList.h +++ b/src/qpLinkedList.h @@ -112,6 +112,7 @@ class qpLinkedList { delete current->item; delete current; + numElements--; return true; } diff --git a/src/qpPattern.cpp b/src/qpPattern.cpp index b58211c..c5c8f3d 100644 --- a/src/qpPattern.cpp +++ b/src/qpPattern.cpp @@ -101,7 +101,7 @@ bool qpPattern::activate() { this->activations++; - this->nextRenderTick = this->ticks; + this->nextRenderTick = this->ticks + 1; this->onActivate(); diff --git a/src/qpPattern.h b/src/qpPattern.h index e2694c8..2bc1e09 100644 --- a/src/qpPattern.h +++ b/src/qpPattern.h @@ -17,7 +17,7 @@ class qpPattern { // ~ Animation speed int ticksBetweenFrames = 1; - int nextRenderTick = 1; + unsigned long nextRenderTick = 1; // ~ Periodic activation diff --git a/src/quickPatterns.cpp b/src/quickPatterns.cpp index bea4ae4..0a779f0 100644 --- a/src/quickPatterns.cpp +++ b/src/quickPatterns.cpp @@ -12,7 +12,7 @@ quickPatterns::~quickPatterns() { bool quickPatterns::draw() { - uint32_t currentMillis = millis(); + unsigned long currentMillis = millis(); if(currentMillis >= this->nextTickMillis) { diff --git a/src/quickPatterns.h b/src/quickPatterns.h index 23be060..4aba17e 100644 --- a/src/quickPatterns.h +++ b/src/quickPatterns.h @@ -43,7 +43,7 @@ class quickPatterns { private: short tickLengthInMillis = 25; - uint32_t nextTickMillis = 0; + unsigned long nextTickMillis = 0; qpLightStrand *lightStrand;