diff --git a/libsrc/leddevice/LedDeviceAPA102.cpp b/libsrc/leddevice/LedDeviceAPA102.cpp index 2af01acf..fa224a9a 100644 --- a/libsrc/leddevice/LedDeviceAPA102.cpp +++ b/libsrc/leddevice/LedDeviceAPA102.cpp @@ -3,6 +3,7 @@ #include #include #include +#include // Linux includes #include @@ -21,14 +22,14 @@ LedDeviceAPA102::LedDeviceAPA102(const std::string& outputDevice, const unsigned int LedDeviceAPA102::write(const std::vector &ledValues) { const unsigned int startFrameSize = 4; - const unsigned int endFrameSize = (ledValues.size() + 63) / 64 * 4; + const unsigned int endFrameSize = std::max(((ledValues.size() + 15) / 16), 4); const unsigned int mLedCount = (ledValues.size() * 4) + startFrameSize + endFrameSize; if(_ledBuffer.size() != mLedCount){ _ledBuffer.resize(mLedCount, 0x00); } for (unsigned iLed=1; iLed<=ledValues.size(); ++iLed) { - const ColorRgb& rgb = ledValues[iLed]; + const ColorRgb& rgb = ledValues[iLed-1]; _ledBuffer[iLed*4] = 0xFF; _ledBuffer[iLed*4+1] = rgb.red; _ledBuffer[iLed*4+2] = rgb.green;