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

Pattern Select itterates backwards now #252

Merged
merged 3 commits into from
Aug 21, 2024
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
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