From 2471bd8753df8d1cb37ea1d9ede3654ae1226c6d Mon Sep 17 00:00:00 2001 From: johan Date: Sun, 27 Oct 2013 10:18:31 +0100 Subject: [PATCH] added flag to have BGR output instead of RGB Former-commit-id: dbd35d6dd4a84d95e0a034b99843be4949a6e169 --- config/hyperion.config.json | 22 +++++++++-------- deploy/HyperCon.jar.REMOVED.git-id | 2 +- deploy/hyperiond.REMOVED.git-id | 2 +- include/hyperion/Hyperion.h | 3 +++ libsrc/hyperion/Hyperion.cpp | 6 +++++ libsrc/hyperion/hyperion.schema.json | 4 ++++ .../hyperion/hypercon/spec/DeviceConfig.java | 24 +++++++++++-------- .../hyperion/hypercon/spec/DeviceType.java | 17 ++++++++++--- 8 files changed, 55 insertions(+), 25 deletions(-) diff --git a/config/hyperion.config.json b/config/hyperion.config.json index 9ec5ae49..e6e348fb 100644 --- a/config/hyperion.config.json +++ b/config/hyperion.config.json @@ -3,18 +3,20 @@ { /// Device configuration contains the following fields: - /// * 'name' : The user friendly name of the device (only used for display purposes) - /// * 'type' : The type of the device or leds (known types for now are 'ws2801', 'test' and 'none') - /// * 'output' : The output specification depends on selected device - /// - 'ws2801' this is the device (eg '/dev/spidev0.0') - /// - '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') + /// * 'name' : The user friendly name of the device (only used for display purposes) + /// * 'type' : The type of the device or leds (known types for now are 'ws2801', 'test' and 'none') + /// * 'output' : The output specification depends on selected device + /// - 'ws2801' this is the device (eg '/dev/spidev0.0') + /// - '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') + /// * 'bgr-output' : Use BGR output instead of RGB (reverse red and blue). "device" : { - "name" : "MyPi", - "type" : "ws2801", - "output" : "/dev/spidev0.0", - "rate" : 1000000 + "name" : "MyPi", + "type" : "ws2801", + "output" : "/dev/spidev0.0", + "rate" : 1000000, + "bgr-output" : false }, /// Color manipulation configuration used to tune the output colors to specific surroundings. Contains the following fields: diff --git a/deploy/HyperCon.jar.REMOVED.git-id b/deploy/HyperCon.jar.REMOVED.git-id index 5de027ce..1da5f8bd 100644 --- a/deploy/HyperCon.jar.REMOVED.git-id +++ b/deploy/HyperCon.jar.REMOVED.git-id @@ -1 +1 @@ -8b85d78801cd11fdefd0d389d61e2c9e5a50ad03 \ No newline at end of file +001950ae6499ac83babe8e563be11b8daacd554c \ No newline at end of file diff --git a/deploy/hyperiond.REMOVED.git-id b/deploy/hyperiond.REMOVED.git-id index 6b43ef26..7af28f7e 100644 --- a/deploy/hyperiond.REMOVED.git-id +++ b/deploy/hyperiond.REMOVED.git-id @@ -1 +1 @@ -db4c1c44b95467b193a79ea0b0ddab37d54f7566 \ No newline at end of file +c2bbbf969d7dbe0e096670758e37284b827b3d03 \ No newline at end of file diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index 5a9e0159..51cd8d60 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -171,6 +171,9 @@ private: /// The BLUE-Channel (RGB) transform ColorTransform * _blueTransform; + /// Flag indicating if the output should be BGR (red and blue reversed) + bool _haveBgrOutput; + /// The actual LedDevice LedDevice* _device; diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index a5af70f6..ee27f4c6 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -96,6 +96,7 @@ Hyperion::Hyperion(const Json::Value &jsonConfig) : _redTransform(createColorTransform(jsonConfig["color"]["red"])), _greenTransform(createColorTransform(jsonConfig["color"]["green"])), _blueTransform(createColorTransform(jsonConfig["color"]["blue"])), + _haveBgrOutput(jsonConfig["device"].get("bgr-output", false).asBool()), _device(constructDevice(jsonConfig["device"])), _timer() { @@ -301,6 +302,11 @@ void Hyperion::update() color.red = _redTransform->transform(color.red); color.green = _greenTransform->transform(color.green); color.blue = _blueTransform->transform(color.blue); + + if (_haveBgrOutput) + { + std::swap(color.red, color.blue); + } } // Write the data to the device diff --git a/libsrc/hyperion/hyperion.schema.json b/libsrc/hyperion/hyperion.schema.json index 443287da..755ed98e 100644 --- a/libsrc/hyperion/hyperion.schema.json +++ b/libsrc/hyperion/hyperion.schema.json @@ -22,6 +22,10 @@ "type" : "integer", "required" : true, "minimum" : 0 + }, + "bgr-output" : { + "type" : "boolean", + "required" : false } }, "additionalProperties" : false diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/DeviceConfig.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/DeviceConfig.java index 8147e7f3..e99341fb 100644 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/DeviceConfig.java +++ b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/DeviceConfig.java @@ -13,6 +13,8 @@ public class DeviceConfig { String mOutput = "/dev/spidev0.0"; /** The baudrate of the device */ 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 @@ -23,20 +25,22 @@ public class DeviceConfig { StringBuffer strBuf = new StringBuffer(); strBuf.append("\t/// Device configuration contains the following fields: \n"); - strBuf.append("\t/// * 'name' : The user friendly name of the device (only used for display purposes)\n"); - strBuf.append("\t/// * 'type' : The type of the device or leds (known types for now are 'ws2801', 'test' and 'none')\n"); - strBuf.append("\t/// * 'output' : The output specification depends on selected device\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/// * 'rate' : The baudrate of the output to the device (only applicable for 'ws2801')\n"); + strBuf.append("\t/// * 'name' : The user friendly name of the device (only used for display purposes)\n"); + strBuf.append("\t/// * 'type' : The type of the device or leds (known types for now are 'ws2801', 'test' and 'none')\n"); + strBuf.append("\t/// * 'output' : The output specification depends on selected device\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/// * '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{\n"); - strBuf.append("\t\t\"name\" : \"").append(mName).append("\",\n"); - strBuf.append("\t\t\"type\" : \"").append(mType).append("\",\n"); - strBuf.append("\t\t\"output\" : \"").append(mOutput).append("\",\n"); - strBuf.append("\t\t\"rate\" : ").append(mBaudrate).append("\n"); + strBuf.append("\t\t\"name\" : \"").append(mName).append("\",\n"); + strBuf.append("\t\t\"type\" : \"").append(mType).append("\",\n"); + strBuf.append("\t\t\"output\" : \"").append(mOutput).append("\",\n"); + strBuf.append("\t\t\"rate\" : ").append(mBaudrate).append(",\n"); + strBuf.append("\t\t\"bgr-output\" : ").append(mBgrOutput).append("\n"); strBuf.append("\t}"); diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/DeviceType.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/DeviceType.java index 963a49e3..4d2f1819 100644 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/DeviceType.java +++ b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/DeviceType.java @@ -5,9 +5,20 @@ package org.hyperion.hypercon.spec; */ public enum DeviceType { /** WS2801 Led String device with one continuous shift-register */ - ws2801, + ws2801("WS2801"), /** Test device for writing color values to file-output */ - test, + test("Test"), /** 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; + } }