Updated constructor of ws2811 to contain chip configuration

Former-commit-id: 330056ce83edb3e7fa4d36961a52f8d413e289bb
This commit is contained in:
T. van der Zwan
2013-12-17 15:59:25 +00:00
parent bd6e0f0d2a
commit 90150b06dc
3 changed files with 76 additions and 56 deletions

View File

@@ -49,10 +49,17 @@ LedDevice* Hyperion::createDevice(const Json::Value& deviceConfig)
}
else if (type == "ws2811")
{
const std::string type = deviceConfig["type"].asString();
const std::string output = deviceConfig["output"].asString();
const std::string output = deviceConfig["output"].asString();
const std::string outputSpeed = deviceConfig["output"].asString();
const std::string timingOption = deviceConfig["timingOption"].asString();
LedDeviceWs2811 * deviceWs2811 = new LedDeviceWs2811(output);
ws2811::SpeedMode speedMode = (outputSpeed == "high")? ws2811::highspeed : ws2811::lowspeed;
if (outputSpeed != "high" && outputSpeed != "low")
{
std::cerr << "Incorrect speed-mode selected for WS2811: " << outputSpeed << " != {'high', 'low'}" << std::endl;
}
LedDeviceWs2811 * deviceWs2811 = new LedDeviceWs2811(output, ws2811::fromString(timingOption, ws2811::option_2855), speedMode);
deviceWs2811->open();
device = deviceWs2811;