mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
untested support for the P9813 chip
Former-commit-id: df7341af27503fffd5be9b0afd9525e52dccbebb
This commit is contained in:
parent
b31ad73beb
commit
fd0a69fb77
@ -22,13 +22,35 @@ int LedDeviceP9813::write(const std::vector<ColorRgb> &ledValues)
|
||||
{
|
||||
mLedCount = ledValues.size();
|
||||
|
||||
const unsigned dataLen = ledValues.size() * sizeof(ColorRgb);
|
||||
const uint8_t * dataPtr = reinterpret_cast<const uint8_t *>(ledValues.data());
|
||||
const unsigned dataLen = ledValues.size() * 4 + 8;
|
||||
uint8_t data[dataLen];
|
||||
|
||||
return writeBytes(dataLen, dataPtr);
|
||||
memset(data, 0x00, dataLen);
|
||||
|
||||
int j = 4;
|
||||
for (unsigned i = 0; i < mLedCount; i++){
|
||||
data[j++] = calculateChecksum(ledValues[i]);
|
||||
data[j++] = ledValues[i].blue;
|
||||
data[j++] = ledValues[i].green;
|
||||
data[j++] = ledValues[i].red;
|
||||
}
|
||||
|
||||
return writeBytes(dataLen, data);
|
||||
}
|
||||
|
||||
int LedDeviceP9813::switchOff()
|
||||
{
|
||||
return write(std::vector<ColorRgb>(mLedCount, ColorRgb{0,0,0}));
|
||||
}
|
||||
|
||||
const uint8_t LedDeviceP9813::calculateChecksum(const ColorRgb color)
|
||||
{
|
||||
uint8_t res = 0;
|
||||
|
||||
res |= (uint8_t)0x03 << 6;
|
||||
res |= (uint8_t)(~(color.blue >> 6) & 0x03) << 4;
|
||||
res |= (uint8_t)(~(color.green >> 6) & 0x03) << 2;
|
||||
res |= (uint8_t)(~(color.red >> 6) & 0x03);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -36,4 +36,5 @@ private:
|
||||
|
||||
/// the number of leds
|
||||
size_t mLedCount;
|
||||
const uint8_t calculateChecksum(const ColorRgb color);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user