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 multi led patterns in pattern select #139

Merged
merged 52 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
bc96d49
fixed multi led patterns in pattern select
Unreal-Dan Nov 17, 2023
d334449
restored these
Unreal-Dan Nov 17, 2023
f626b9e
minor fix
Unreal-Dan Nov 17, 2023
7389367
Changed saving to work off preview mode
LivingSynthesis Nov 17, 2023
a250fdf
Chaser pattern for orbit
LivingSynthesis Nov 17, 2023
a3e0281
Finished Dynamic Chaser Pattern
LivingSynthesis Nov 18, 2023
f937792
Ensures at least 1 Chaser for Chaser pattern
LivingSynthesis Nov 18, 2023
cfc76c2
Fixes to several patterns
LivingSynthesis Nov 18, 2023
c7c9f1d
Substituted Materia for Vortex, needs renaming
LivingSynthesis Nov 18, 2023
b5d50ea
Renamed Materia to Vortex
LivingSynthesis Nov 18, 2023
9c43498
Upated Materia to Vortex
LivingSynthesis Nov 18, 2023
b1d8b18
Small fixes to comments an types
LivingSynthesis Nov 19, 2023
344e449
fixed random function call ordering
Unreal-Dan Nov 22, 2023
e945187
added a comment
Unreal-Dan Nov 22, 2023
6641d42
minor fixes
Unreal-Dan Nov 22, 2023
2cbcb90
Explicit random call order
LivingSynthesis Nov 22, 2023
f8ceb45
Merge branch 'shane/core/random_call_ordering' into daniel/orbit/mult…
LivingSynthesis Nov 22, 2023
e66bfc1
Merge branch 'orbit' into daniel/orbit/multi_led_pattern_select_fix
Unreal-Dan Nov 24, 2023
fb3c52d
fixed multi-led stuff and renamed materia to vortex
Unreal-Dan Nov 24, 2023
9ae30d7
fixed default mode on jest
Unreal-Dan Nov 24, 2023
e11d81d
how to solve vortex on other devices
Unreal-Dan Nov 24, 2023
28b5924
Dynamic version of Vortex Pattern for all devices
LivingSynthesis Nov 28, 2023
cc2ddc9
Merge branch 'daniel/core/multi_led_audit1' into daniel/orbit/multi_l…
LivingSynthesis Nov 29, 2023
bebaa9e
Mutliled pattern args for orbit
LivingSynthesis Nov 29, 2023
b1736fe
Merge branch 'orbit' into daniel/orbit/multi_led_pattern_select_fix
LivingSynthesis Nov 30, 2023
cbf7026
missed this before woops
LivingSynthesis Nov 30, 2023
82d1558
Orbit variants for some patterns
LivingSynthesis Nov 30, 2023
4b902a0
Merge branch 'orbit' into daniel/orbit/multi_led_pattern_select_fix
Unreal-Dan Nov 30, 2023
34c0c50
recorded tests
Unreal-Dan Nov 30, 2023
b2035ed
Merge branch 'orbit' into daniel/orbit/multi_led_pattern_select_fix
Unreal-Dan Nov 30, 2023
9aaecad
fixed sequenced patterns
Unreal-Dan Nov 30, 2023
72a02c1
sequencer fix
Unreal-Dan Nov 30, 2023
01eb151
Fixed deleted default
LivingSynthesis Nov 30, 2023
dce3797
Silly comma, tricks are for kids
LivingSynthesis Nov 30, 2023
6d930fc
adjusted led typing for ring even odd
Unreal-Dan Dec 1, 2023
568f805
Merge branch 'daniel/orbit/multi_led_pattern_select_fix' of https://g…
Unreal-Dan Dec 1, 2023
a33b5da
adjusted blend code
Unreal-Dan Dec 1, 2023
d8ed3b3
removed unused var
Unreal-Dan Dec 1, 2023
69877e1
began pattern expansion for multiled randomizer
LivingSynthesis Dec 1, 2023
751207c
Merge branch 'daniel/orbit/multi_led_pattern_select_fix' of https://g…
LivingSynthesis Dec 1, 2023
acedd21
Added colors to the multi randomize thingy
LivingSynthesis Dec 2, 2023
a4a5746
Finished MutliLed randomize and fixed a bug
LivingSynthesis Dec 5, 2023
9bfc4a6
Fixes for HueShift
LivingSynthesis Dec 5, 2023
3677f0f
Merge branch 'orbit' into daniel/orbit/multi_led_pattern_select_fix
Unreal-Dan Dec 6, 2023
90975c4
Added support for 2nd button exit, orbit only
LivingSynthesis Dec 7, 2023
a843462
Merge branch 'daniel/orbit/multi_led_pattern_select_fix' of https://g…
LivingSynthesis Dec 7, 2023
6d50cbc
Merge branch 'orbit' into daniel/orbit/multi_led_pattern_select_fix
Unreal-Dan Dec 8, 2023
f1eb7ad
Cleaned up HueShiftPattern
LivingSynthesis Dec 8, 2023
00b57fe
Merge branch 'orbit' into daniel/orbit/multi_led_pattern_select_fix
Unreal-Dan Dec 8, 2023
9041103
Merge branch 'orbit' into daniel/orbit/multi_led_pattern_select_fix
Unreal-Dan Dec 8, 2023
faa9a7e
Reverted randomizer
Unreal-Dan Dec 8, 2023
f3b91f2
recorded tests
Unreal-Dan Dec 8, 2023
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
7 changes: 5 additions & 2 deletions VortexEngine/src/Leds/LedTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ enum Pair : uint8_t
#define isEven(pos) ((pos % 2) == 0)
#define isOdd(pos) ((pos % 2) != 0)

