Skip to content

Commit

Permalink
Daniel/orbit/multi pat arg audit (#151)
Browse files Browse the repository at this point in the history
* adjusted args for multi pats

* recorded tests

* Some core fixes
  • Loading branch information
Unreal-Dan authored Dec 8, 2023
1 parent 0248732 commit 442dcb5
Show file tree
Hide file tree
Showing 36 changed files with 19,716 additions and 19,709 deletions.
4 changes: 4 additions & 0 deletions VortexEngine/src/Log/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "VortexLib.h"
#endif

#ifdef VORTEX_EMBEDDED
#include <Arduino.h>
#endif

#if LOGGING_LEVEL > 0
void InfoMsg(const char *msg, ...)
{
Expand Down
10 changes: 6 additions & 4 deletions VortexEngine/src/Patterns/Multi/MeteorPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ void MeteorPattern::blinkOff()

void MeteorPattern::poststep()
{
// when a new meteor is created it is incerted into the stash so the blinking pattern is not interrupted
LedPos target = (LedPos)m_randCtx.next8(LED_FIRST, LED_LAST);
RGBColor col = m_colorset.getNext();
m_stash.setIndex(target, col);
for (uint8_t meteorCount = 0; meteorCount < (LED_COUNT / 2); ++meteorCount) {
// when a new meteor is created it is incerted into the stash so the blinking pattern is not interrupted
LedPos target = (LedPos)m_randCtx.next8(LED_FIRST, LED_LAST);
RGBColor col = m_colorset.getNext();
m_stash.setIndex(target, col);
}
}
49 changes: 25 additions & 24 deletions VortexEngine/src/Patterns/Multi/Sequencer/ChaserPattern.cpp
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
#include "ChaserPattern.h"

// This controls 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
uint32_t numChasers = LED_COUNT / CHASER_RATIO;
if (!numChasers) {
numChasers = 1;
}
// set the pattern ID
//m_patternID = PATTERN_CHASER;
// There are 8 steps in the chaser, so iterate 8 times and generate
// There are LED_COUNT steps in the chaser, so iterate LED_COUNT times and generate
// a pattern map for each step. A colorset map can also be applied
// to override certain colors for specific steps, but that's not
// what is being done here
for (uint8_t i = 0; i < 8; ++i) {
// Each step all fingers are dops except for one, so start with a
// Pattern Map that has dops on all fingers. A Pattern Map will map
for (uint8_t i = 0; i < (LED_COUNT / numChasers); ++i) {
// Each step all LEDs are dops except for one, so start with a
// Pattern Map that has dops on all LEDs. A Pattern Map will map
// a Pattern ID to each LED on the device, then we will override a
// different entry each step with the Pattern ID for Solid0.
PatternMap patMap(PATTERN_DOPS);
// Override a single finger in the pattern map with the Solid0 pattern
// Override a single LED in the pattern map with the Solid0 pattern
// 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
// step index like this:
//
// step -> finger index -> target leds -> LedMap
// -----------------------------------------------------
// 0 0 0, 1 00 00 00 00 11
// 1 1 2, 3 00 00 00 11 00
// 2 2 4, 5 00 00 11 00 00
// 3 3 6, 7 00 11 00 00 00
// 4 4 8, 9 11 00 00 00 00
// 5 3 6, 7 00 11 00 00 00
// 6 2 4, 5 00 00 11 00 00
// 7 1 2, 3 00 00 00 11 00
LedMap overrideLeds = 0; //MAP_PAIR((Pair)((i < 5) ? i : (8 - i)));
// Then this API is used to override specific positions in the Pattern Map
// with a different pattern ID, we use the Led Map generated above to tell
// setPatternAt() which indices to override with Solid0
patMap.setPatternAt(PATTERN_SOLID, overrideLeds);
LedMap overrideLeds = MAP_LED_NONE;
// This creates an led map with 1 chaser per CHASER_RATIO (default 7) leds in LED_COUNT
for (uint8_t chaserCount = 0; chaserCount < numChasers; ++chaserCount) {
// Then this API is used to override specific positions in the Pattern Map
// with a different pattern ID, we use the Led Map generated above to tell
// setPatternAt() which indices to override with Solid0
patMap.setPatternAt(PATTERN_SOLID, MAP_LED((i + (chaserCount * CHASER_RATIO)) % LED_COUNT));
}
// Then finally we add this pattern mapping to the sequence in a new step
// that will last 300ms, this means all 8 steps will be 300ms each.
// that will last 300ms, this means all LED_COUNT steps will be 300ms each.
// The last parameter of addStep() is omitted, that parameter could be used
// to override the colorset for specific Leds on any given step. Since it
// is omitted that means this pattern will use whichever colorset is chosen
m_sequence.addStep(300, patMap);
m_sequence.addStep(150, patMap);
}
}
32 changes: 16 additions & 16 deletions VortexEngine/src/Patterns/PatternBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,28 +164,28 @@ PatternArgs PatternBuilder::getDefaultArgs(PatternID id)
// =====================
// Multi Led Patterns:
#if VORTEX_SLIM == 0
case PATTERN_HUE_SCROLL: return PatternArgs(1, 1);
case PATTERN_HUE_SCROLL: return PatternArgs(1, 1, 10);
case PATTERN_THEATER_CHASE: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, 28);
case PATTERN_CHASER: return PatternArgs();
case PATTERN_ZIGZAG: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, 55, 1, 55);
case PATTERN_ZIPFADE: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, 100, 4, 1);
case PATTERN_DRIP: return PatternArgs(STROBE_ON_DURATION, STROBE_OFF_DURATION, 250);
case PATTERN_ZIGZAG: return PatternArgs(DOPS_ON_DURATION, 3, 3, 5, 55);
case PATTERN_ZIPFADE: return PatternArgs(DOPS_ON_DURATION, 2, 75, 9, 230);
case PATTERN_DRIP: return PatternArgs(STROBE_ON_DURATION, STROBE_OFF_DURATION, 150);
case PATTERN_DRIPMORPH: return PatternArgs(STROBE_ON_DURATION, STROBE_OFF_DURATION, 1);
case PATTERN_CROSSDOPS: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, 100);
case PATTERN_CROSSDOPS: return PatternArgs(DOPS_ON_DURATION, 2, 25);
case PATTERN_DOUBLESTROBE: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, 115);
case PATTERN_METEOR: return PatternArgs(STROBE_ON_DURATION, STROBE_OFF_DURATION, 55, 75);
case PATTERN_SPARKLETRACE: return PatternArgs(5, 0, 50);
case PATTERN_VORTEXWIPE: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, 130);
case PATTERN_WARP: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, 150);
case PATTERN_WARPWORM: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, 110);
case PATTERN_SNOWBALL: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, 110);
case PATTERN_LIGHTHOUSE: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, 100, 25, 5);
case PATTERN_PULSISH: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, STROBE_ON_DURATION, STROBE_OFF_DURATION, 250);
case PATTERN_FILL: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, 200);
case PATTERN_BOUNCE: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, 200, 10);
case PATTERN_METEOR: return PatternArgs(1, 1, 20, 130);
case PATTERN_SPARKLETRACE: return PatternArgs(1, 5, 3);
case PATTERN_VORTEXWIPE: return PatternArgs(DOPS_ON_DURATION, 3, 80);
case PATTERN_WARP: return PatternArgs(3, DOPS_OFF_DURATION, 50);
case PATTERN_WARPWORM: return PatternArgs(DOPS_ON_DURATION, 10, 100);
case PATTERN_SNOWBALL: return PatternArgs(3, 3, 33);
case PATTERN_LIGHTHOUSE: return PatternArgs(DOPS_ON_DURATION, 5, 22, 3, 3);
case PATTERN_PULSISH: return PatternArgs(DOPS_ON_DURATION, 6, 5, 1, 100);
case PATTERN_FILL: return PatternArgs(DOPS_ON_DURATION, 5, 50);
case PATTERN_BOUNCE: return PatternArgs(10, 5, 50, 10);
case PATTERN_SPLITSTROBIE: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, 0, 16, 3, 10, PATTERN_DOPS, PATTERN_STROBIE);
case PATTERN_BACKSTROBE: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, 0, HYPERSTROBE_ON_DURATION, HYPERSTROBE_OFF_DURATION, 10, PATTERN_DOPS, PATTERN_HYPERSTROBE);
case PATTERN_VORTEX: return PatternArgs(STROBE_ON_DURATION, STROBE_OFF_DURATION, 130);
case PATTERN_VORTEX: return PatternArgs(1, 1, 130);
case PATTERN_NONE: break;
default: break;
#else
Expand Down
Loading

0 comments on commit 442dcb5

Please sign in to comment.