Skip to content

Commit

Permalink
Pattern Select itterates backwards now (#252)
Browse files Browse the repository at this point in the history
* Pattern Select itterates backwards now

* adjusted comparisons

---------

Co-authored-by: Dan <[email protected]>
  • Loading branch information
LivingSynthesis and Unreal-Dan authored Aug 21, 2024
1 parent bd69cec commit 5d280bc
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
66 changes: 66 additions & 0 deletions VortexEngine/src/Menus/MenuList/PatternSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ void PatternSelect::onShortClick()
}
}

void PatternSelect::onShortClick2()
{
switch (m_state) {
case STATE_PICK_LIST:
if (m_curSelection > QUADRANT_FIRST) {
m_curSelection = (Quadrant)((m_curSelection - 1));
} else {
m_curSelection = QUADRANT_LAST;
}
break;
case STATE_PICK_PATTERN:
previousPattern();
break;
}
}

void PatternSelect::nextPatternID()
{
// increment to next pattern
Expand Down Expand Up @@ -148,6 +164,51 @@ void PatternSelect::nextPattern()
DEBUG_LOGF("Iterated to pattern id %d", m_newPatternID);
}

void PatternSelect::previousPatternID()
{
// increment to next pattern
PatternID endList = PATTERN_SINGLE_LAST;
PatternID beginList = PATTERN_SINGLE_FIRST;
#if VORTEX_SLIM == 0
// if targeted multi led or all singles, iterate through multis
if ((m_targetLeds == MAP_LED_ALL) || (m_targetLeds == MAP_LED(LED_MULTI))) {
endList = PATTERN_MULTI_LAST;
}
// if targeted multi then start at multis and only iterate multis
if ((m_targetLeds == MAP_LED(LED_MULTI))) {
beginList = PATTERN_MULTI_FIRST;
}
#endif
if (m_newPatternID > beginList) {
m_newPatternID = (PatternID)(m_newPatternID - 1);
} else {
m_newPatternID = endList;
}
}

void PatternSelect::previousPattern()
{
if (m_started) {
previousPatternID();
} else {
m_started = true;
// Do not modify m_newPatternID Here! It has been set in the long click handler
// to be the start of the list we want to iterate
}
// set the new pattern id
if (isMultiLedPatternID(m_newPatternID)) {
m_previewMode.setPattern(m_newPatternID);
} else {
// if the user selected multi then just put singles on all leds
LedMap setLeds = (m_targetLeds == MAP_LED(LED_MULTI)) ? LED_ALL : m_targetLeds;
m_previewMode.setPatternMap(setLeds, m_newPatternID);
// TODO: clear multi a better way
m_previewMode.clearPattern(LED_MULTI);
}
m_previewMode.init();
DEBUG_LOGF("Iterated to pattern id %d", m_newPatternID);
}

void PatternSelect::onLongClick()
{
bool needsSave = false;
Expand Down Expand Up @@ -188,6 +249,11 @@ void PatternSelect::onLongClick()
m_curSelection = QUADRANT_FIRST;
}

void PatternSelect::onLongClick2()
{
leaveMenu(false);
}

void PatternSelect::showExit()
{
// don't show the exit when picking pattern
Expand Down
4 changes: 4 additions & 0 deletions VortexEngine/src/Menus/MenuList/PatternSelect.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ class PatternSelect : public Menu
// handlers for clicks
void onShortClick() override;
void onLongClick() override;
void onShortClick2() override;
void onLongClick2() override;

private:
void showListSelection();
void showPatternSelection();
void nextPatternID();
void nextPattern();
void previousPatternID();
void previousPattern();

void showExit() override;

Expand Down

0 comments on commit 5d280bc

Please sign in to comment.