diff --git a/VortexEngine/src/Menus/MenuList/Randomizer.cpp b/VortexEngine/src/Menus/MenuList/Randomizer.cpp index d741d3eb71..b92f78b6e1 100644 --- a/VortexEngine/src/Menus/MenuList/Randomizer.cpp +++ b/VortexEngine/src/Menus/MenuList/Randomizer.cpp @@ -277,6 +277,11 @@ PatternID Randomizer::rollPatternID(Random &ctx) return newPat; } +PatternID Randomizer::rollMultiPatternID(Random &ctx) +{ + return (PatternID)ctx.next8(PATTERN_MULTI_FIRST, PATTERN_MULTI_LAST); +} + bool Randomizer::reRoll() { MAP_FOREACH_LED(m_targetLeds) { @@ -304,9 +309,25 @@ bool Randomizer::reRoll() } } } + if (m_targetLeds == MAP_LED(LED_MULTI)) { + if (m_flags & RANDOMIZE_PATTERN) { + // TODO: Advanced multi led patterns? + if (!m_previewMode.setPattern(rollMultiPatternID(m_multiRandCtx), LED_MULTI)) { + ERROR_LOG("Failed to roll new pattern"); + return false; + } + } + if (m_flags & RANDOMIZE_COLORSET) { + // roll a new colorset + if (!m_previewMode.setColorset(rollColorset(m_multiRandCtx), LED_MULTI)) { + ERROR_LOG("Failed to roll new colorset"); + return false; + } + } + } // initialize the mode with the new pattern and colorset m_previewMode.init(); - DEBUG_LOGF("Randomized Led %u set with randomization technique %u, %u colors, and Pattern number %u", - pos, randType, randomSet.numColors(), newPat); + //DEBUG_LOGF("Randomized Led %u set with randomization technique %u, %u colors, and Pattern number %u", + // pos, randType, randomSet.numColors(), newPat); return true; } diff --git a/VortexEngine/src/Menus/MenuList/Randomizer.h b/VortexEngine/src/Menus/MenuList/Randomizer.h index 01af38c5c6..33b0114712 100644 --- a/VortexEngine/src/Menus/MenuList/Randomizer.h +++ b/VortexEngine/src/Menus/MenuList/Randomizer.h @@ -62,6 +62,7 @@ class Randomizer : public Menu // generate a random colorset with a random context bool rollPattern(Random &ctx, Mode *pMode, LedPos pos); PatternID rollPatternID(Random &ctx); + PatternID rollMultiPatternID(Random &ctx); Colorset rollColorset(Random &ctx); // random pattern generators diff --git a/VortexEngine/src/Patterns/Pattern.cpp b/VortexEngine/src/Patterns/Pattern.cpp index 311ee3d0af..6078cc4ed1 100644 --- a/VortexEngine/src/Patterns/Pattern.cpp +++ b/VortexEngine/src/Patterns/Pattern.cpp @@ -164,9 +164,9 @@ void Pattern::clearColorset() } #ifdef VORTEX_LIB -void Pattern::registerArg(const char *name, uint8_t argOffset) +void Pattern::registerArg(const char *name, arg_offset_t argOffset) #else -void Pattern::registerArg(uint8_t argOffset) +void Pattern::registerArg(arg_offset_t argOffset) #endif { if (m_numArgs >= MAX_PATTERN_ARGS) { diff --git a/VortexEngine/src/Patterns/Pattern.h b/VortexEngine/src/Patterns/Pattern.h index 5f8a0bb829..e659abf885 100644 --- a/VortexEngine/src/Patterns/Pattern.h +++ b/VortexEngine/src/Patterns/Pattern.h @@ -27,11 +27,22 @@ // the pattern is a multi-pattern #define PATTERN_FLAG_MULTI (1<<0) +// and arg_offset_t is the distance from the base of the object +// to the desired argument, in slim vortex we only need a single byte +// but in multi-led patterns they can be a bit further in +#if VORTEX_SLIM == 1 +typedef uint8_t arg_offset_t; +#else +typedef uint16_t arg_offset_t; +#endif + // macro to register args of a pattern #ifdef VORTEX_LIB -#define REGISTER_ARG(arg) registerArg(#arg, (uint8_t)(((uintptr_t)&arg - (uintptr_t)this))); +#define REGISTER_ARG(arg) \ + registerArg(#arg, (arg_offset_t)(((uintptr_t)&arg - (uintptr_t)this))); #else -#define REGISTER_ARG(arg) registerArg((uint8_t)(((uintptr_t)&arg - (uintptr_t)this))); +#define REGISTER_ARG(arg) \ + registerArg((arg_offset_t)(((uintptr_t)&arg - (uintptr_t)this))); #endif class ByteStream; @@ -122,13 +133,13 @@ class Pattern LedPos m_ledPos; uint8_t m_numArgs; - uint8_t m_argList[MAX_PATTERN_ARGS]; + arg_offset_t m_argList[MAX_PATTERN_ARGS]; #ifdef VORTEX_LIB - void registerArg(const char *name, uint8_t argOffset); + void registerArg(const char *name, arg_offset_t argOffset); const char *m_argNameList[MAX_PATTERN_ARGS]; #else - void registerArg(uint8_t argOffset); + void registerArg(arg_offset_t argOffset); #endif };