hyperion.ng/libsrc/leddevice/LedDeviceFile.cpp
redPanther bfb9a08c80 migrate std::string to qstring + add sysinfo via json (#412)
* std::string -> qstring part 1

* more string migration

* more string migration ...

* ...

* more qstring mogrations
add sysinfo via json

* remove unneccessary includes

* integrate sysinfo into webui
2017-03-04 22:17:42 +01:00

45 lines
761 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);
QString fileName = deviceConfig["output"].toString("/dev/null");
_ofs.open( QSTRING_CSTR(fileName) );
return true;
}
int LedDeviceFile::write(const std::vector<ColorRgb> & ledValues)
{
_ofs << "[";
for (const ColorRgb& color : ledValues)
{
_ofs << color;
}
_ofs << "]" << std::endl;
return 0;
}