mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Update LedDeviceAdalightApa102.cpp
Former-commit-id: 2bbbb4756e6c3f8fe070ba73e63ce327e3f75ff4
This commit is contained in:
parent
acc1a1b397
commit
9d004fa36e
@ -3,6 +3,7 @@
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
// Linux includes
|
||||
#include <fcntl.h>
|
||||
@ -23,7 +24,7 @@ LedDeviceAdalightApa102::LedDeviceAdalightApa102(const std::string& outputDevice
|
||||
int LedDeviceAdalightApa102::write(const std::vector<ColorRgb> & ledValues)
|
||||
{
|
||||
const unsigned int startFrameSize = 4;
|
||||
const unsigned int endFrameSize = (ledValues.size() + 63) / 64 * 4;
|
||||
const unsigned int endFrameSize = std::max<unsigned int>(((ledValues.size() + 15) / 16), 4);
|
||||
const unsigned int mLedCount = (ledValues.size() * 4) + startFrameSize + endFrameSize;
|
||||
if(_ledBuffer.size() != mLedCount){
|
||||
_ledBuffer.resize(mLedCount, 0x00);
|
||||
@ -36,7 +37,7 @@ int LedDeviceAdalightApa102::write(const std::vector<ColorRgb> & ledValues)
|
||||
}
|
||||
|
||||
for (unsigned iLed=1; iLed<=ledValues.size(); iLed++) {
|
||||
const ColorRgb& rgb = ledValues[iLed];
|
||||
const ColorRgb& rgb = ledValues[iLed-1];
|
||||
_ledBuffer[iLed*4+6] = 0xFF;
|
||||
_ledBuffer[iLed*4+1+6] = rgb.red;
|
||||
_ledBuffer[iLed*4+2+6] = rgb.green;
|
||||
|
Loading…
Reference in New Issue
Block a user