From b86e08cf0abb92c55491617ec51f09e5c8516aa7 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 1 Jan 2015 19:31:04 +0100 Subject: [PATCH] Added rgbOrder config for each led Former-commit-id: 9c9f49d61b24267fe9ebe566600cdc42c78c1ab6 --- include/hyperion/Hyperion.h | 6 ------ include/hyperion/LedString.h | 8 ++++++++ libsrc/hyperion/Hyperion.cpp | 17 +++++++++++++++-- libsrc/hyperion/hyperion.schema.json | 4 ++++ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index 9689d97d..aa353a33 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -52,12 +52,6 @@ public: 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 /// diff --git a/include/hyperion/LedString.h b/include/hyperion/LedString.h index e6adc2c0..af25290c 100644 --- a/include/hyperion/LedString.h +++ b/include/hyperion/LedString.h @@ -12,6 +12,12 @@ // Forward class declarations 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 /// color. @@ -40,6 +46,8 @@ struct Led double minY_frac; /// The maximum horizontal scan line included for this leds color double maxY_frac; + /// the color order + ColorOrder colorOrder; }; /// diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index 5e76d8e8..e6d2824b 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -27,7 +27,7 @@ #include -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 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.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())); + if (ledConfig.get("colorOrder", false).asBool()) { + led.colorOrder = createColorOrder(ledConfig); + } else { + led.colorOrder = ORDER_DEFAULT; + } + // Fix if the user swapped min and max if (led.minX_frac > led.maxX_frac) @@ -429,10 +435,16 @@ void Hyperion::update() // Apply the transform to each led and color-channel std::vector ledColors = _raw2ledTransform->applyTransform(priorityInfo.ledColors); + const std::vector& leds = _ledString.leds(); + int i = 0; for (ColorRgb& color : ledColors) { + ColorOrder ledColorOrder = leds.at(i).colorOrder; + if(ledColorOrder == ORDER_DEFAULT) { + ledColorOrder = _colorOrder; + } // correct the color byte order - switch (_colorOrder) + switch (ledColorOrder) { case ORDER_RGB: // leave as it is @@ -463,6 +475,7 @@ void Hyperion::update() break; } } + i++; } // Write the data to the device diff --git a/libsrc/hyperion/hyperion.schema.json b/libsrc/hyperion/hyperion.schema.json index 38192312..e459425b 100644 --- a/libsrc/hyperion/hyperion.schema.json +++ b/libsrc/hyperion/hyperion.schema.json @@ -195,6 +195,10 @@ } }, "additionalProperties" : false + }, + "colorOrder" : { + "type" : "string", + "required" : false } }, "additionalProperties" : false