Skip to content

Commit

Permalink
Ensures at least 1 Chaser for Chaser pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
LivingSynthesis committed Nov 18, 2023
1 parent a3e0281 commit f937792
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions VortexEngine/src/Patterns/Multi/Sequencer/ChaserPattern.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
#include "ChaserPattern.h"

// This controlls the ratio of chaser dots to LED_COUNT. Default 1 chaser per 7 LEDs.
// This controlls the ratio of chaser dots to LED_COUNT. Default 1 chaser per 7 LEDs. Range: 1-LED_COUNT.
#define CHASER_RATIO 7


// This pattern aims to be a demonstration of the sequencer.
// There are always many ways to implement a pattern, it's best
// to choose the method that is most suitable for the pattern.
ChaserPattern::ChaserPattern(const PatternArgs &args) :
SequencedPattern(args)
{
setArgs(args);

// Makes sure there is at least 1 chaser
uint8_t numChasers = LED_COUNT / CHASER_RATIO;
if (!numChasers) {
numChasers = 1;
}
// set the pattern ID
//m_patternID = PATTERN_CHASER;
// There are LED_COUNT steps in the chaser, so iterate LED_COUNT times and generate
Expand All @@ -26,9 +33,9 @@ ChaserPattern::ChaserPattern(const PatternArgs &args) :
// which will use the 0th color from the colorset as the solid color.
// An LedMap is a bitmap that indicates which leds are turned on or off
// at any given time. This will generate an Led Map based on the current
LedMap overrideLeds = 0;
LedMap overrideLeds = 0;
// This creates an led map with 1 chaser per CHASER_RATIO (default 7) leds in LED_COUNT
for (int chaserCount = 0; chaserCount < (LED_COUNT / CHASER_RATIO); ++chaserCount) {
for (int chaserCount = 0; chaserCount < numChasers; ++chaserCount) {
overrideLeds |= MAP_LED((i + (chaserCount * CHASER_RATIO)) % LED_COUNT);
}
// Then this API is used to override specific positions in the Pattern Map
Expand Down

0 comments on commit f937792

Please sign in to comment.