You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Moved the dmxChannelCount calculation and the creation of the ledBuffer from the `write` function to the `init` function.
This avoids repeated calculations and memory allocations on every call to `write`, improving performance.
@@ -153,11 +157,8 @@ int LedDeviceUdpE131::write(const std::vector<ColorRgb> &ledValues)
153
157
{
154
158
int retVal = 0;
155
159
int thisChannelCount = 0;
156
-
int dmxChannelCount = (_whiteAlgorithm == RGBW::WhiteAlgorithm::WHITE_OFF) ? _ledRGBCount : _ledRGBWCount; // if white_off we expect 3 channels per LED otherwise 4
157
160
158
-
// Create a temporary buffer for RGB or RGBW data
159
-
std::vector<uint8_t> tempBuffer(dmxChannelCount);
160
-
uint8_t* rawDataPtr = tempBuffer.data();
161
+
uint8_t* rawDataPtr = _ledBuffer.data();
161
162
162
163
int currentChannel = 0;
163
164
for (const ColorRgb& color : ledValues)
@@ -180,11 +181,11 @@ int LedDeviceUdpE131::write(const std::vector<ColorRgb> &ledValues)
180
181
181
182
_e131_seq++;
182
183
183
-
for (int rawIdx = 0; rawIdx < dmxChannelCount; rawIdx++)
184
+
for (int rawIdx = 0; rawIdx < _dmxChannelCount; rawIdx++)
184
185
{
185
186
if (rawIdx % _e131_dmx_max == 0) // start of new packet
0 commit comments