Skip to content

Commit

Permalink
Merge branch 'spark' into shane/spark/spark_menu_updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Nov 27, 2024
2 parents 2a69175 + 3f50ab6 commit 4dbe129
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 61 deletions.
10 changes: 5 additions & 5 deletions VortexEngine/src/Leds/LedTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ static_assert(LED_COUNT == (PAIR_COUNT * 2), "Incorrect number of Pairs for Leds
#define PAIR_4 PAIR_1

// check if an led is even or odd
#define isEven(pos) (pos < 3)
#define isOdd(pos) (pos >= 3)
#define isEven(pos) ((pos % 2) == 0)
#define isOdd(pos) ((pos % 2) != 0)

// convert a pair to even or odd led position
#define pairEven(pair) (LedPos)((uint32_t)pair)
#define pairOdd(pair) (LedPos)(((uint32_t)pair) + 3)
#define pairEven(pair) (LedPos)((uint32_t)pair * 2)
#define pairOdd(pair) (LedPos)(((uint32_t)pair * 2) + 1)

// convert an led position to a pair
#define ledToPair(pos) (Pair)((uint32_t)pos >= 3 ? 1 : 0)
#define ledToPair(pos) (Pair)((uint32_t)pos / 2)

// LedMap is a bitmap of leds, used for expressing whether to turn certain leds on
// or off with a single integer
Expand Down
58 changes: 5 additions & 53 deletions VortexEngine/src/Menus/MenuList/PatternSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

PatternSelect::PatternSelect(const RGBColor &col, bool advanced) :
Menu(col, advanced),
m_newPatternID(PATTERN_FIRST),
m_srcLed(LED_FIRST),
m_argIndex(0),
m_started(false)
{
}
Expand All @@ -43,7 +43,7 @@ Menu::MenuAction PatternSelect::run()
// run the current mode
m_previewMode.play();
// show dimmer selections in advanced mode
Menus::showSelection(m_advanced ? RGB_GREEN0 : RGB_WHITE5);
Menus::showSelection(RGB_WHITE5);
return MENU_CONTINUE;
}

Expand All @@ -54,48 +54,8 @@ void PatternSelect::onLedSelected()

void PatternSelect::onShortClick()
{
if (m_advanced) {
// double click = skip 10
bool doSkip = g_pButton->onConsecutivePresses(2);
MAP_FOREACH_LED(m_targetLeds) {
Pattern *pat = m_previewMode.getPattern(pos);
if (pat->getNumArgs() <= m_argIndex) {
continue;
}
uint8_t &arg = pat->argRef(m_argIndex);
if (doSkip) {
arg += 10 - (arg % 10);
} else {
arg++;
}
// on/off/gap/dash duration max 100
uint8_t max = 100;
if (m_argIndex == 6) {
// blend number of numflips
max = 4;
} else if (m_argIndex > 3) {
// group size, solid index, blendspeed
max = 20;
}
if (arg > max) {
// red flash indicates reaching end
Leds::holdAll(RGB_RED);
arg %= (max + 1);
}
// do not let argument0 be reset to 0
if (!m_argIndex && !arg) {
arg = 1;
}
}
m_previewMode.init();
if (doSkip) {
// hold white for a moment to show they are skipping 25
Leds::holdAll(RGB_YELLOW1);
}
return;
}
nextPattern();
}
}

void PatternSelect::nextPatternID()
{
Expand Down Expand Up @@ -141,19 +101,11 @@ void PatternSelect::nextPattern()
DEBUG_LOGF("Iterated to pattern id %d", m_newPatternID);
}


void PatternSelect::onLongClick()
{
bool needsSave = false;
if (m_advanced) {
m_argIndex++;
if (m_argIndex < m_previewMode.getPattern(m_srcLed)->getNumArgs()) {
// if we haven't reached number of args yet then just return and kee pgoing
return;
}
Leds::holdAll(m_menuColor);
}
needsSave = !Modes::curMode()->equals(&m_previewMode);
Mode *cur = Modes::curMode();
needsSave = !cur || !cur->equals(&m_previewMode);
if (needsSave) {
// update the current mode with the new pattern
Modes::updateCurMode(&m_previewMode);
Expand Down
3 changes: 0 additions & 3 deletions VortexEngine/src/Menus/MenuList/PatternSelect.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ class PatternSelect : public Menu
// helpful member
LedPos m_srcLed;

// used for adv pat select
uint8_t m_argIndex;

// the pat select starts by showing the current pattern
// then the first click begin cycling the list of pats
bool m_started;
Expand Down
Binary file modified VortexEngine/tests/tests_general.tar.gz
Binary file not shown.

0 comments on commit 4dbe129

Please sign in to comment.