// check if an led is orbit even
#define isOrbitEven(pos) ((MAP_LED(pos) & MAP_RINGS_EVEN) == MAP_LED(pos))

// convert a pair to even or odd led position
#define pairEven(pair) (LedPos)((uint32_t)pair * 2)
#define pairOdd(pair) (LedPos)(((uint32_t)pair * 2) + 1)
Expand Down Expand Up @@ -371,8 +374,8 @@ inline LedPos mapGetNextLed(LedMap map, LedPos pos)
MAP_LED(LED_16) | MAP_LED(LED_18) | MAP_LED(LED_23) | MAP_LED(LED_25))
#define MAP_RING_EDGE (MAP_LED(LED_3) | MAP_LED(LED_10) | MAP_LED(LED_17) | MAP_LED(LED_24))

#define MAP_RINGS_ODD (MAP_RING_INNER | MAP_RING_OUTER)
#define MAP_RINGS_EVEN (MAP_RING_MIDDLE | MAP_RING_EDGE)
#define MAP_RINGS_EVEN (MAP_RING_INNER | MAP_RING_OUTER)
#define MAP_RINGS_ODD (MAP_RING_MIDDLE | MAP_RING_EDGE)

// led quadrant maps
#define MAP_QUADRANT_1 (MAP_LED(LED_0) | MAP_LED(LED_1) | MAP_LED(LED_2) | MAP_LED(LED_3) | \
Expand Down
3 changes: 2 additions & 1 deletion VortexEngine/src/Menus/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ void Menu::onLongClick()

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

