Migrate logging and add "enable" to smoothing (#105)

* Migrate logging and add "enable" to smoothing

* Migrated the linearcolorsmoothing file
This commit is contained in:
penfold42 2016-07-12 20:46:54 +10:00 committed by brindosch
parent 76acff8043
commit b7b17b36e8
4 changed files with 15 additions and 6 deletions

View File

@ -133,6 +133,7 @@
"smoothing" :
{
"enable" : true,
"type" : "linear",
"time_ms" : 200,
"updateFrequency" : 20.0000,

View File

@ -83,6 +83,7 @@
],
"smoothing" :
{
"enable" : true,
"type" : "linear",
"time_ms" : 200,
"updateFrequency" : 20.0000,

View File

@ -482,28 +482,34 @@ LedString Hyperion::createLedString(const Json::Value& ledsConfig, const ColorOr
LedDevice * Hyperion::createColorSmoothing(const Json::Value & smoothingConfig, LedDevice * ledDevice)
{
Logger * log = Logger::getInstance("Core");
std::string type = smoothingConfig.get("type", "none").asString();
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")
{
std::cout << "HYPERION INFO: Not creating any smoothing" << std::endl;
Info(log, "Smoothing set to none");
return ledDevice;
}
else if (type == "linear")
{
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"))
{
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
{
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(
ledDevice,
smoothingConfig["updateFrequency"].asDouble(),
@ -513,7 +519,7 @@ LedDevice * Hyperion::createColorSmoothing(const Json::Value & smoothingConfig,
}
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;

View File

@ -22,7 +22,8 @@ LinearColorSmoothing::LinearColorSmoothing(
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()