mirror of
				https://github.com/hyperion-project/hyperion.ng.git
				synced 2025-03-01 10:33:28 +00:00 
			
		
		
		
	added flag to have BGR output instead of RGB
Former-commit-id: dbd35d6dd4a84d95e0a034b99843be4949a6e169
This commit is contained in:
		@@ -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:
 | 
			
		||||
 
 | 
			
		||||
@@ -1 +1 @@
 | 
			
		||||
8b85d78801cd11fdefd0d389d61e2c9e5a50ad03
 | 
			
		||||
001950ae6499ac83babe8e563be11b8daacd554c
 | 
			
		||||
@@ -1 +1 @@
 | 
			
		||||
db4c1c44b95467b193a79ea0b0ddab37d54f7566
 | 
			
		||||
c2bbbf969d7dbe0e096670758e37284b827b3d03
 | 
			
		||||
@@ -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;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -22,6 +22,10 @@
 | 
			
		||||
                    "type" : "integer",
 | 
			
		||||
                    "required" : true,
 | 
			
		||||
                    "minimum" : 0
 | 
			
		||||
                },
 | 
			
		||||
                "bgr-output" : {
 | 
			
		||||
                    "type" : "boolean",
 | 
			
		||||
                    "required" : false
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
            "additionalProperties" : false
 | 
			
		||||
 
 | 
			
		||||
@@ -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}");
 | 
			
		||||
		
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user