From 7dce3ab798879bc75948579febc71d6bc254ac98 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Wed, 23 Mar 2016 21:12:34 +1100 Subject: [PATCH 1/3] renamed the "Test" device to be "File" No functional changes, but - files have been renamed - the device name is now "file" not "test" Former-commit-id: 3fbc03c3fe1d764654c1d28ebb80562ce6276ab1 --- config/hyperion.config.json | 2 +- config/hyperion_x86.config.json | 2 +- libsrc/leddevice/CMakeLists.txt | 6 +++--- libsrc/leddevice/LedDeviceFactory.cpp | 6 +++--- .../leddevice/{LedDeviceTest.cpp => LedDeviceFile.cpp} | 10 +++++----- libsrc/leddevice/{LedDeviceTest.h => LedDeviceFile.h} | 6 +++--- 6 files changed, 16 insertions(+), 16 deletions(-) rename libsrc/leddevice/{LedDeviceTest.cpp => LedDeviceFile.cpp} (55%) rename libsrc/leddevice/{LedDeviceTest.h => LedDeviceFile.h} (86%) diff --git a/config/hyperion.config.json b/config/hyperion.config.json index 0b8c5d8c..748781fd 100644 --- a/config/hyperion.config.json +++ b/config/hyperion.config.json @@ -5,7 +5,7 @@ /// 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 - /// APA102, Adalight, AmbiLed, Atmo, Hyperion-USBASP-WS2801, Hyperion-USBASP-WS2812, Lightberry, Lightpack, LPD6803, LPD8806, Multi-Lightpack, P9813, Paintpack, PhilipsHUE, PiBlaster, SEDU, Test, ThinkerForge, TPM2, WS2801, WS2812b, None) + /// APA102, Adalight, AmbiLed, Atmo, Hyperion-USBASP-WS2801, Hyperion-USBASP-WS2812, Lightberry, Lightpack, LPD6803, LPD8806, Multi-Lightpack, P9813, Paintpack, PhilipsHUE, PiBlaster, SEDU, file, ThinkerForge, TPM2, WS2801, WS2812b, None) /// * [device type specific configuration] /// * 'colorOrder' : The order of the color bytes ('rgb', 'rbg', 'bgr', etc.). "device" : diff --git a/config/hyperion_x86.config.json b/config/hyperion_x86.config.json index 79a02589..a17801b9 100644 --- a/config/hyperion_x86.config.json +++ b/config/hyperion_x86.config.json @@ -5,7 +5,7 @@ /// 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', 'ldp8806', - /// 'lpd6803', 'sedu', 'adalight', 'lightpack', 'test' and 'none') + /// 'lpd6803', 'sedu', 'adalight', 'lightpack', 'file' and 'none') /// * 'output' : The output specification depends on selected device. This can for example be the /// device specifier, device serial number, or the output file name /// * 'rate' : The baudrate of the output to the device diff --git a/libsrc/leddevice/CMakeLists.txt b/libsrc/leddevice/CMakeLists.txt index 66d61efd..6d89205a 100755 --- a/libsrc/leddevice/CMakeLists.txt +++ b/libsrc/leddevice/CMakeLists.txt @@ -21,7 +21,7 @@ SET(Leddevice_QT_HEADERS ${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.h ${CURRENT_SOURCE_DIR}/LedHIDDevice.h ${CURRENT_SOURCE_DIR}/LedDeviceRawHID.h - ${CURRENT_SOURCE_DIR}/LedDeviceTest.h + ${CURRENT_SOURCE_DIR}/LedDeviceFile.h ${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.h ) @@ -34,7 +34,7 @@ SET(Leddevice_HEADERS ${CURRENT_SOURCE_DIR}/LedDevicePaintpack.h ${CURRENT_SOURCE_DIR}/LedDevicePiBlaster.h ${CURRENT_SOURCE_DIR}/LedDeviceSedu.h - ${CURRENT_SOURCE_DIR}/LedDeviceTest.h + ${CURRENT_SOURCE_DIR}/LedDeviceFile.h ${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.h ${CURRENT_SOURCE_DIR}/LedDeviceUdp.h ${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.h @@ -58,7 +58,7 @@ SET(Leddevice_SOURCES ${CURRENT_SOURCE_DIR}/LedDevicePaintpack.cpp ${CURRENT_SOURCE_DIR}/LedDevicePiBlaster.cpp ${CURRENT_SOURCE_DIR}/LedDeviceSedu.cpp - ${CURRENT_SOURCE_DIR}/LedDeviceTest.cpp + ${CURRENT_SOURCE_DIR}/LedDeviceFile.cpp ${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.cpp ${CURRENT_SOURCE_DIR}/LedDeviceUdp.cpp ${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.cpp diff --git a/libsrc/leddevice/LedDeviceFactory.cpp b/libsrc/leddevice/LedDeviceFactory.cpp index a3dd87af..37f22511 100755 --- a/libsrc/leddevice/LedDeviceFactory.cpp +++ b/libsrc/leddevice/LedDeviceFactory.cpp @@ -29,7 +29,7 @@ #include "LedDevicePaintpack.h" #include "LedDevicePiBlaster.h" #include "LedDeviceSedu.h" -#include "LedDeviceTest.h" +#include "LedDeviceFile.h" #include "LedDeviceFadeCandy.h" #include "LedDeviceUdp.h" #include "LedDeviceHyperionUsbasp.h" @@ -275,10 +275,10 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig) device = new LedDeviceAtmoOrb(output, switchOffOnBlack, transitiontime, port, numLeds, orbIds); } - else if (type == "test") + else if (type == "file") { const std::string output = deviceConfig["output"].asString(); - device = new LedDeviceTest(output); + device = new LedDeviceFile(output); } else if (type == "fadecandy") { diff --git a/libsrc/leddevice/LedDeviceTest.cpp b/libsrc/leddevice/LedDeviceFile.cpp similarity index 55% rename from libsrc/leddevice/LedDeviceTest.cpp rename to libsrc/leddevice/LedDeviceFile.cpp index 4a616d2e..87085f39 100644 --- a/libsrc/leddevice/LedDeviceTest.cpp +++ b/libsrc/leddevice/LedDeviceFile.cpp @@ -1,19 +1,19 @@ // Local-Hyperion includes -#include "LedDeviceTest.h" +#include "LedDeviceFile.h" -LedDeviceTest::LedDeviceTest(const std::string& output) : +LedDeviceFile::LedDeviceFile(const std::string& output) : _ofs(output.empty()?"/home/pi/LedDevice.out":output.c_str()) { // empty } -LedDeviceTest::~LedDeviceTest() +LedDeviceFile::~LedDeviceFile() { // empty } -int LedDeviceTest::write(const std::vector & ledValues) +int LedDeviceFile::write(const std::vector & ledValues) { _ofs << "["; for (const ColorRgb& color : ledValues) @@ -25,7 +25,7 @@ int LedDeviceTest::write(const std::vector & ledValues) return 0; } -int LedDeviceTest::switchOff() +int LedDeviceFile::switchOff() { return 0; } diff --git a/libsrc/leddevice/LedDeviceTest.h b/libsrc/leddevice/LedDeviceFile.h similarity index 86% rename from libsrc/leddevice/LedDeviceTest.h rename to libsrc/leddevice/LedDeviceFile.h index cc4a6f32..ef7a54f7 100644 --- a/libsrc/leddevice/LedDeviceTest.h +++ b/libsrc/leddevice/LedDeviceFile.h @@ -10,18 +10,18 @@ /// Implementation of the LedDevice that write the led-colors to an /// ASCII-textfile('/home/pi/LedDevice.out') /// -class LedDeviceTest : public LedDevice +class LedDeviceFile : public LedDevice { public: /// /// Constructs the test-device, which opens an output stream to the file /// - LedDeviceTest(const std::string& output); + LedDeviceFile(const std::string& output); /// /// Destructor of this test-device /// - virtual ~LedDeviceTest(); + virtual ~LedDeviceFile(); /// /// Writes the given led-color values to the output stream From a3204ae6be65734fe90711f734716d5b4419114c Mon Sep 17 00:00:00 2001 From: penfold42 Date: Wed, 23 Mar 2016 21:28:31 +1100 Subject: [PATCH 2/3] LedDeviceFile now defaults to /dev/null if the output is omitted. Former-commit-id: eff12ec16d08ffa00287ed68238ab6b397f1c53d --- libsrc/leddevice/LedDeviceFactory.cpp | 2 +- libsrc/leddevice/LedDeviceFile.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libsrc/leddevice/LedDeviceFactory.cpp b/libsrc/leddevice/LedDeviceFactory.cpp index 37f22511..7e52748c 100755 --- a/libsrc/leddevice/LedDeviceFactory.cpp +++ b/libsrc/leddevice/LedDeviceFactory.cpp @@ -277,7 +277,7 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig) } else if (type == "file") { - const std::string output = deviceConfig["output"].asString(); + const std::string output = deviceConfig.get("output", "/dev/null").asString(); device = new LedDeviceFile(output); } else if (type == "fadecandy") diff --git a/libsrc/leddevice/LedDeviceFile.cpp b/libsrc/leddevice/LedDeviceFile.cpp index 87085f39..e6da1fc0 100644 --- a/libsrc/leddevice/LedDeviceFile.cpp +++ b/libsrc/leddevice/LedDeviceFile.cpp @@ -3,7 +3,7 @@ #include "LedDeviceFile.h" LedDeviceFile::LedDeviceFile(const std::string& output) : - _ofs(output.empty()?"/home/pi/LedDevice.out":output.c_str()) + _ofs(output.empty()?"/dev/null":output.c_str()) { // empty } From 1b50fdd74e2b147b266e705797b1869d61112f51 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Wed, 23 Mar 2016 13:35:38 +0100 Subject: [PATCH 3/3] Update hyperion-remote.cpp Former-commit-id: dec50a509837d19120ed9699a2618b61d77ec00d --- src/hyperion-remote/hyperion-remote.cpp | 93 +++++++++++++------------ 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/src/hyperion-remote/hyperion-remote.cpp b/src/hyperion-remote/hyperion-remote.cpp index 57f8448a..2da4ecfa 100644 --- a/src/hyperion-remote/hyperion-remote.cpp +++ b/src/hyperion-remote/hyperion-remote.cpp @@ -79,7 +79,7 @@ int main(int argc, char * argv[]) SwitchParameter<> & argHelp = parameters.add >('h', "help" , "Show this help message and exit"); StringParameter & argIdC = parameters.add ('y', "qualifier" , "Identifier(qualifier) of the correction to set"); CorrectionParameter & argCorrection = parameters.add('Y', "correction" , "Set the correction of the leds (requires 3 space seperated values between 0 and 255)"); - StringParameter & argIdT = parameters.add ('z', "qualifier" , "Identifier(qualifier) of the temperature to set"); + StringParameter & argIdT = parameters.add ('z', "qualifier" , "Identifier(qualifier) of the temperature correction to set"); CorrectionParameter & argTemperature = parameters.add('Z', "temperature" , "Set the temperature correction of the leds (requires 3 space seperated values between 0 and 255)"); // set the default values @@ -100,9 +100,10 @@ int main(int argc, char * argv[]) // check if at least one of the available color transforms is set bool colorTransform = argSaturation.isSet() || argValue.isSet() || argSaturationL.isSet() || argLuminance.isSet() || argThreshold.isSet() || argGamma.isSet() || argBlacklevel.isSet() || argWhitelevel.isSet(); - + bool colorModding = colorTransform || argCorrection.isSet() || argTemperature.isSet(); + // check that exactly one command was given - int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorTransform, argCorrection.isSet(), argTemperature.isSet()}); + int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorModding}); if (commandCount != 1) { std::cerr << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:" << std::endl; @@ -112,7 +113,7 @@ int main(int argc, char * argv[]) std::cerr << " " << argServerInfo.usageLine() << std::endl; std::cerr << " " << argClear.usageLine() << std::endl; std::cerr << " " << argClearAll.usageLine() << std::endl; - std::cerr << "one or more of the available color transformations:" << std::endl; + std::cerr << "or one or more of the available color modding operations:" << std::endl; std::cerr << " " << argId.usageLine() << std::endl; std::cerr << " " << argSaturation.usageLine() << std::endl; std::cerr << " " << argValue.usageLine() << std::endl; @@ -122,10 +123,8 @@ int main(int argc, char * argv[]) std::cerr << " " << argGamma.usageLine() << std::endl; std::cerr << " " << argBlacklevel.usageLine() << std::endl; std::cerr << " " << argWhitelevel.usageLine() << std::endl; - std::cerr << "one or more of the available color corrections:" << std::endl; std::cerr << " " << argIdC.usageLine() << std::endl; std::cerr << " " << argCorrection.usageLine() << std::endl; - std::cerr << "or one or more of the available color temperature adjustment:" << std::endl; std::cerr << " " << argIdT.usageLine() << std::endl; std::cerr << " " << argTemperature.usageLine() << std::endl; return 1; @@ -160,23 +159,50 @@ int main(int argc, char * argv[]) { connection.clearAll(); } - else if (colorTransform) - { - std::string transId; - double saturation, value, saturationL, luminance; - ColorTransformValues threshold, gamma, blacklevel, whitelevel; + else if (colorModding) + { + if (argCorrection.isSet()) + { + std::string corrId; + ColorCorrectionValues correction; - if (argId.isSet()) transId = argId.getValue(); - if (argSaturation.isSet()) saturation = argSaturation.getValue(); - if (argValue.isSet()) value = argValue.getValue(); - if (argSaturationL.isSet()) saturationL = argSaturationL.getValue(); - if (argLuminance.isSet()) luminance = argLuminance.getValue(); - if (argThreshold.isSet()) threshold = argThreshold.getValue(); - if (argGamma.isSet()) gamma = argGamma.getValue(); - if (argBlacklevel.isSet()) blacklevel = argBlacklevel.getValue(); - if (argWhitelevel.isSet()) whitelevel = argWhitelevel.getValue(); + if (argIdC.isSet()) corrId = argIdC.getValue(); + if (argCorrection.isSet()) correction = argCorrection.getValue(); + + connection.setCorrection( + argIdC.isSet() ? &corrId : nullptr, + argCorrection.isSet() ? &correction : nullptr); + } + + if (argTemperature.isSet()) + { + std::string tempId; + ColorCorrectionValues temperature; + + if (argIdT.isSet()) tempId = argIdT.getValue(); + if (argTemperature.isSet()) temperature = argTemperature.getValue(); - connection.setTransform( + connection.setTemperature( + argIdT.isSet() ? &tempId : nullptr, + argTemperature.isSet() ? &temperature : nullptr); + } + if (colorTransform) + { + std::string transId; + double saturation, value, saturationL, luminance; + ColorTransformValues threshold, gamma, blacklevel, whitelevel; + + if (argId.isSet()) transId = argId.getValue(); + if (argSaturation.isSet()) saturation = argSaturation.getValue(); + if (argValue.isSet()) value = argValue.getValue(); + if (argSaturationL.isSet()) saturationL = argSaturationL.getValue(); + if (argLuminance.isSet()) luminance = argLuminance.getValue(); + if (argThreshold.isSet()) threshold = argThreshold.getValue(); + if (argGamma.isSet()) gamma = argGamma.getValue(); + if (argBlacklevel.isSet()) blacklevel = argBlacklevel.getValue(); + if (argWhitelevel.isSet()) whitelevel = argWhitelevel.getValue(); + + connection.setTransform( argId.isSet() ? &transId : nullptr, argSaturation.isSet() ? &saturation : nullptr, argValue.isSet() ? &value : nullptr, @@ -186,30 +212,7 @@ int main(int argc, char * argv[]) argGamma.isSet() ? &gamma : nullptr, argBlacklevel.isSet() ? &blacklevel : nullptr, argWhitelevel.isSet() ? &whitelevel : nullptr); - } - else if (argCorrection.isSet()) - { - std::string corrId; - ColorCorrectionValues correction; - - if (argIdC.isSet()) corrId = argIdC.getValue(); - if (argCorrection.isSet()) correction = argCorrection.getValue(); - - connection.setCorrection( - argIdC.isSet() ? &corrId : nullptr, - argCorrection.isSet() ? &correction : nullptr); - } - else if (argTemperature.isSet()) - { - std::string tempId; - ColorCorrectionValues temperature; - - if (argIdT.isSet()) tempId = argIdT.getValue(); - if (argTemperature.isSet()) temperature = argTemperature.getValue(); - - connection.setTemperature( - argIdT.isSet() ? &tempId : nullptr, - argTemperature.isSet() ? &temperature : nullptr); + } } } catch (const std::runtime_error & e)