void Menu::leaveMenu(bool doSave)
Expand Down Expand Up @@ -254,7 +255,7 @@ void Menu::blinkSelection(uint32_t offMs, uint32_t onMs)
// this adds the currently targeted ledPermutation to the selected leds
void Menu::addSelectionMask() {
// if selecting any of the individual leds then toggle
uint32_t mask = ledPermutations[m_ledSelection];
LedMap mask = ledPermutations[m_ledSelection];
// checks if only 1 b it is set in the target mask
if ((mask & (mask - 1)) == 0) {
// if there's only one bit set then toggle that location
Expand Down
14 changes: 6 additions & 8 deletions VortexEngine/src/Menus/MenuList/PatternSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ void PatternSelect::nextPattern()
if (isMultiLedPatternID(newID)) {
m_previewMode.setPattern(newID);
} else {
// TODO: clear multi a better way
m_previewMode.setPatternMap(m_targetLeds, newID);
m_previewMode.clearPattern(LED_MULTI);
}
m_previewMode.init();
DEBUG_LOGF("Iterated to pattern id %d", newID);
Expand Down Expand Up @@ -201,14 +203,10 @@ void PatternSelect::onLongClick()
break;
case STATE_PICK_PATTERN:
// need to save the new pattern if it's different from current
needsSave = (cur->getPatternID() != m_newPatternID);
// store the new pattern in the mode
cur->setPattern(m_newPatternID);
cur->init();
DEBUG_LOGF("Saving pattern %u", m_newPatternID);
// go back to beginning for next time
m_state = STATE_PICK_LIST;
// done in the pattern select menu
needsSave = (cur->getPatternID() != m_previewMode.getPatternID());
// update the current mode with the new pattern
Modes::updateCurMode(&m_previewMode);
// then done here, save if the mode was different
leaveMenu(needsSave);
break;
}
Expand Down
11 changes: 7 additions & 4 deletions VortexEngine/src/Modes/DefaultModes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
// the gloveset upon factory reset
const default_mode_entry default_modes[MAX_MODES] = {
{
PATTERN_BOUNCE, 3, {
HSV(0, 255, 255),
HSV(96, 255, 255),
HSV(160, 255, 255)
PATTERN_VORTEX, 5, {
RGB_RED,
RGB_GREEN,
RGB_BLUE,
0xABAA00,
0x5500AB
}
},

Expand Down Expand Up @@ -128,6 +130,7 @@ const default_mode_entry default_modes[MAX_MODES] = {
0x13000A
}
},

{
PATTERN_GHOSTCRUSH, 7, {
0x26004B,
Expand Down
4 changes: 2 additions & 2 deletions VortexEngine/src/Patterns/Multi/CompoundPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ void CompoundPattern::setEvensOdds(PatternID evenPattern, PatternID oddPattern,
{
// Set the evenPattern on all evens and oddPattern on all odds
for (LedPos p = LED_FIRST; p <= LED_LAST; p++) {
const PatternArgs *args = isEven(p) ? evenArgs : oddArgs;
PatternID id = isEven(p) ? evenPattern : oddPattern;
const PatternArgs *args = isOrbitEven(p) ? evenArgs : oddArgs;
PatternID id = isOrbitEven(p) ? evenPattern : oddPattern;
setPatternAt(p, PatternBuilder::makeSingle(id, args));
}
}
2 changes: 1 addition & 1 deletion VortexEngine/src/Patterns/Multi/CrossDopsPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void CrossDopsPattern::init()
{
BlinkStepPattern::init();
// Alternating evens and odds mapping of leds to turn on/off
m_ledMap = MAP_PAIR_EVENS;
m_ledMap = MAP_LINE_1;
// start colorset at index 0 so cur() works
m_colorset.setCurIndex(0);
}
Expand Down
4 changes: 2 additions & 2 deletions VortexEngine/src/Patterns/Multi/DoubleStrobePattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ void DoubleStrobePattern::init()

void DoubleStrobePattern::blinkOn()
{
Leds::setAllOdds(m_colorset.cur());
Leds::setAllEvens(m_colorset.peekNext());
Leds::setMap(MAP_RINGS_ODD, m_colorset.cur());
Leds::setMap(MAP_RINGS_EVEN, m_colorset.peekNext());
}
4 changes: 2 additions & 2 deletions VortexEngine/src/Patterns/Multi/DripMorphPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ void DripMorphPattern::blinkOn()
// always over/under shoot
m_cur.hue += m_speed * sign;
// set the target led with the current HSV color
Leds::setAllEvens(m_cur);
Leds::setAllOdds(m_colorset.cur());
Leds::setMap(MAP_RINGS_EVEN, m_cur);
Leds::setMap(MAP_RINGS_ODD, m_colorset.cur());
}

void DripMorphPattern::blinkOff()
Expand Down
4 changes: 2 additions & 2 deletions VortexEngine/src/Patterns/Multi/DripPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ void DripPattern::init()
void DripPattern::blinkOn()
{
if (!m_sync) {
Leds::setAllEvens(m_colorset.cur());
Leds::setAllOdds(m_colorset.peekNext());
Leds::setMap(MAP_RINGS_EVEN, m_colorset.cur());
Leds::setMap(MAP_RINGS_ODD, m_colorset.peekNext());
} else {
Leds::setAll(m_colorset.cur());
}
Expand Down
7 changes: 4 additions & 3 deletions VortexEngine/src/Patterns/Multi/FillPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ void FillPattern::init()

void FillPattern::blinkOn()
{
Leds::setQuadrants(QUADRANT_FIRST, (Quadrant)m_progress, m_colorset.peekNext());
Leds::setQuadrants((Quadrant)m_progress, QUADRANT_LAST, m_colorset.cur());
LedPos edgePos = (LedPos)(m_progress * (LED_COUNT / 4));
Leds::setRange(LED_FIRST, edgePos, m_colorset.peekNext());
Leds::setRange(edgePos, LED_LAST, m_colorset.cur());
}

void FillPattern::poststep()
{
m_progress = (m_progress + 1) % PAIR_COUNT;
m_progress = (m_progress + 1) % 4;
if (m_progress == 0) {
m_colorset.getNext();
}
Expand Down
10 changes: 3 additions & 7 deletions VortexEngine/src/Patterns/Multi/VortexPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,13 @@ void VortexPattern::init()

void VortexPattern::blinkOn()
{
// Sets an LED at opposite ends of the strip and progresses towards the center
Leds::setIndex((LedPos)m_progress, m_colorset.peekNext());
Leds::setIndex((LedPos)(LED_LAST - m_progress), m_colorset.peekNext());
Leds::setRing((Ring)(RING_LAST - m_progress), m_colorset.peekNext());
}

void VortexPattern::poststep()
{
// step till the middle point
m_progress = (m_progress + 1) % MIDDLE_POINT;
// each cycle progress to the next color
if (m_progress == 0) {
m_progress = (m_progress + 1) % RING_COUNT;
if (RING_COUNT - m_progress == RING_COUNT) {
m_colorset.getNext();
}
}
25 changes: 4 additions & 21 deletions VortexEngine/src/Patterns/Multi/ZigzagPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,8 @@
#include "../../Leds/Leds.h"
#include "../../Log/Log.h"

// Mapping of LED positions to steps.
// The lights runs across evens, then back across odds.
// Index this array with m_step in order to get correct LedPos
const LedPos ZigzagPattern::ledStepPositions[] = {
LED_1,
LED_3,
LED_5,
LED_7,
LED_9,

LED_8,
LED_6,
LED_4,
LED_2,
LED_0,
};

// There just happens to be LED_COUNT steps in the pattern
#define NUM_ZIGZAG_STEPS (sizeof(ledStepPositions) / sizeof(ledStepPositions[0]))
#define NUM_ZIGZAG_STEPS LED_COUNT
#define HALF_ZIGZAG_STEPS (NUM_ZIGZAG_STEPS / 2)

ZigzagPattern::ZigzagPattern(const PatternArgs &args) :
Expand Down Expand Up @@ -60,8 +43,8 @@ void ZigzagPattern::init()
m_stepTimer.start();

// initialize the snakes with dops timing
m_snake1.init(m_onDuration, m_offDuration, m_colorset, 0, 0, m_snakeSize, m_fadeAmount, 3);
m_snake2.init(m_onDuration, m_offDuration, m_colorset, 1, HALF_ZIGZAG_STEPS, m_snakeSize, m_fadeAmount, 8);
m_snake1.init(m_onDuration, m_offDuration, m_colorset, 0, 0, m_snakeSize, m_fadeAmount, 4);
m_snake2.init(m_onDuration, m_offDuration, m_colorset, 1, HALF_ZIGZAG_STEPS, m_snakeSize, m_fadeAmount, 7);
}

// pure virtual must override the play function
Expand Down Expand Up @@ -159,7 +142,7 @@ void ZigzagPattern::Snake::drawSnake()
col.adjustBrightness(m_fadeAmount * segment);
}
// lookup the target in the step positions array and turn it on with given color/brightness
Leds::setIndex(ledStepPositions[segment_position], col);
Leds::setIndex((LedPos)segment_position, col);
Unreal-Dan marked this conversation as resolved.
Show resolved Hide resolved
// if this segment is on the step where the color changes
if (segment_position == m_changeBoundary) {
// then decrement the color index for the rest of the snake so that the
Expand Down
4 changes: 0 additions & 4 deletions VortexEngine/src/Patterns/Multi/ZigzagPattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ class ZigzagPattern : public MultiLedPattern
uint8_t m_fadeAmount;
uint8_t m_changeBoundary;
};

// path for leds to take, index this with m_step up to LED_COUNT steps
static const LedPos ledStepPositions[];

// blink on duration
uint8_t m_onDuration;
// blink off duration
Expand Down
Loading