mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Leddevices source tree refactoring (#461)
* rework structure of leddevice source tree * fix data type vor v4l sig detection value in webui * automate leddevicefactory.cpp
This commit is contained in:
38
libsrc/leddevice/dev_spi/LedDeviceLpd6803.cpp
Normal file
38
libsrc/leddevice/dev_spi/LedDeviceLpd6803.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "LedDeviceLpd6803.h"
|
||||
|
||||
LedDeviceLpd6803::LedDeviceLpd6803(const QJsonObject &deviceConfig)
|
||||
: ProviderSpi()
|
||||
{
|
||||
_deviceReady = init(deviceConfig);
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceLpd6803::construct(const QJsonObject &deviceConfig)
|
||||
{
|
||||
return new LedDeviceLpd6803(deviceConfig);
|
||||
}
|
||||
|
||||
bool LedDeviceLpd6803::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
ProviderSpi::init(deviceConfig);
|
||||
|
||||
unsigned messageLength = 4 + 2*_ledCount + _ledCount/8 + 1;
|
||||
// Initialise the buffer
|
||||
_ledBuffer.resize(messageLength, 0x00);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int LedDeviceLpd6803::write(const std::vector<ColorRgb> &ledValues)
|
||||
{
|
||||
// Copy the colors from the ColorRgb vector to the Ldp6803 data vector
|
||||
for (unsigned iLed=0; iLed<(unsigned)_ledCount; ++iLed)
|
||||
{
|
||||
const ColorRgb& color = ledValues[iLed];
|
||||
|
||||
_ledBuffer[4 + 2 * iLed] = 0x80 | ((color.red & 0xf8) >> 1) | (color.green >> 6);
|
||||
_ledBuffer[5 + 2 * iLed] = ((color.green & 0x38) << 2) | (color.blue >> 3);
|
||||
}
|
||||
|
||||
// Write the data
|
||||
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
|
||||
}
|
Reference in New Issue
Block a user