mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
added flag to have BGR output instead of RGB
Former-commit-id: dbd35d6dd4a84d95e0a034b99843be4949a6e169
This commit is contained in:
parent
2aaf58aa78
commit
2471bd8753
@ -9,12 +9,14 @@
|
|||||||
/// - 'ws2801' this is the device (eg '/dev/spidev0.0')
|
/// - 'ws2801' this is the device (eg '/dev/spidev0.0')
|
||||||
/// - 'test' this is the file used to write test output (eg '/home/pi/hyperion.out')
|
/// - 'test' this is the file used to write test output (eg '/home/pi/hyperion.out')
|
||||||
/// * 'rate' : The baudrate of the output to the device (only applicable for 'ws2801')
|
/// * 'rate' : The baudrate of the output to the device (only applicable for 'ws2801')
|
||||||
|
/// * 'bgr-output' : Use BGR output instead of RGB (reverse red and blue).
|
||||||
"device" :
|
"device" :
|
||||||
{
|
{
|
||||||
"name" : "MyPi",
|
"name" : "MyPi",
|
||||||
"type" : "ws2801",
|
"type" : "ws2801",
|
||||||
"output" : "/dev/spidev0.0",
|
"output" : "/dev/spidev0.0",
|
||||||
"rate" : 1000000
|
"rate" : 1000000,
|
||||||
|
"bgr-output" : false
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Color manipulation configuration used to tune the output colors to specific surroundings. Contains the following fields:
|
/// Color manipulation configuration used to tune the output colors to specific surroundings. Contains the following fields:
|
||||||
|
@ -1 +1 @@
|
|||||||
8b85d78801cd11fdefd0d389d61e2c9e5a50ad03
|
001950ae6499ac83babe8e563be11b8daacd554c
|
@ -1 +1 @@
|
|||||||
db4c1c44b95467b193a79ea0b0ddab37d54f7566
|
c2bbbf969d7dbe0e096670758e37284b827b3d03
|
@ -171,6 +171,9 @@ private:
|
|||||||
/// The BLUE-Channel (RGB) transform
|
/// The BLUE-Channel (RGB) transform
|
||||||
ColorTransform * _blueTransform;
|
ColorTransform * _blueTransform;
|
||||||
|
|
||||||
|
/// Flag indicating if the output should be BGR (red and blue reversed)
|
||||||
|
bool _haveBgrOutput;
|
||||||
|
|
||||||
/// The actual LedDevice
|
/// The actual LedDevice
|
||||||
LedDevice* _device;
|
LedDevice* _device;
|
||||||
|
|
||||||
|
@ -96,6 +96,7 @@ Hyperion::Hyperion(const Json::Value &jsonConfig) :
|
|||||||
_redTransform(createColorTransform(jsonConfig["color"]["red"])),
|
_redTransform(createColorTransform(jsonConfig["color"]["red"])),
|
||||||
_greenTransform(createColorTransform(jsonConfig["color"]["green"])),
|
_greenTransform(createColorTransform(jsonConfig["color"]["green"])),
|
||||||
_blueTransform(createColorTransform(jsonConfig["color"]["blue"])),
|
_blueTransform(createColorTransform(jsonConfig["color"]["blue"])),
|
||||||
|
_haveBgrOutput(jsonConfig["device"].get("bgr-output", false).asBool()),
|
||||||
_device(constructDevice(jsonConfig["device"])),
|
_device(constructDevice(jsonConfig["device"])),
|
||||||
_timer()
|
_timer()
|
||||||
{
|
{
|
||||||
@ -301,6 +302,11 @@ void Hyperion::update()
|
|||||||
color.red = _redTransform->transform(color.red);
|
color.red = _redTransform->transform(color.red);
|
||||||
color.green = _greenTransform->transform(color.green);
|
color.green = _greenTransform->transform(color.green);
|
||||||
color.blue = _blueTransform->transform(color.blue);
|
color.blue = _blueTransform->transform(color.blue);
|
||||||
|
|
||||||
|
if (_haveBgrOutput)
|
||||||
|
{
|
||||||
|
std::swap(color.red, color.blue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the data to the device
|
// Write the data to the device
|
||||||
|
@ -22,6 +22,10 @@
|
|||||||
"type" : "integer",
|
"type" : "integer",
|
||||||
"required" : true,
|
"required" : true,
|
||||||
"minimum" : 0
|
"minimum" : 0
|
||||||
|
},
|
||||||
|
"bgr-output" : {
|
||||||
|
"type" : "boolean",
|
||||||
|
"required" : false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties" : false
|
"additionalProperties" : false
|
||||||
|
@ -13,6 +13,8 @@ public class DeviceConfig {
|
|||||||
String mOutput = "/dev/spidev0.0";
|
String mOutput = "/dev/spidev0.0";
|
||||||
/** The baudrate of the device */
|
/** The baudrate of the device */
|
||||||
int mBaudrate = 1000000;
|
int mBaudrate = 1000000;
|
||||||
|
/** Flag indicating if the red and blue should be reversed */
|
||||||
|
boolean mBgrOutput = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the JSON string of the configuration as used in the Hyperion daemon configfile
|
* Creates the JSON string of the configuration as used in the Hyperion daemon configfile
|
||||||
@ -29,6 +31,7 @@ public class DeviceConfig {
|
|||||||
strBuf.append("\t/// - 'ws2801' this is the device (eg '/dev/spidev0.0')\n");
|
strBuf.append("\t/// - 'ws2801' this is the device (eg '/dev/spidev0.0')\n");
|
||||||
strBuf.append("\t/// - 'test' this is the file used to write test output (eg '/home/pi/hyperion.out')\n");
|
strBuf.append("\t/// - 'test' this is the file used to write test output (eg '/home/pi/hyperion.out')\n");
|
||||||
strBuf.append("\t/// * 'rate' : The baudrate of the output to the device (only applicable for 'ws2801')\n");
|
strBuf.append("\t/// * 'rate' : The baudrate of the output to the device (only applicable for 'ws2801')\n");
|
||||||
|
strBuf.append("\t/// * 'bgr-output' : Use BGR output instead of RGB (reverse red and blue).\n");
|
||||||
|
|
||||||
strBuf.append("\t\"device\" :\n");
|
strBuf.append("\t\"device\" :\n");
|
||||||
strBuf.append("\t{\n");
|
strBuf.append("\t{\n");
|
||||||
@ -36,7 +39,8 @@ public class DeviceConfig {
|
|||||||
strBuf.append("\t\t\"name\" : \"").append(mName).append("\",\n");
|
strBuf.append("\t\t\"name\" : \"").append(mName).append("\",\n");
|
||||||
strBuf.append("\t\t\"type\" : \"").append(mType).append("\",\n");
|
strBuf.append("\t\t\"type\" : \"").append(mType).append("\",\n");
|
||||||
strBuf.append("\t\t\"output\" : \"").append(mOutput).append("\",\n");
|
strBuf.append("\t\t\"output\" : \"").append(mOutput).append("\",\n");
|
||||||
strBuf.append("\t\t\"rate\" : ").append(mBaudrate).append("\n");
|
strBuf.append("\t\t\"rate\" : ").append(mBaudrate).append(",\n");
|
||||||
|
strBuf.append("\t\t\"bgr-output\" : ").append(mBgrOutput).append("\n");
|
||||||
|
|
||||||
strBuf.append("\t}");
|
strBuf.append("\t}");
|
||||||
|
|
||||||
|
@ -5,9 +5,20 @@ package org.hyperion.hypercon.spec;
|
|||||||
*/
|
*/
|
||||||
public enum DeviceType {
|
public enum DeviceType {
|
||||||
/** WS2801 Led String device with one continuous shift-register */
|
/** WS2801 Led String device with one continuous shift-register */
|
||||||
ws2801,
|
ws2801("WS2801"),
|
||||||
/** Test device for writing color values to file-output */
|
/** Test device for writing color values to file-output */
|
||||||
test,
|
test("Test"),
|
||||||
/** No device, no output is generated */
|
/** No device, no output is generated */
|
||||||
none;
|
none("None");
|
||||||
|
|
||||||
|
private final String mName;
|
||||||
|
|
||||||
|
private DeviceType(String name) {
|
||||||
|
mName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return mName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user