Skip to content

Adding method to remove patterns by index. #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: init
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/qpLayer.cpp
Original file line number Diff line number Diff line change
@@ -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);
2 changes: 2 additions & 0 deletions src/qpLayer.h
Original file line number Diff line number Diff line change
@@ -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);
1 change: 1 addition & 0 deletions src/qpLinkedList.h
Original file line number Diff line number Diff line change
@@ -112,6 +112,7 @@ class qpLinkedList {

delete current->item;
delete current;
numElements--;
return true;
}

2 changes: 1 addition & 1 deletion src/qpPattern.cpp
Original file line number Diff line number Diff line change
@@ -101,7 +101,7 @@ bool qpPattern::activate() {

this->activations++;

this->nextRenderTick = this->ticks;
this->nextRenderTick = this->ticks + 1;

this->onActivate();

2 changes: 1 addition & 1 deletion src/qpPattern.h
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ class qpPattern {
// ~ Animation speed

int ticksBetweenFrames = 1;
int nextRenderTick = 1;
unsigned long nextRenderTick = 1;

// ~ Periodic activation

2 changes: 1 addition & 1 deletion src/quickPatterns.cpp
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ quickPatterns::~quickPatterns() {

bool quickPatterns::draw() {

uint32_t currentMillis = millis();
unsigned long currentMillis = millis();

if(currentMillis >= this->nextTickMillis) {

2 changes: 1 addition & 1 deletion src/quickPatterns.h
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ class quickPatterns {
private:

short tickLengthInMillis = 25;
uint32_t nextTickMillis = 0;
unsigned long nextTickMillis = 0;

qpLightStrand *lightStrand;