Updated orbIds config setting and sample config.

Former-commit-id: 350db40b53d04efbb43dc8c87c88bf2eb378fa6b
This commit is contained in:
RickDB 2016-03-15 18:37:55 +01:00
parent f783c59185
commit 7adb339dea
2 changed files with 26 additions and 10 deletions

View File

@ -10,10 +10,12 @@
/// * [device type specific configuration]
/// * 'colorOrder' : The order of the color bytes ('rgb', 'rbg', 'bgr', etc.).
///
/// * 'Specific of Philips Hue:
/// * 'username' : The name of user registred on the Philips Hue Bridge
/// * 'switchOffOnBlack': Define if Hue light switch off when black is detected
/// * 'transitiontime' : Set the time of transition between color of Hue light
/// * 'Specific for AtmoOrb:
/// * 'transitiontime' : Set the time of transition between color of Orb (not implemented)
/// * 'port' : Multicast UDP port
/// * 'numLeds' : Number of leds in Orb
/// * 'orbIds' : The Orb ids to use
/// * 'switchOffOnBlack': Define if Orb is to switch off when black is detected
"device" :
{
"name" : "MyPi",
@ -22,7 +24,7 @@
"transitiontime" : 0,
"port" : 49692,
"numLeds" : 24,
"orbIds" : [1],
"orbIds" : "1",
"switchOffOnBlack" : true,
"colorOrder" : "rgb"
},

View File

@ -253,10 +253,24 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig)
const int transitiontime = deviceConfig.get("transitiontime", 1).asInt();
const int port = deviceConfig.get("port", 1).asInt();
const int numLeds = deviceConfig.get("numLeds", 1).asInt();
const std::string orbId = deviceConfig["orbIds"].asString();
std::vector<unsigned int> orbIds;
for (Json::Value::ArrayIndex i = 0; i < deviceConfig["orbIds"].size(); i++) {
orbIds.push_back(deviceConfig["orbIds"][i].asInt());
// If we find multiple Orb ids separate them and add to list
const std::string separator (",");
if (orbId.find(separator) != std::string::npos) {
std::stringstream ss(orbId);
std::vector<int> output;
unsigned int i;
while (ss >> i) {
orbIds.push_back(i);
if (ss.peek() == ',' || ss.peek() == ' ')
ss.ignore();
}
}
else
{
orbIds.push_back(atoi(orbId.c_str()));
}
device = new LedDeviceAtmoOrb(output, switchOffOnBlack, transitiontime, port, numLeds, orbIds);