hyperion.ng/libsrc/leddevice/LedDeviceFile.cpp
redPanther 96e8c29582 refresh time for all devices + schema fixes (#305)
* refresh for all :-)
remove dups

* - integrate refresh leds for all devices
- fix schemas for led devices

* add minimum for rewrite time

* rewriteTime: add missing info in config examples
2016-12-02 12:07:24 +01:00

45 lines
773 B
C++

#include "LedDeviceFile.h"
LedDeviceFile::LedDeviceFile(const QJsonObject &deviceConfig)
: LedDevice()
{
init(deviceConfig);
}
LedDeviceFile::~LedDeviceFile()
{
}
LedDevice* LedDeviceFile::construct(const QJsonObject &deviceConfig)
{
return new LedDeviceFile(deviceConfig);
}
bool LedDeviceFile::init(const QJsonObject &deviceConfig)
{
if ( _ofs.is_open() )
{
_ofs.close();
}
_refresh_timer_interval = 0;
LedDevice::init(deviceConfig);
std::string fileName = deviceConfig["output"].toString("/dev/null").toStdString();
_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;
}