Merge pull request #238 from sweetpi/master

Added rgbOrder config for each led

Former-commit-id: 91881cdbe14a9fc33e12e91ef15b52faa66a6047
This commit is contained in:
tvdzwan 2015-02-23 15:53:44 +01:00
commit e8ae9c36e6
4 changed files with 27 additions and 8 deletions

View File

@ -52,12 +52,6 @@ public:
SATURATION_GAIN, VALUE_GAIN, THRESHOLD, GAMMA, BLACKLEVEL, WHITELEVEL SATURATION_GAIN, VALUE_GAIN, THRESHOLD, GAMMA, BLACKLEVEL, WHITELEVEL
}; };
/// Enumeration containing the possible orders of device color byte data
enum ColorOrder
{
ORDER_RGB, ORDER_RBG, ORDER_GRB, ORDER_BRG, ORDER_GBR, ORDER_BGR
};
/// ///
/// Constructs the Hyperion instance based on the given Json configuration /// Constructs the Hyperion instance based on the given Json configuration
/// ///

View File

@ -12,6 +12,12 @@
// Forward class declarations // Forward class declarations
namespace Json { class Value; } namespace Json { class Value; }
/// Enumeration containing the possible orders of device color byte data
enum ColorOrder
{
ORDER_RGB, ORDER_RBG, ORDER_GRB, ORDER_BRG, ORDER_GBR, ORDER_BGR, ORDER_DEFAULT
};
/// ///
/// The Led structure contains the definition of the image portion used to determine a single led's /// The Led structure contains the definition of the image portion used to determine a single led's
/// color. /// color.
@ -40,6 +46,8 @@ struct Led
double minY_frac; double minY_frac;
/// The maximum horizontal scan line included for this leds color /// The maximum horizontal scan line included for this leds color
double maxY_frac; double maxY_frac;
/// the color order
ColorOrder colorOrder;
}; };
/// ///

View File

@ -27,7 +27,7 @@
#include <effectengine/EffectEngine.h> #include <effectengine/EffectEngine.h>
Hyperion::ColorOrder Hyperion::createColorOrder(const Json::Value &deviceConfig) ColorOrder Hyperion::createColorOrder(const Json::Value &deviceConfig)
{ {
// deprecated: force BGR when the deprecated flag is present and set to true // deprecated: force BGR when the deprecated flag is present and set to true
if (deviceConfig.get("bgr-output", false).asBool()) if (deviceConfig.get("bgr-output", false).asBool())
@ -201,6 +201,12 @@ LedString Hyperion::createLedString(const Json::Value& ledsConfig)
led.maxX_frac = std::max(0.0, std::min(1.0, hscanConfig["maximum"].asDouble())); led.maxX_frac = std::max(0.0, std::min(1.0, hscanConfig["maximum"].asDouble()));
led.minY_frac = std::max(0.0, std::min(1.0, vscanConfig["minimum"].asDouble())); led.minY_frac = std::max(0.0, std::min(1.0, vscanConfig["minimum"].asDouble()));
led.maxY_frac = std::max(0.0, std::min(1.0, vscanConfig["maximum"].asDouble())); led.maxY_frac = std::max(0.0, std::min(1.0, vscanConfig["maximum"].asDouble()));
if (ledConfig.get("colorOrder", false).asBool()) {
led.colorOrder = createColorOrder(ledConfig);
} else {
led.colorOrder = ORDER_DEFAULT;
}
// Fix if the user swapped min and max // Fix if the user swapped min and max
if (led.minX_frac > led.maxX_frac) if (led.minX_frac > led.maxX_frac)
@ -429,10 +435,16 @@ void Hyperion::update()
// Apply the transform to each led and color-channel // Apply the transform to each led and color-channel
std::vector<ColorRgb> ledColors = _raw2ledTransform->applyTransform(priorityInfo.ledColors); std::vector<ColorRgb> ledColors = _raw2ledTransform->applyTransform(priorityInfo.ledColors);
const std::vector<Led>& leds = _ledString.leds();
int i = 0;
for (ColorRgb& color : ledColors) for (ColorRgb& color : ledColors)
{ {
ColorOrder ledColorOrder = leds.at(i).colorOrder;
if(ledColorOrder == ORDER_DEFAULT) {
ledColorOrder = _colorOrder;
}
// correct the color byte order // correct the color byte order
switch (_colorOrder) switch (ledColorOrder)
{ {
case ORDER_RGB: case ORDER_RGB:
// leave as it is // leave as it is
@ -463,6 +475,7 @@ void Hyperion::update()
break; break;
} }
} }
i++;
} }
// Write the data to the device // Write the data to the device

View File

@ -195,6 +195,10 @@
} }
}, },
"additionalProperties" : false "additionalProperties" : false
},
"colorOrder" : {
"type" : "string",
"required" : false
} }
}, },
"additionalProperties" : false "additionalProperties" : false