hyperion.ng/libsrc/hyperion/device/LedDeviceWs2801.cpp
T. van der Zwan c787241747 Moved all device to seperate directory
Added 'sedu' device based on RS232 device


Former-commit-id: 918cbde65a4a14f532c2e08e104745715c3fdd37
2013-11-05 16:18:04 +00:00

35 lines
751 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) :
LedSpiDevice(outputDevice, baudrate, 500000),
mLedCount(0)
{
// empty
}
int LedDeviceWs2801::write(const std::vector<RgbColor> &ledValues)
{
mLedCount = ledValues.size();
const unsigned dataLen = ledValues.size() * sizeof(RgbColor);
const uint8_t * dataPtr = reinterpret_cast<const uint8_t *>(ledValues.data());
return writeBytes(dataLen, dataPtr);
}
int LedDeviceWs2801::switchOff()
{
return write(std::vector<RgbColor>(mLedCount, RgbColor::BLACK));
}