From b090ca306b1d6b68d567c3be16e8ac8b26a7b0d6 Mon Sep 17 00:00:00 2001 From: Unreal-Dan <72595612+Unreal-Dan@users.noreply.github.com> Date: Fri, 29 Dec 2023 00:46:51 -0800 Subject: [PATCH] implemented typedef arg_offset_t for argument offsets (#190) --- VortexEngine/src/Patterns/Pattern.cpp | 4 ++-- VortexEngine/src/Patterns/Pattern.h | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) 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 };