hyperion.ng/libsrc/leddevice/LedDeviceFile.cpp
redPanther 5aac2be702 Leddevice refactoring the next next part (#263)
* switch rs232 provider to completly async transfer

* start of implementing a seperate init function for leddevices

* rename setconfig to init

* more fixes

* implement missing code

* fix code style

* remove debug  code

* remove  debug stuff

* set loglevel to original state
2016-10-08 08:14:36 +02:00

42 lines
702 B
C++

#include "LedDeviceFile.h"
LedDeviceFile::LedDeviceFile(const Json::Value &deviceConfig)
: LedDevice()
{
init(deviceConfig);
}
LedDeviceFile::~LedDeviceFile()
{
}
LedDevice* LedDeviceFile::construct(const Json::Value &deviceConfig)
{
return new LedDeviceFile(deviceConfig);
}
bool LedDeviceFile::init(const Json::Value &deviceConfig)
{
if ( _ofs.is_open() )
{
_ofs.close();
}
std::string fileName = deviceConfig.get("output","/dev/null").asString();
_ofs.open( fileName.c_str() );
return true;
}
int LedDeviceFile::write(const std::vector<ColorRgb> & ledValues)
{
_ofs << "[";
for (const ColorRgb& color : ledValues)
{
_ofs << color;
}
_ofs << "]" << std::endl;
return 0;
}