diff --git a/VortexEngine/VortexEngine.vcxproj b/VortexEngine/VortexEngine.vcxproj index 4190dac366..5a5b577cca 100644 --- a/VortexEngine/VortexEngine.vcxproj +++ b/VortexEngine/VortexEngine.vcxproj @@ -179,7 +179,7 @@ - + @@ -251,7 +251,7 @@ - + diff --git a/VortexEngine/VortexEngine.vcxproj.filters b/VortexEngine/VortexEngine.vcxproj.filters index 913b0d84e7..9bbf08e6d4 100644 --- a/VortexEngine/VortexEngine.vcxproj.filters +++ b/VortexEngine/VortexEngine.vcxproj.filters @@ -240,7 +240,7 @@ Source Files\Patterns\Multi - + Source Files\Patterns\Multi @@ -452,7 +452,7 @@ Header Files\Patterns\Multi - + Header Files\Patterns\Multi diff --git a/VortexEngine/VortexLib/VortexLib.cpp b/VortexEngine/VortexLib/VortexLib.cpp index c56f1a012b..ea0714baa1 100644 --- a/VortexEngine/VortexLib/VortexLib.cpp +++ b/VortexEngine/VortexLib/VortexLib.cpp @@ -809,7 +809,7 @@ string Vortex::patternToString(PatternID id) "hueshift", "theater_chase", "chaser", "zigzag", "zipfade", "drip", "dripmorph", "crossdops", "doublestrobe", "meteor", "sparkletrace", "vortexwipe", "warp", "warpworm", "snowball", "lighthouse", "pulsish", - "fill", "bounce", "splitstrobie", "backstrobe", "materia", + "fill", "bounce", "splitstrobie", "backstrobe", "vortex", }; if (sizeof(patternNames) / sizeof(patternNames[0]) != PATTERN_COUNT) { // if you see this it means the list of strings above is not equal to diff --git a/VortexEngine/src/Menus/MenuList/PatternSelect.cpp b/VortexEngine/src/Menus/MenuList/PatternSelect.cpp index a86be8a50e..f5e75c7635 100644 --- a/VortexEngine/src/Menus/MenuList/PatternSelect.cpp +++ b/VortexEngine/src/Menus/MenuList/PatternSelect.cpp @@ -108,7 +108,9 @@ void PatternSelect::onShortClick() 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); diff --git a/VortexEngine/src/Modes/DefaultModes.cpp b/VortexEngine/src/Modes/DefaultModes.cpp index 6e67bb7262..a0f4be8b7c 100644 --- a/VortexEngine/src/Modes/DefaultModes.cpp +++ b/VortexEngine/src/Modes/DefaultModes.cpp @@ -79,7 +79,7 @@ const default_mode_entry default_modes[MAX_MODES] = { } }, { - PATTERN_MATERIA, 4, { + PATTERN_VORTEX, 4, { 0xAA0055, 0x7070C5, 0x0A0013, diff --git a/VortexEngine/src/Patterns/Multi/MateriaPattern.cpp b/VortexEngine/src/Patterns/Multi/MateriaPattern.cpp deleted file mode 100644 index 3d9c6b18a3..0000000000 --- a/VortexEngine/src/Patterns/Multi/MateriaPattern.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#include "MateriaPattern.h" - -#include "../../Serial/ByteStream.h" -#include "../../Time/TimeControl.h" -#include "../../Leds/Leds.h" -#include "../../Log/Log.h" - -MateriaPattern::MateriaPattern(const PatternArgs &args) : - MultiLedPattern(args), - m_onDuration1(0), - m_offDuration1(0), - m_onDuration2(0), - m_offDuration2(0), - m_stepSpeed(0), - m_stepTimer(), - m_ledMap(0), - m_switch(false) -{ - m_patternID = PATTERN_MATERIA; - REGISTER_ARG(m_onDuration1); - REGISTER_ARG(m_offDuration1); - REGISTER_ARG(m_onDuration2); - REGISTER_ARG(m_offDuration2); - REGISTER_ARG(m_stepSpeed); - setArgs(args); -} - -MateriaPattern::~MateriaPattern() -{ -} - -// init the pattern to initial state -void MateriaPattern::init() -{ - MultiLedPattern::init(); - - // start on index 1 - m_colorset.setCurIndex(1); - // reset the blink timer entirely - m_blinkTimer1.reset(); - // dops timing - m_blinkTimer1.addAlarm(m_onDuration1); - m_blinkTimer1.addAlarm(m_offDuration1); - // start the blink timer from the next frame - m_blinkTimer1.start(); - - // reset the blink timer entirely - m_blinkTimer2.reset(); - // dops timing - m_blinkTimer2.addAlarm(m_onDuration2); - m_blinkTimer2.addAlarm(m_offDuration2); - // start the blink timer from the next frame - m_blinkTimer2.start(); - - // reset and add alarm - m_stepTimer.reset(); - m_stepTimer.addAlarm(m_stepSpeed * 100); - m_stepTimer.start(); - - // map of the Thumb, Index, Ring, and Pinkie Tops - m_ledMap = MAP_LED(LED_9) | MAP_LED(LED_7) | MAP_LED(LED_3) | MAP_LED(LED_1); - - //Set the middle top to solid color 0 - Leds::setIndex(LED_5, m_colorset.get(0)); -} - -// pure virtual must override the play function -void MateriaPattern::play() -{ - // get next color on stepTimer alarm, skip color 0 - if (m_stepTimer.alarm() == 0) { - m_colorset.getNext(); - if (m_colorset.curIndex() == 0) { - m_colorset.getNext(); - } - } - switch (m_blinkTimer1.alarm()) { - case -1: // just break and still run post-step - break; - case 0: // turn on the leds for given mapping - m_switch = !m_switch; - // alternate between showing the current and next color - if (m_switch) { - // if this is the last color of the set, skip color 0 (color 0 is for Middle top only) - if (m_colorset.curIndex() != m_colorset.numColors() - 1) { - Leds::setAllEvens(m_colorset.peekNext()); - } else { - Leds::setAllEvens(m_colorset.peek(2)); - } - } - else { - Leds::setAllEvens(m_colorset.cur()); - } - break; - case 1: // turn off the leds - Leds::clearAllEvens(); - break; - } - - switch (m_blinkTimer2.alarm()) { - case -1: // just break and still run post-step - break; - case 0: // turn on the leds for given mapping - Leds::setMap(m_ledMap, m_colorset.cur()); - break; - case 1: // turn off the leds - Leds::clearMap(m_ledMap); - break; - } - } diff --git a/VortexEngine/src/Patterns/Multi/MateriaPattern.h b/VortexEngine/src/Patterns/Multi/MateriaPattern.h deleted file mode 100644 index 2c87343ba4..0000000000 --- a/VortexEngine/src/Patterns/Multi/MateriaPattern.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef MATERIA_PATTERN_H -#define MATERIA_PATTERN_H - -#include "MultiLedPattern.h" - -#include "../../Time/Timings.h" -#include "../../Time/Timer.h" -#include "../../Leds/LedTypes.h" - -class MateriaPattern : public MultiLedPattern -{ -public: - MateriaPattern(const PatternArgs &args); - virtual ~MateriaPattern(); - - // init the pattern to initial state - virtual void init() override; - - // pure virtual must override the play function - virtual void play() override; - -private: - // blink durations - uint8_t m_onDuration1; - uint8_t m_offDuration1; - uint8_t m_onDuration2; - uint8_t m_offDuration2; - // the speed for the step timer - uint8_t m_stepSpeed; - // the step timer - Timer m_blinkTimer1; - Timer m_blinkTimer2; - Timer m_stepTimer; - - LedMap m_ledMap; - - bool m_switch; -}; -#endif diff --git a/VortexEngine/src/Patterns/Multi/VortexPattern.cpp b/VortexEngine/src/Patterns/Multi/VortexPattern.cpp new file mode 100644 index 0000000000..b879687b11 --- /dev/null +++ b/VortexEngine/src/Patterns/Multi/VortexPattern.cpp @@ -0,0 +1,48 @@ +#include "VortexPattern.h" + +#include "../../Serial/ByteStream.h" +#include "../../Time/TimeControl.h" +#include "../../Leds/Leds.h" +#include "../../Log/Log.h" + +// add 1 to prevent the middle point from being led 0 +#define MIDDLE_POINT ((LED_COUNT + 1) / 2) + +VortexPattern::VortexPattern(const PatternArgs& args) : + BlinkStepPattern(args), + m_progress(0) +{ + m_patternID = PATTERN_VORTEXWIPE; + setArgs(args); +} + +VortexPattern::~VortexPattern() +{ +} + +// init the pattern to initial state +void VortexPattern::init() +{ + BlinkStepPattern::init(); + // reset progress + m_progress = 0; + // start colorset at index 0 so cur() works + m_colorset.setCurIndex(0); +} + +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()); +} + +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_colorset.getNext(); + } +} diff --git a/VortexEngine/src/Patterns/Multi/VortexPattern.h b/VortexEngine/src/Patterns/Multi/VortexPattern.h new file mode 100644 index 0000000000..38b261c8ab --- /dev/null +++ b/VortexEngine/src/Patterns/Multi/VortexPattern.h @@ -0,0 +1,26 @@ +#ifndef VORTEX_PATTERN_H +#define VORTEX_PATTERN_H + +#include "BlinkStepPattern.h" + +#include "../../Time/Timings.h" + +class VortexPattern : public BlinkStepPattern +{ +public: + VortexPattern(const PatternArgs& args); + virtual ~VortexPattern(); + + // init the pattern to initial state + virtual void init() override; + +protected: + virtual void blinkOn() override; + virtual void poststep() override; + +private: + // how much the fill has progressed + uint8_t m_progress; +}; + +#endif diff --git a/VortexEngine/src/Patterns/PatternBuilder.cpp b/VortexEngine/src/Patterns/PatternBuilder.cpp index 2d174d062d..8579af9880 100644 --- a/VortexEngine/src/Patterns/PatternBuilder.cpp +++ b/VortexEngine/src/Patterns/PatternBuilder.cpp @@ -27,7 +27,7 @@ #include "Multi/PulsishPattern.h" #include "Multi/BouncePattern.h" #include "Multi/BackStrobePattern.h" -#include "Multi/MateriaPattern.h" +#include "Multi/VortexPattern.h" #include "Single/SingleLedPattern.h" #include "Single/BasicPattern.h" @@ -185,7 +185,7 @@ PatternArgs PatternBuilder::getDefaultArgs(PatternID id) case PATTERN_BOUNCE: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, 200, 10); case PATTERN_SPLITSTROBIE: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, 0, 16, 3, 10, PATTERN_DOPS, PATTERN_STROBIE); case PATTERN_BACKSTROBE: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, 0, HYPERSTROBE_ON_DURATION, HYPERSTROBE_OFF_DURATION, 10, PATTERN_DOPS, PATTERN_HYPERSTROBE); - case PATTERN_MATERIA: return PatternArgs(STROBE_ON_DURATION, STROBE_OFF_DURATION, 3, 35, 80); + case PATTERN_VORTEX: return PatternArgs(STROBE_ON_DURATION, STROBE_OFF_DURATION, 130); case PATTERN_NONE: break; default: break; #else @@ -273,7 +273,7 @@ Pattern *PatternBuilder::generate(PatternID id, const PatternArgs *userArgs) case PATTERN_BOUNCE: return new BouncePattern(args); case PATTERN_SPLITSTROBIE: case PATTERN_BACKSTROBE: return new BackStrobePattern(args); - case PATTERN_MATERIA: return new MateriaPattern(args); + case PATTERN_VORTEX: return new VortexPattern(args); case PATTERN_NONE: return nullptr; #else // in vortex slim just use basic pattern for all multi led diff --git a/VortexEngine/src/Patterns/Patterns.h b/VortexEngine/src/Patterns/Patterns.h index e9af6d8c8a..65f3b90bb7 100644 --- a/VortexEngine/src/Patterns/Patterns.h +++ b/VortexEngine/src/Patterns/Patterns.h @@ -89,7 +89,7 @@ enum PatternID : int8_t PATTERN_BOUNCE, PATTERN_SPLITSTROBIE, PATTERN_BACKSTROBE, - PATTERN_MATERIA, + PATTERN_VORTEX, // ADD NEW MULTI LED PATTERNS HERE