Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit 91881cd

Browse files
committed
Merge pull request #238 from sweetpi/master
Added rgbOrder config for each led
2 parents 87c8645 + 9c9f49d commit 91881cd

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

include/hyperion/Hyperion.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ class Hyperion : public QObject
5252
SATURATION_GAIN, VALUE_GAIN, THRESHOLD, GAMMA, BLACKLEVEL, WHITELEVEL
5353
};
5454

55-
/// Enumeration containing the possible orders of device color byte data
56-
enum ColorOrder
57-
{
58-
ORDER_RGB, ORDER_RBG, ORDER_GRB, ORDER_BRG, ORDER_GBR, ORDER_BGR
59-
};
60-
6155
///
6256
/// Constructs the Hyperion instance based on the given Json configuration
6357
///

include/hyperion/LedString.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
// Forward class declarations
1313
namespace Json { class Value; }
1414

15+
/// Enumeration containing the possible orders of device color byte data
16+
enum ColorOrder
17+
{
18+
ORDER_RGB, ORDER_RBG, ORDER_GRB, ORDER_BRG, ORDER_GBR, ORDER_BGR, ORDER_DEFAULT
19+
};
20+
1521
///
1622
/// The Led structure contains the definition of the image portion used to determine a single led's
1723
/// color.
@@ -40,6 +46,8 @@ struct Led
4046
double minY_frac;
4147
/// The maximum horizontal scan line included for this leds color
4248
double maxY_frac;
49+
/// the color order
50+
ColorOrder colorOrder;
4351
};
4452

4553
///

libsrc/hyperion/Hyperion.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <effectengine/EffectEngine.h>
2828

2929

30-
Hyperion::ColorOrder Hyperion::createColorOrder(const Json::Value &deviceConfig)
30+
ColorOrder Hyperion::createColorOrder(const Json::Value &deviceConfig)
3131
{
3232
// deprecated: force BGR when the deprecated flag is present and set to true
3333
if (deviceConfig.get("bgr-output", false).asBool())
@@ -201,6 +201,12 @@ LedString Hyperion::createLedString(const Json::Value& ledsConfig)
201201
led.maxX_frac = std::max(0.0, std::min(1.0, hscanConfig["maximum"].asDouble()));
202202
led.minY_frac = std::max(0.0, std::min(1.0, vscanConfig["minimum"].asDouble()));
203203
led.maxY_frac = std::max(0.0, std::min(1.0, vscanConfig["maximum"].asDouble()));
204+
if (ledConfig.get("colorOrder", false).asBool()) {
205+
led.colorOrder = createColorOrder(ledConfig);
206+
} else {
207+
led.colorOrder = ORDER_DEFAULT;
208+
}
209+
204210

205211
// Fix if the user swapped min and max
206212
if (led.minX_frac > led.maxX_frac)
@@ -429,10 +435,16 @@ void Hyperion::update()
429435

430436
// Apply the transform to each led and color-channel
431437
std::vector<ColorRgb> ledColors = _raw2ledTransform->applyTransform(priorityInfo.ledColors);
438+
const std::vector<Led>& leds = _ledString.leds();
439+
int i = 0;
432440
for (ColorRgb& color : ledColors)
433441
{
442+
ColorOrder ledColorOrder = leds.at(i).colorOrder;
443+
if(ledColorOrder == ORDER_DEFAULT) {
444+
ledColorOrder = _colorOrder;
445+
}
434446
// correct the color byte order
435-
switch (_colorOrder)
447+
switch (ledColorOrder)
436448
{
437449
case ORDER_RGB:
438450
// leave as it is
@@ -463,6 +475,7 @@ void Hyperion::update()
463475
break;
464476
}
465477
}
478+
i++;
466479
}
467480

468481
// Write the data to the device

libsrc/hyperion/hyperion.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@
195195
}
196196
},
197197
"additionalProperties" : false
198+
},
199+
"colorOrder" : {
200+
"type" : "string",
201+
"required" : false
198202
}
199203
},
200204
"additionalProperties" : false

0 commit comments

Comments
 (0)