mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Migrate logging and add "enable" to smoothing (#105)
* Migrate logging and add "enable" to smoothing * Migrated the linearcolorsmoothing file
This commit is contained in:
parent
76acff8043
commit
b7b17b36e8
@ -133,6 +133,7 @@
|
|||||||
|
|
||||||
"smoothing" :
|
"smoothing" :
|
||||||
{
|
{
|
||||||
|
"enable" : true,
|
||||||
"type" : "linear",
|
"type" : "linear",
|
||||||
"time_ms" : 200,
|
"time_ms" : 200,
|
||||||
"updateFrequency" : 20.0000,
|
"updateFrequency" : 20.0000,
|
||||||
|
@ -83,6 +83,7 @@
|
|||||||
],
|
],
|
||||||
"smoothing" :
|
"smoothing" :
|
||||||
{
|
{
|
||||||
|
"enable" : true,
|
||||||
"type" : "linear",
|
"type" : "linear",
|
||||||
"time_ms" : 200,
|
"time_ms" : 200,
|
||||||
"updateFrequency" : 20.0000,
|
"updateFrequency" : 20.0000,
|
||||||
|
@ -482,28 +482,34 @@ LedString Hyperion::createLedString(const Json::Value& ledsConfig, const ColorOr
|
|||||||
|
|
||||||
LedDevice * Hyperion::createColorSmoothing(const Json::Value & smoothingConfig, LedDevice * ledDevice)
|
LedDevice * Hyperion::createColorSmoothing(const Json::Value & smoothingConfig, LedDevice * ledDevice)
|
||||||
{
|
{
|
||||||
|
Logger * log = Logger::getInstance("Core");
|
||||||
std::string type = smoothingConfig.get("type", "none").asString();
|
std::string type = smoothingConfig.get("type", "none").asString();
|
||||||
std::transform(type.begin(), type.end(), type.begin(), ::tolower);
|
std::transform(type.begin(), type.end(), type.begin(), ::tolower);
|
||||||
|
|
||||||
|
if ( ! smoothingConfig.get("enable", true).asBool() )
|
||||||
|
{
|
||||||
|
Info(log,"Smoothing disabled in config");
|
||||||
|
return ledDevice;
|
||||||
|
}
|
||||||
if (type == "none")
|
if (type == "none")
|
||||||
{
|
{
|
||||||
std::cout << "HYPERION INFO: Not creating any smoothing" << std::endl;
|
Info(log, "Smoothing set to none");
|
||||||
return ledDevice;
|
return ledDevice;
|
||||||
}
|
}
|
||||||
else if (type == "linear")
|
else if (type == "linear")
|
||||||
{
|
{
|
||||||
if (!smoothingConfig.isMember("time_ms"))
|
if (!smoothingConfig.isMember("time_ms"))
|
||||||
{
|
{
|
||||||
std::cout << "HYPERION ERROR: Unable to create smoothing of type linear because of missing parameter 'time_ms'" << std::endl;
|
Error(log, "Unable to create smoothing of type linear because of missing parameter 'time_ms'");
|
||||||
}
|
}
|
||||||
else if (!smoothingConfig.isMember("updateFrequency"))
|
else if (!smoothingConfig.isMember("updateFrequency"))
|
||||||
{
|
{
|
||||||
std::cout << "HYPERION ERROR: Unable to create smoothing of type linear because of missing parameter 'updateFrequency'" << std::endl;
|
Error(log, "Unable to create smoothing of type linear because of missing parameter 'updateFrequency'");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const unsigned updateDelay = smoothingConfig.get("updateDelay", Json::Value(0u)).asUInt();
|
const unsigned updateDelay = smoothingConfig.get("updateDelay", Json::Value(0u)).asUInt();
|
||||||
std::cout << "INFO: Creating linear smoothing" << std::endl;
|
Info(log, "Creating linear smoothing");
|
||||||
return new LinearColorSmoothing(
|
return new LinearColorSmoothing(
|
||||||
ledDevice,
|
ledDevice,
|
||||||
smoothingConfig["updateFrequency"].asDouble(),
|
smoothingConfig["updateFrequency"].asDouble(),
|
||||||
@ -513,7 +519,7 @@ LedDevice * Hyperion::createColorSmoothing(const Json::Value & smoothingConfig,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "HYPERION ERROR: Unable to create smoothing of type " << type << std::endl;
|
Error(log, "Unknown smoothing type %s.", type.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ledDevice;
|
return ledDevice;
|
||||||
|
@ -22,7 +22,8 @@ LinearColorSmoothing::LinearColorSmoothing(
|
|||||||
|
|
||||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(updateLeds()));
|
connect(&_timer, SIGNAL(timeout()), this, SLOT(updateLeds()));
|
||||||
|
|
||||||
std::cout << "HYPERION (CS) INFO: Created linear-smoothing(interval_ms=" << _updateInterval << ";settlingTime_ms=" << settlingTime_ms << ";updateDelay=" << _outputDelay << std::endl;
|
Info(Logger::getInstance("Smoothing"), "Created linear-smoothing with interval_ms: %d, settlingTime_ms: %d, updateDelay: %d",
|
||||||
|
_updateInterval, settlingTime_ms, _outputDelay );
|
||||||
}
|
}
|
||||||
|
|
||||||
LinearColorSmoothing::~LinearColorSmoothing()
|
LinearColorSmoothing::~LinearColorSmoothing()
|
||||||
|
Loading…
Reference in New Issue
Block a user