From 6cb8b1792482ffd21c7977b30a8d8524113ee431 Mon Sep 17 00:00:00 2001 From: Unreal-Dan <72595612+Unreal-Dan@users.noreply.github.com> Date: Wed, 29 Nov 2023 01:01:02 -0800 Subject: [PATCH 1/5] Daniel/core/multi led audit1 (#142) * fixed multi-led stuff and renamed materia to vortex * fixed default mode on jest * how to solve vortex on other devices * Dynamic version of Vortex Pattern for all devices * fixed default * adjusted --------- Co-authored-by: Shane Aronson --- VortexEngine/VortexEngine.vcxproj | 4 +- VortexEngine/VortexEngine.vcxproj.filters | 4 +- VortexEngine/VortexLib/VortexLib.cpp | 2 +- .../src/Menus/MenuList/PatternSelect.cpp | 2 + VortexEngine/src/Modes/DefaultModes.cpp | 2 +- .../src/Patterns/Multi/MateriaPattern.cpp | 110 ------------------ .../src/Patterns/Multi/MateriaPattern.h | 39 ------- .../src/Patterns/Multi/VortexPattern.cpp | 48 ++++++++ .../src/Patterns/Multi/VortexPattern.h | 26 +++++ VortexEngine/src/Patterns/PatternBuilder.cpp | 6 +- VortexEngine/src/Patterns/Patterns.h | 2 +- 11 files changed, 86 insertions(+), 159 deletions(-) delete mode 100644 VortexEngine/src/Patterns/Multi/MateriaPattern.cpp delete mode 100644 VortexEngine/src/Patterns/Multi/MateriaPattern.h create mode 100644 VortexEngine/src/Patterns/Multi/VortexPattern.cpp create mode 100644 VortexEngine/src/Patterns/Multi/VortexPattern.h 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 From e0aeb34def084701ce2ee71c04936178685a90ba Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 29 Nov 2023 02:34:56 -0800 Subject: [PATCH 2/5] added wait in recordtests sh --- VortexEngine/tests/recordtests.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/VortexEngine/tests/recordtests.sh b/VortexEngine/tests/recordtests.sh index 9d89628cb2..4247fced2e 100644 --- a/VortexEngine/tests/recordtests.sh +++ b/VortexEngine/tests/recordtests.sh @@ -16,8 +16,7 @@ for folder in tests_*/; do REPOS+=("$folder_name") done -for arg in "$@" -do +for arg in "$@"; do # -v for validate if [ "$arg" == "-v" ]; then VALIDATE=1 @@ -116,7 +115,12 @@ function record_tests() { TESTCOUNT=$((TESTCOUNT + 1)) done + # Wait for all background jobs to finish + wait + + echo "All tests recorded successfully!" #rm -rf tmp/$PROJECT } record_tests $TARGETREPO + From 0dee78f17c76aac64c2af4dcd70d0a8892225ec8 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 29 Nov 2023 03:16:39 -0800 Subject: [PATCH 3/5] test script fixes --- VortexEngine/tests/record_test.sh | 6 ++++-- VortexEngine/tests/recordtests.sh | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/VortexEngine/tests/record_test.sh b/VortexEngine/tests/record_test.sh index 27feccf73a..03a35a9c83 100644 --- a/VortexEngine/tests/record_test.sh +++ b/VortexEngine/tests/record_test.sh @@ -6,6 +6,7 @@ FILE=$1 VALIDATE=$2 TESTCOUNT=$3 NUMFILES=$4 +QUIET=$5 if [ "$FILE" == "" ]; then echo "$0 " @@ -26,7 +27,7 @@ ARGS="$(grep "Args=" $FILE | cut -d= -f2)" TESTNUM="$(echo $FILE | cut -d/ -f2 | cut -d_ -f1 | cut -d/ -f2)" TESTNUM=$((10#$TESTNUM)) -echo -e -n "\e[31mRecording $PROJECT ($TESTCOUNT/$NUMFILES) \e[33m[\e[97m$BRIEF\e[33m] \e[33m[\e[97m$ARGS\e[33m]...\e[0m" +$QUIET || echo -e -n "\e[31mRecording $PROJECT ($TESTCOUNT/$NUMFILES) \e[33m[\e[97m$BRIEF\e[33m] \e[33m[\e[97m$ARGS\e[33m]...\e[0m" TEMP_FILE="tmp/${FILE}.out" # Append the output of the $VORTEX command to the temp file # NOTE: When recording the tests we don't use valgrind because @@ -43,7 +44,8 @@ $VORTEX $ARGS --no-timestep --hex <<< $INPUT >> $TEMP_FILE sed -i 's/\r//g' $TEMP_FILE # Replace the original file with the modified temp file mv $TEMP_FILE $FILE -echo -e "\e[96mOK\e[0m" +$QUIET || echo -e "\e[96mOK\e[0m" +$QUIET && echo -e "." # print out colorful if in verbose if [ "$VALIDATE" -eq 1 ]; then $VORTEX $ARGS --no-timestep --color <<< $INPUT diff --git a/VortexEngine/tests/recordtests.sh b/VortexEngine/tests/recordtests.sh index 4247fced2e..1202d63941 100644 --- a/VortexEngine/tests/recordtests.sh +++ b/VortexEngine/tests/recordtests.sh @@ -4,6 +4,7 @@ VALGRIND="valgrind --quiet --leak-check=full --show-leak-kinds=all" VORTEX="../vortex" VALIDATE=0 +QUIET=0 TODO= declare -a REPOS @@ -17,6 +18,10 @@ for folder in tests_*/; do done for arg in "$@"; do + # -q for quiet + if [ "$arg" == "-q" ]; then + QUIET=1 + fi # -v for validate if [ "$arg" == "-v" ]; then VALIDATE=1 @@ -111,13 +116,14 @@ function record_tests() { TESTCOUNT=0 for FILE in $FILES; do - ./record_test.sh $FILE $VALIDATE $TESTCOUNT $NUMFILES & + ./record_test.sh $FILE $VALIDATE $TESTCOUNT $NUMFILES $QUIET & TESTCOUNT=$((TESTCOUNT + 1)) done # Wait for all background jobs to finish wait + $QUIET && echo ". Complete" echo "All tests recorded successfully!" #rm -rf tmp/$PROJECT } From 4c2eeb064ad226eb30acc26183659a48d41e48c5 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 29 Nov 2023 03:21:58 -0800 Subject: [PATCH 4/5] fixed --- VortexEngine/tests/record_test.sh | 12 ++++++++---- VortexEngine/tests/recordtests.sh | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/VortexEngine/tests/record_test.sh b/VortexEngine/tests/record_test.sh index 03a35a9c83..d373dad005 100644 --- a/VortexEngine/tests/record_test.sh +++ b/VortexEngine/tests/record_test.sh @@ -27,7 +27,9 @@ ARGS="$(grep "Args=" $FILE | cut -d= -f2)" TESTNUM="$(echo $FILE | cut -d/ -f2 | cut -d_ -f1 | cut -d/ -f2)" TESTNUM=$((10#$TESTNUM)) -$QUIET || echo -e -n "\e[31mRecording $PROJECT ($TESTCOUNT/$NUMFILES) \e[33m[\e[97m$BRIEF\e[33m] \e[33m[\e[97m$ARGS\e[33m]...\e[0m" +if [ "$QUIET" -eq 0 ]; then + echo -e -n "\e[31mRecording $PROJECT ($TESTCOUNT/$NUMFILES) \e[33m[\e[97m$BRIEF\e[33m] \e[33m[\e[97m$ARGS\e[33m]...\e[0m" +fi TEMP_FILE="tmp/${FILE}.out" # Append the output of the $VORTEX command to the temp file # NOTE: When recording the tests we don't use valgrind because @@ -44,9 +46,11 @@ $VORTEX $ARGS --no-timestep --hex <<< $INPUT >> $TEMP_FILE sed -i 's/\r//g' $TEMP_FILE # Replace the original file with the modified temp file mv $TEMP_FILE $FILE -$QUIET || echo -e "\e[96mOK\e[0m" -$QUIET && echo -e "." -# print out colorful if in verbose +if [ "$QUIET" -eq 0 ]; then + echo -e "\e[96mOK\e[0m" +else + echo -e "." +fi if [ "$VALIDATE" -eq 1 ]; then $VORTEX $ARGS --no-timestep --color <<< $INPUT echo -e "\e[31mRecorded \e[33m[\e[97m$BRIEF\e[33m] \e[33m[\e[97m$ARGS\e[33m]\e[0m" diff --git a/VortexEngine/tests/recordtests.sh b/VortexEngine/tests/recordtests.sh index 1202d63941..8edfa4ab4f 100644 --- a/VortexEngine/tests/recordtests.sh +++ b/VortexEngine/tests/recordtests.sh @@ -123,7 +123,9 @@ function record_tests() { # Wait for all background jobs to finish wait - $QUIET && echo ". Complete" + if [ "$QUIET" -eq 1]; then + echo ". Complete" + fi echo "All tests recorded successfully!" #rm -rf tmp/$PROJECT } From 2d785c481101eca6c374eab4ba526960e00f5004 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 29 Nov 2023 03:23:58 -0800 Subject: [PATCH 5/5] fixed tests --- VortexEngine/tests/record_test.sh | 2 +- VortexEngine/tests/recordtests.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VortexEngine/tests/record_test.sh b/VortexEngine/tests/record_test.sh index d373dad005..a83dc7a0e3 100644 --- a/VortexEngine/tests/record_test.sh +++ b/VortexEngine/tests/record_test.sh @@ -49,7 +49,7 @@ mv $TEMP_FILE $FILE if [ "$QUIET" -eq 0 ]; then echo -e "\e[96mOK\e[0m" else - echo -e "." + echo -n "." fi if [ "$VALIDATE" -eq 1 ]; then $VORTEX $ARGS --no-timestep --color <<< $INPUT diff --git a/VortexEngine/tests/recordtests.sh b/VortexEngine/tests/recordtests.sh index 8edfa4ab4f..78694cf0d6 100644 --- a/VortexEngine/tests/recordtests.sh +++ b/VortexEngine/tests/recordtests.sh @@ -123,7 +123,7 @@ function record_tests() { # Wait for all background jobs to finish wait - if [ "$QUIET" -eq 1]; then + if [ "$QUIET" -eq 1 ]; then echo ". Complete" fi echo "All tests recorded successfully!"