Skip to content
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

Fixed sequencer and some multi led fixes #144

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions VortexEngine/src/Leds/LedTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ typedef uint64_t LedMap;
// convert a map to the first Led position in the map
inline LedPos mapGetFirstLed(LedMap map)
{
if (map == MAP_LED(LED_MULTI)) {
return LED_MULTI;
}
LedPos pos = LED_FIRST;
while (map && pos < LED_COUNT) {
if (map & 1) {
Expand Down
1 change: 1 addition & 0 deletions VortexEngine/src/Menus/MenuList/ColorSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ bool ColorSelect::init()
return false;
}
if (cur->isMultiLed()) {
m_targetLeds = MAP_LED(LED_MULTI);
m_ledSelected = true;
}
m_state = STATE_INIT;
Expand Down
17 changes: 14 additions & 3 deletions VortexEngine/src/Patterns/Multi/Sequencer/SequencedPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,27 @@ void SequencedPattern::init()

m_timer.start();

// TODO: Play first sequence step in init?
// Play first sequence step in init, if there is one
if (m_sequence.numSteps() > 0) {
playSequenceStep(m_sequence[0]);
}
}

// pure virtual must the play function
void SequencedPattern::play()
{
if (m_timer.alarm() != -1 && !m_timer.onStart()) {
if (m_timer.alarm() != -1) {
m_curSequence = (m_curSequence + 1) % m_sequence.numSteps();
}
const SequenceStep &step = m_sequence[m_curSequence];
// only index the sequence if the current sequence index is valid
if (m_curSequence < m_sequence.numSteps()) {
// play the sequence step
playSequenceStep(m_sequence[m_curSequence]);
}
}

void SequencedPattern::playSequenceStep(const SequenceStep &step)
{
for (LedPos pos = LED_FIRST; pos < LED_COUNT; ++pos) {
// the current initialized pattern for this LED
SingleLedPattern *curPat = m_ledPatterns[pos];
Expand Down
2 changes: 2 additions & 0 deletions VortexEngine/src/Patterns/Multi/Sequencer/SequencedPattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class SequencedPattern : public CompoundPattern
void bindSequence(const Sequence &sequence);

protected:
void playSequenceStep(const SequenceStep &step);

// static data
Sequence m_sequence;

Expand Down