mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
* Added "invert" and "spimode" options to ws2801, ws2812spi and sk6812spi devices * fixed test/TestSpi.cpp * some coding style wish
36 lines
856 B
C++
36 lines
856 B
C++
|
|
// STL includes
|
|
#include <cstring>
|
|
#include <cstdio>
|
|
#include <iostream>
|
|
|
|
// Linux includes
|
|
#include <fcntl.h>
|
|
#include <sys/ioctl.h>
|
|
|
|
// hyperion local includes
|
|
#include "LedDeviceWs2801.h"
|
|
|
|
LedDeviceWs2801::LedDeviceWs2801(const std::string& outputDevice, const unsigned baudrate, const unsigned latchTime,
|
|
const int spiMode, const bool spiDataInvert)
|
|
: LedSpiDevice(outputDevice, baudrate, latchTime, spiMode, spiDataInvert)
|
|
, mLedCount(0)
|
|
{
|
|
// empty
|
|
}
|
|
|
|
int LedDeviceWs2801::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());
|
|
|
|
return writeBytes(dataLen, dataPtr);
|
|
}
|
|
|
|
int LedDeviceWs2801::switchOff()
|
|
{
|
|
return write(std::vector<ColorRgb>(mLedCount, ColorRgb{0,0,0}));
|
|
}
|