From 30421bd808049564f64eeef2579b9f6bea9b4ca7 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Tue, 22 Dec 2015 09:56:17 +0100 Subject: [PATCH 01/67] Create ColorCorrection.h Former-commit-id: f52df680a7f056d37d23e9f7d49fa713d8b48949 --- include/hyperion/ColorCorrection.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 include/hyperion/ColorCorrection.h diff --git a/include/hyperion/ColorCorrection.h b/include/hyperion/ColorCorrection.h new file mode 100644 index 00000000..51ae0605 --- /dev/null +++ b/include/hyperion/ColorCorrection.h @@ -0,0 +1,18 @@ +#pragma once + +// STL includes +#include + +// Utils includes +#include + +class ColorCorrection +{ +public: + + /// Unique identifier for this color correction + std::string _id; + + /// The RGB correction + RgbChannelCorrection _rgbCorrection; +}; From e6fe6e5bc7160352f918b3789a730efe656f97a8 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Tue, 22 Dec 2015 09:57:08 +0100 Subject: [PATCH 02/67] Create HslTransform.h Former-commit-id: 2014641903af65c9ee1ac23cd90dad44d35f6c9f --- include/utils/HslTransform.h | 108 +++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 include/utils/HslTransform.h diff --git a/include/utils/HslTransform.h b/include/utils/HslTransform.h new file mode 100644 index 00000000..01eb4f55 --- /dev/null +++ b/include/utils/HslTransform.h @@ -0,0 +1,108 @@ +#pragma once + +// STL includes +#include + +/// +/// Color transformation to adjust the saturation and value of a RGB color value +/// +class HslTransform +{ +public: + /// + /// Default constructor + /// + HslTransform(); + + /// + /// Constructor + /// + /// @param saturationGain The used saturation gain + /// @param luminanceGain The used luminance gain + /// + HslTransform(double saturationGain, double luminanceGain); + + /// + /// Destructor + /// + ~HslTransform(); + + /// + /// Updates the saturation gain + /// + /// @param saturationGain New saturationGain + /// + void setSaturationGain(double saturationGain); + + /// + /// Returns the saturation gain + /// + /// @return The current Saturation gain + /// + double getSaturationGain() const; + + /// + /// Updates the luminance gain + /// + /// @param luminanceGain New luminance gain + /// + void setLuminanceGain(double luminanceGain); + + /// + /// Returns the luminance gain + /// + /// @return The current luminance gain + /// + double getLuminanceGain() const; + + /// + /// Apply the transform the the given RGB values. + /// + /// @param red The red color component + /// @param green The green color component + /// @param blue The blue color component + /// + /// @note The values are updated in place. + /// + void transform(uint8_t & red, uint8_t & green, uint8_t & blue) const; + + /// + /// Translates an RGB (red, green, blue) color to an HSL (hue, saturation, luminance) color + /// + /// @param[in] red The red RGB-component + /// @param[in] green The green RGB-component + /// @param[in] blue The blue RGB-component + /// @param[out] hue The hue HSL-component + /// @param[out] saturation The saturation HSL-component + /// @param[out] luminance The luminance HSL-component + /// + /// @note Integer version of the conversion are faster, but a little less accurate all values + /// are unsigned 8 bit values and scaled between 0 and 255 except for the hue which is a 16 bit + /// number and scaled between 0 and 360 + /// + static void rgb2hsl(uint8_t red, uint8_t green, uint8_t blue, uint16_t & hue, float & saturation, float & luminance); + + /// + /// Translates an HSL (hue, saturation, luminance) color to an RGB (red, green, blue) color + /// + /// @param[in] hue The hue HSV-component + /// @param[in] saturation The saturation HSV-component + /// @param[in] luminance The luminance HSL-component + /// @param[out] red The red RGB-component + /// @param[out] green The green RGB-component + /// @param[out] blue The blue RGB-component + /// + /// @note Integer version of the conversion are faster, but a little less accurate all values + /// are unsigned 8 bit values and scaled between 0 and 255 except for the hue which is a 16 bit + /// number and scaled between 0 and 360 + /// + static void hsl2rgb(uint16_t hue, float saturation, float luminance, uint8_t & red, uint8_t & green, uint8_t & blue); + +private: + /// The saturation gain + double _saturationGain; + /// The value gain + double _luminanceGain; + /// aux function + float hue2rgb(float p, float q, float t); +}; From 2eabc34f0981f279407ac53b37b5a61080885935 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Tue, 22 Dec 2015 09:58:49 +0100 Subject: [PATCH 03/67] Update HslTransform.h Former-commit-id: 634544dbb41949a55591f5b41ef956588c5c7946 --- include/utils/HslTransform.h | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/include/utils/HslTransform.h b/include/utils/HslTransform.h index 01eb4f55..f2151e65 100644 --- a/include/utils/HslTransform.h +++ b/include/utils/HslTransform.h @@ -4,7 +4,7 @@ #include /// -/// Color transformation to adjust the saturation and value of a RGB color value +/// Color transformation to adjust the saturation and luminance of a RGB color value /// class HslTransform { @@ -76,33 +76,25 @@ public: /// @param[out] saturation The saturation HSL-component /// @param[out] luminance The luminance HSL-component /// - /// @note Integer version of the conversion are faster, but a little less accurate all values - /// are unsigned 8 bit values and scaled between 0 and 255 except for the hue which is a 16 bit - /// number and scaled between 0 and 360 - /// + static void rgb2hsl(uint8_t red, uint8_t green, uint8_t blue, uint16_t & hue, float & saturation, float & luminance); /// /// Translates an HSL (hue, saturation, luminance) color to an RGB (red, green, blue) color /// - /// @param[in] hue The hue HSV-component - /// @param[in] saturation The saturation HSV-component + /// @param[in] hue The hue HSL-component + /// @param[in] saturation The saturation HSL-component /// @param[in] luminance The luminance HSL-component /// @param[out] red The red RGB-component /// @param[out] green The green RGB-component /// @param[out] blue The blue RGB-component /// - /// @note Integer version of the conversion are faster, but a little less accurate all values - /// are unsigned 8 bit values and scaled between 0 and 255 except for the hue which is a 16 bit - /// number and scaled between 0 and 360 - /// + static void hsl2rgb(uint16_t hue, float saturation, float luminance, uint8_t & red, uint8_t & green, uint8_t & blue); private: /// The saturation gain double _saturationGain; - /// The value gain + /// The luminance gain double _luminanceGain; - /// aux function - float hue2rgb(float p, float q, float t); }; From a23aa38f2010a210dcb2689489b471d1c9723410 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Tue, 22 Dec 2015 09:59:17 +0100 Subject: [PATCH 04/67] Create RgbChannelCorrection.h Former-commit-id: 7b0decaf9a9829cbc39a9d14db6bb42fb3d68445 --- include/utils/RgbChannelCorrection.h | 67 ++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 include/utils/RgbChannelCorrection.h diff --git a/include/utils/RgbChannelCorrection.h b/include/utils/RgbChannelCorrection.h new file mode 100644 index 00000000..7e00a633 --- /dev/null +++ b/include/utils/RgbChannelCorrection.h @@ -0,0 +1,67 @@ +#pragma once + +// STL includes +#include + +/// Correction for a single color byte value +/// All configuration values are unsigned int and assume the color value to be between 0 and 255 +class RgbChannelCorrection +{ +public: + /// Default constructor + RgbChannelCorrection(); + + /// Constructor + /// @param correctionR + /// @param correctionG + /// @param correctionB + + RgbChannelCorrection(int correctionR, int correctionG, int correctionB); + + /// Destructor + ~RgbChannelCorrection(); + + /// @return The current correctionR value + uint8_t getcorrectionR() const; + + /// @param threshold New correctionR value + void setcorrectionR(uint8_t correctionR); + + /// @return The current correctionG value + uint8_t getcorrectionG() const; + + /// @param gamma New correctionG value + void setcorrectionG(uint8_t correctionG); + + /// @return The current correctionB value + uint8_t getcorrectionB() const; + + /// @param blacklevel New correctionB value + void setcorrectionB(uint8_t correctionB); + + /// Transform the given array value + /// @param input The input color bytes + /// @return The transformed byte value + uint8_t correctionR(uint8_t inputR) const; + uint8_t correctionG(uint8_t inputG) const; + uint8_t correctionB(uint8_t inputB) const; + + +private: + /// (re)-initilize the color mapping + void initializeMapping(); + +private: + /// The correction of R channel + int _correctionR; + /// The correction of G channel + int _correctionG; + /// The correction of B channel + int _correctionB; + + /// The mapping from input color to output color + + int _mappingR[256]; + int _mappingG[256]; + int _mappingB[256]; +}; From 7773a82cb40935038eed3396b20cd1e793a49721 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Tue, 22 Dec 2015 09:59:55 +0100 Subject: [PATCH 05/67] Update RgbChannelCorrection.h Former-commit-id: 003e07c72d2244f2ffb6f4c4cb2b3b691ecaaad7 --- include/utils/RgbChannelCorrection.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/utils/RgbChannelCorrection.h b/include/utils/RgbChannelCorrection.h index 7e00a633..f09b9cef 100644 --- a/include/utils/RgbChannelCorrection.h +++ b/include/utils/RgbChannelCorrection.h @@ -41,7 +41,7 @@ public: /// Transform the given array value /// @param input The input color bytes - /// @return The transformed byte value + /// @return The corrected byte value uint8_t correctionR(uint8_t inputR) const; uint8_t correctionG(uint8_t inputG) const; uint8_t correctionB(uint8_t inputB) const; @@ -60,7 +60,6 @@ private: int _correctionB; /// The mapping from input color to output color - int _mappingR[256]; int _mappingG[256]; int _mappingB[256]; From d3afc41040f98ad3b21961e3afeab507cb8dda00 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Tue, 22 Dec 2015 10:01:08 +0100 Subject: [PATCH 06/67] Update CMakeLists.txt Former-commit-id: 470a5b8f4a7c5a44b7aaff7a6c8f834ff55472bf --- libsrc/hyperion/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libsrc/hyperion/CMakeLists.txt b/libsrc/hyperion/CMakeLists.txt index 8f6a227d..f671fea5 100644 --- a/libsrc/hyperion/CMakeLists.txt +++ b/libsrc/hyperion/CMakeLists.txt @@ -18,6 +18,7 @@ SET(Hyperion_HEADERS ${CURRENT_HEADER_DIR}/PriorityMuxer.h ${CURRENT_SOURCE_DIR}/MultiColorTransform.h + ${CURRENT_SOURCE_DIR}/MultiColorCorrection.h ) SET(Hyperion_SOURCES @@ -29,6 +30,7 @@ SET(Hyperion_SOURCES ${CURRENT_SOURCE_DIR}/ImageToLedsMap.cpp ${CURRENT_SOURCE_DIR}/MultiColorTransform.cpp + ${CURRENT_SOURCE_DIR}/MultiColorCorrection.cpp ${CURRENT_SOURCE_DIR}/LinearColorSmoothing.cpp ) From 9acdf946bf5aae27ae995e6039e644fd9c3f053c Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Tue, 22 Dec 2015 10:01:47 +0100 Subject: [PATCH 07/67] Update Hyperion.cpp Former-commit-id: acf5e5c722402f7527ae0b942437d4c01917dccb --- libsrc/hyperion/Hyperion.cpp | 219 ++++++++++++++++++++++++++++++++++- 1 file changed, 217 insertions(+), 2 deletions(-) diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index d6657046..dc6ca3fb 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -15,12 +15,15 @@ // hyperion include #include #include +#include +#include // Leddevice includes #include #include #include "MultiColorTransform.h" +#include "MultiColorCorrection.h" #include "LinearColorSmoothing.h" // effect engine includes @@ -77,6 +80,7 @@ ColorTransform * Hyperion::createColorTransform(const Json::Value & transformCon RgbChannelTransform * blueTransform = createRgbChannelTransform(transformConfig["blue"]); HsvTransform * hsvTransform = createHsvTransform(transformConfig["hsv"]); + HslTransform * hslTransform = createHslTransform(transformConfig["hsl"]); ColorTransform * transform = new ColorTransform(); transform->_id = id; @@ -84,16 +88,35 @@ ColorTransform * Hyperion::createColorTransform(const Json::Value & transformCon transform->_rgbGreenTransform = *greenTransform; transform->_rgbBlueTransform = *blueTransform; transform->_hsvTransform = *hsvTransform; + transform->_hslTransform = *hslTransform; + // Cleanup the allocated individual transforms delete redTransform; delete greenTransform; delete blueTransform; delete hsvTransform; + delete hslTransform; return transform; } +ColorCorrection * Hyperion::createColorCorrection(const Json::Value & correctionConfig) +{ + const std::string id = correctionConfig.get("id", "default").asString(); + + RgbChannelCorrection * rgbCorrection = createRgbChannelCorrection(correctionConfig["correctionValues"]); + + ColorCorrection * correction = new ColorCorrection(); + correction->_id = id; + correction->_rgbCorrection = *rgbCorrection; + + // Cleanup the allocated individual transforms + delete rgbCorrection; + + return correction; +} + MultiColorTransform * Hyperion::createLedColorsTransform(const unsigned ledCnt, const Json::Value & colorConfig) { // Create the result, the transforms are added to this @@ -168,6 +191,154 @@ MultiColorTransform * Hyperion::createLedColorsTransform(const unsigned ledCnt, return transform; } +MultiColorCorrection * Hyperion::createLedColorsCorrection(const unsigned ledCnt, const Json::Value & colorConfig) +{ + // Create the result, the corrections are added to this + MultiColorCorrection * correction = new MultiColorCorrection(ledCnt); + + const Json::Value correctionConfig = colorConfig.get("correction", Json::nullValue); + if (correctionConfig.isNull()) + { + // Old style color correction config (just one for all leds) + ColorCorrection * colorCorrection = createColorCorrection(colorConfig); + correction->addCorrection(colorCorrection); + correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1); + } + else if (!correctionConfig.isArray()) + { + ColorCorrection * colorCorrection = createColorCorrection(colorConfig); + correction->addCorrection(colorCorrection); + correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1); + } + else + { + const QRegExp overallExp("([0-9]+(\\-[0-9]+)?)(,[ ]*([0-9]+(\\-[0-9]+)?))*"); + + for (Json::UInt i = 0; i < correctionConfig.size(); ++i) + { + const Json::Value & config = correctionConfig[i]; + ColorCorrection * colorCorrection = createColorCorrection(config); + correction->addCorrection(colorCorrection); + + const QString ledIndicesStr = QString(config.get("leds", "").asCString()).trimmed(); + if (ledIndicesStr.compare("*") == 0) + { + // Special case for indices '*' => all leds + correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1); + std::cout << "ColorCorrection '" << colorCorrection->_id << "' => [0; "<< ledCnt-1 << "]" << std::endl; + continue; + } + + if (!overallExp.exactMatch(ledIndicesStr)) + { + std::cerr << "Given led indices " << i << " not correct format: " << ledIndicesStr.toStdString() << std::endl; + continue; + } + + std::cout << "ColorCorrection '" << colorCorrection->_id << "' => ["; + + const QStringList ledIndexList = ledIndicesStr.split(","); + for (int i=0; i 0) + { + std::cout << ", "; + } + if (ledIndexList[i].contains("-")) + { + QStringList ledIndices = ledIndexList[i].split("-"); + int startInd = ledIndices[0].toInt(); + int endInd = ledIndices[1].toInt(); + + correction->setCorrectionForLed(colorCorrection->_id, startInd, endInd); + std::cout << startInd << "-" << endInd; + } + else + { + int index = ledIndexList[i].toInt(); + correction->setCorrectionForLed(colorCorrection->_id, index, index); + std::cout << index; + } + } + std::cout << "]" << std::endl; + } + } + return correction; +} + +MultiColorCorrection * Hyperion::createLedColorsTemperature(const unsigned ledCnt, const Json::Value & colorConfig) +{ + // Create the result, the corrections are added to this + MultiColorCorrection * correction = new MultiColorCorrection(ledCnt); + + const Json::Value correctionConfig = colorConfig.get("temperature", Json::nullValue); + if (correctionConfig.isNull()) + { + // Old style color correction config (just one for all leds) + ColorCorrection * colorCorrection = createColorCorrection(colorConfig); + correction->addCorrection(colorCorrection); + correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1); + } + else if (!correctionConfig.isArray()) + { + ColorCorrection * colorCorrection = createColorCorrection(colorConfig); + correction->addCorrection(colorCorrection); + correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1); + } + else + { + const QRegExp overallExp("([0-9]+(\\-[0-9]+)?)(,[ ]*([0-9]+(\\-[0-9]+)?))*"); + + for (Json::UInt i = 0; i < correctionConfig.size(); ++i) + { + const Json::Value & config = correctionConfig[i]; + ColorCorrection * colorCorrection = createColorCorrection(config); + correction->addCorrection(colorCorrection); + + const QString ledIndicesStr = QString(config.get("leds", "").asCString()).trimmed(); + if (ledIndicesStr.compare("*") == 0) + { + // Special case for indices '*' => all leds + correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1); + std::cout << "ColorCorrection '" << colorCorrection->_id << "' => [0; "<< ledCnt-1 << "]" << std::endl; + continue; + } + + if (!overallExp.exactMatch(ledIndicesStr)) + { + std::cerr << "Given led indices " << i << " not correct format: " << ledIndicesStr.toStdString() << std::endl; + continue; + } + + std::cout << "ColorCorrection '" << colorCorrection->_id << "' => ["; + + const QStringList ledIndexList = ledIndicesStr.split(","); + for (int i=0; i 0) + { + std::cout << ", "; + } + if (ledIndexList[i].contains("-")) + { + QStringList ledIndices = ledIndexList[i].split("-"); + int startInd = ledIndices[0].toInt(); + int endInd = ledIndices[1].toInt(); + + correction->setCorrectionForLed(colorCorrection->_id, startInd, endInd); + std::cout << startInd << "-" << endInd; + } + else + { + int index = ledIndexList[i].toInt(); + correction->setCorrectionForLed(colorCorrection->_id, index, index); + std::cout << index; + } + } + std::cout << "]" << std::endl; + } + } + return correction; +} + HsvTransform * Hyperion::createHsvTransform(const Json::Value & hsvConfig) { const double saturationGain = hsvConfig.get("saturationGain", 1.0).asDouble(); @@ -176,6 +347,14 @@ HsvTransform * Hyperion::createHsvTransform(const Json::Value & hsvConfig) return new HsvTransform(saturationGain, valueGain); } +HslTransform * Hyperion::createHslTransform(const Json::Value & hslConfig) +{ + const double saturationGain = hslConfig.get("saturationGain", 1.0).asDouble(); + const double luminanceGain = hslConfig.get("luminanceGain", 1.0).asDouble(); + + return new HslTransform(saturationGain, luminanceGain); +} + RgbChannelTransform* Hyperion::createRgbChannelTransform(const Json::Value& colorConfig) { const double threshold = colorConfig.get("threshold", 0.0).asDouble(); @@ -187,6 +366,16 @@ RgbChannelTransform* Hyperion::createRgbChannelTransform(const Json::Value& colo return transform; } +RgbChannelCorrection* Hyperion::createRgbChannelCorrection(const Json::Value& colorConfig) +{ + const int varR = colorConfig.get("red", 255).asInt(); + const int varG = colorConfig.get("green", 255).asInt(); + const int varB = colorConfig.get("blue", 255).asInt(); + + RgbChannelCorrection* correction = new RgbChannelCorrection(varR, varG, varB); + return correction; +} + LedString Hyperion::createLedString(const Json::Value& ledsConfig, const ColorOrder deviceOrder) { LedString ledString; @@ -270,11 +459,17 @@ LedDevice * Hyperion::createColorSmoothing(const Json::Value & smoothingConfig, Hyperion::Hyperion(const Json::Value &jsonConfig) : _ledString(createLedString(jsonConfig["leds"], createColorOrder(jsonConfig["device"]))), _muxer(_ledString.leds().size()), + _raw2ledCorrection(createLedColorsCorrection(_ledString.leds().size(), jsonConfig["color"])), + _raw2ledTemperature(createLedColorsTemperature(_ledString.leds().size(), jsonConfig["color"])), _raw2ledTransform(createLedColorsTransform(_ledString.leds().size(), jsonConfig["color"])), _device(LedDeviceFactory::construct(jsonConfig["device"])), _effectEngine(nullptr), _timer() { + if (!_raw2ledCorrection->verifyCorrections()) + { + throw std::runtime_error("Color correction incorrectly set"); + } if (!_raw2ledTransform->verifyTransforms()) { throw std::runtime_error("Color transformation incorrectly set"); @@ -314,6 +509,9 @@ Hyperion::~Hyperion() // delete the color transform delete _raw2ledTransform; + + // delete the color correction + delete _raw2ledCorrection; } unsigned Hyperion::getLedCount() const @@ -359,16 +557,31 @@ const std::vector & Hyperion::getTransformIds() const return _raw2ledTransform->getTransformIds(); } +const std::vector & Hyperion::getCorrectionIds() const +{ + return _raw2ledCorrection->getCorrectionIds(); +} + ColorTransform * Hyperion::getTransform(const std::string& id) { return _raw2ledTransform->getTransform(id); } +ColorCorrection * Hyperion::getCorrection(const std::string& id) +{ + return _raw2ledCorrection->getCorrection(id); +} + void Hyperion::transformsUpdated() { update(); } +void Hyperion::correctionsUpdated() +{ + update(); +} + void Hyperion::clear(int priority) { if (_muxer.hasPriority(priority)) @@ -432,8 +645,10 @@ void Hyperion::update() int priority = _muxer.getCurrentPriority(); const PriorityMuxer::InputInfo & priorityInfo = _muxer.getInputInfo(priority); - // Apply the transform to each led and color-channel - std::vector ledColors = _raw2ledTransform->applyTransform(priorityInfo.ledColors); + // Apply the correction and the transform to each led and color-channel + std::vector correctedColors = _raw2ledCorrection->applyCorrection(priorityInfo.ledColors); + std::vector temperatureColors = _raw2ledTemperature->applyCorrection(correctedColors); + std::vector ledColors =_raw2ledTransform->applyTransform(temperatureColors); const std::vector& leds = _ledString.leds(); int i = 0; for (ColorRgb& color : ledColors) From 516df4b83a7595a20195ba74597ed4e0c51e0360 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Tue, 22 Dec 2015 10:06:04 +0100 Subject: [PATCH 08/67] Update Hyperion.cpp Former-commit-id: f5cb215d9d6625102530b7f2b1ccce5145ec0768 --- libsrc/hyperion/Hyperion.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index dc6ca3fb..eef3bd7d 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -470,6 +470,10 @@ Hyperion::Hyperion(const Json::Value &jsonConfig) : { throw std::runtime_error("Color correction incorrectly set"); } + if (!_raw2ledTemperature->verifyCorrections()) + { + throw std::runtime_error("Color temperature incorrectly set"); + } if (!_raw2ledTransform->verifyTransforms()) { throw std::runtime_error("Color transformation incorrectly set"); @@ -512,6 +516,9 @@ Hyperion::~Hyperion() // delete the color correction delete _raw2ledCorrection; + + // delete the color temperature correction + delete _raw2ledTemperature; } unsigned Hyperion::getLedCount() const @@ -562,6 +569,11 @@ const std::vector & Hyperion::getCorrectionIds() const return _raw2ledCorrection->getCorrectionIds(); } +const std::vector & Hyperion::getTemperatureIds() const +{ + return _raw2ledTemperature->getCorrectionIds(); +} + ColorTransform * Hyperion::getTransform(const std::string& id) { return _raw2ledTransform->getTransform(id); @@ -572,6 +584,11 @@ ColorCorrection * Hyperion::getCorrection(const std::string& id) return _raw2ledCorrection->getCorrection(id); } +ColorCorrection * Hyperion::getTemperature(const std::string& id) +{ + return _raw2ledTemperature->getCorrection(id); +} + void Hyperion::transformsUpdated() { update(); From aeed93ac838598a086e15189d62890b210a35bc2 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Tue, 22 Dec 2015 10:08:31 +0100 Subject: [PATCH 09/67] Create MultiColorCorrection.h Former-commit-id: 09d90cb6c5fe0479e659028363391d9e5c846e14 --- libsrc/hyperion/MultiColorCorrection.h | 66 ++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 libsrc/hyperion/MultiColorCorrection.h diff --git a/libsrc/hyperion/MultiColorCorrection.h b/libsrc/hyperion/MultiColorCorrection.h new file mode 100644 index 00000000..5f90fb12 --- /dev/null +++ b/libsrc/hyperion/MultiColorCorrection.h @@ -0,0 +1,66 @@ +#pragma once + +// STL includes +#include + +// Utils includes +#include + +// Hyperion includes +#include + +/// +/// The LedColorTransform is responsible for performing color transformation from 'raw' colors +/// received as input to colors mapped to match the color-properties of the leds. +/// +class MultiColorCorrection +{ +public: + MultiColorCorrection(const unsigned ledCnt); + ~MultiColorCorrection(); + + /** + * Adds a new ColorTransform to this MultiColorTransform + * + * @param transform The new ColorTransform (ownership is transfered) + */ + void addCorrection(ColorCorrection * correction); + + void setCorrectionForLed(const std::string& id, const unsigned startLed, const unsigned endLed); + + bool verifyCorrections() const; + + /// + /// Returns the identifier of all the unique ColorTransform + /// + /// @return The list with unique id's of the ColorTransforms + const std::vector & getCorrectionIds(); + + /// + /// Returns the pointer to the ColorTransform with the given id + /// + /// @param id The identifier of the ColorTransform + /// + /// @return The ColorTransform with the given id (or nullptr if it does not exist) + /// + ColorCorrection* getCorrection(const std::string& id); + + /// + /// Performs the color transoformation from raw-color to led-color + /// + /// @param rawColors The list with raw colors + /// + /// @return The list with led-colors + /// + std::vector applyCorrection(const std::vector& rawColors); + +private: + /// List with transform ids + std::vector _correctionIds; + + /// List with unique ColorTransforms + std::vector _correction; + + /// List with a pointer to the ColorTransform for each individual led + std::vector _ledCorrections; +}; From 27c41acdeebbc9eb7cb4be3b15e4acdba80be887 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Tue, 22 Dec 2015 10:08:55 +0100 Subject: [PATCH 10/67] Create MultiColorCorrection.cpp Former-commit-id: 9a69072ba9306024338cfa03691c6705890bcee3 --- libsrc/hyperion/MultiColorCorrection.cpp | 96 ++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 libsrc/hyperion/MultiColorCorrection.cpp diff --git a/libsrc/hyperion/MultiColorCorrection.cpp b/libsrc/hyperion/MultiColorCorrection.cpp new file mode 100644 index 00000000..c104c31b --- /dev/null +++ b/libsrc/hyperion/MultiColorCorrection.cpp @@ -0,0 +1,96 @@ + +// STL includes +#include + +// Hyperion includes +#include "MultiColorCorrection.h" + +MultiColorCorrection::MultiColorCorrection(const unsigned ledCnt) : + _ledCorrections(ledCnt, nullptr) +{ +} + +MultiColorCorrection::~MultiColorCorrection() +{ + // Clean up all the transforms + for (ColorCorrection * correction : _correction) + { + delete correction; + } +} + +void MultiColorCorrection::addCorrection(ColorCorrection * correction) +{ + _correctionIds.push_back(correction->_id); + _correction.push_back(correction); +} + +void MultiColorCorrection::setCorrectionForLed(const std::string& id, const unsigned startLed, const unsigned endLed) +{ + assert(startLed <= endLed); + assert(endLed < _ledCorrections.size()); + + // Get the identified correction (don't care if is nullptr) + ColorCorrection * correction = getCorrection(id); + for (unsigned iLed=startLed; iLed<=endLed; ++iLed) + { + _ledCorrections[iLed] = correction; + } +} + +bool MultiColorCorrection::verifyCorrections() const +{ + bool allLedsSet = true; + for (unsigned iLed=0; iLed<_ledCorrections.size(); ++iLed) + { + if (_ledCorrections[iLed] == nullptr) + { + std::cerr << "No correction set for " << iLed << std::endl; + allLedsSet = false; + } + } + return allLedsSet; +} + +const std::vector & MultiColorCorrection::getCorrectionIds() +{ + return _correctionIds; +} + +ColorCorrection* MultiColorCorrection::getCorrection(const std::string& id) +{ + // Iterate through the unique transforms until we find the one with the given id + for (ColorCorrection * correction : _correction) + { + if (correction->_id == id) + { + return correction; + } + } + + // The ColorTransform was not found + return nullptr; +} + +std::vector MultiColorCorrection::applyCorrection(const std::vector& rawColors) +{ + // Create a copy, as we will do the rest of the transformation in place + std::vector ledColors(rawColors); + + const size_t itCnt = std::min(_ledCorrections.size(), rawColors.size()); + for (size_t i=0; i_rgbCorrection.correctionR(color.red); + color.green = correction->_rgbCorrection.correctionG(color.green); + color.blue = correction->_rgbCorrection.correctionB(color.blue); + } + return ledColors; +} From 257532df74d0842af8fca3cb2122869e8b7eeb71 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Tue, 22 Dec 2015 10:09:47 +0100 Subject: [PATCH 11/67] Update Hyperion.h Former-commit-id: 932b50f14d2d2365d158f21290ddbf95cf7df0af --- include/hyperion/Hyperion.h | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index b6ed0946..142e0523 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -13,6 +13,8 @@ // Hyperion includes #include #include +#include +#include // Effect engine includes #include @@ -22,8 +24,12 @@ class LedDevice; class ColorTransform; class EffectEngine; class HsvTransform; +class HslTransform; class RgbChannelTransform; +class RgbChannelCorrection; class MultiColorTransform; +class MultiColorCorrection; +class MultiColorTemperature; /// /// The main class of Hyperion. This gives other 'users' access to the attached LedDevice through @@ -115,15 +121,30 @@ public slots: /// @return The list with transform identifiers /// const std::vector & getTransformIds() const; + + /// + /// Returns the list with unique transform identifiers + /// @return The list with correction identifiers + /// + const std::vector & getCorrectionIds() const; /// /// Returns the ColorTransform with the given identifier /// @return The transform with the given identifier (or nullptr if the identifier does not exist) /// ColorTransform * getTransform(const std::string& id); + + /// + /// Returns the ColorTransform with the given identifier + /// @return The transform with the given identifier (or nullptr if the identifier does not exist) + /// + ColorCorrection * getCorrection(const std::string& id); /// Tell Hyperion that the transforms have changed and the leds need to be updated void transformsUpdated(); + + /// Tell Hyperion that the corrections have changed and the leds need to be updated + void correctionsUpdated(); /// /// Clears the given priority channel. This will switch the led-colors to the colors of the next @@ -163,9 +184,14 @@ public: static LedString createLedString(const Json::Value & ledsConfig, const ColorOrder deviceOrder); static MultiColorTransform * createLedColorsTransform(const unsigned ledCnt, const Json::Value & colorTransformConfig); + static MultiColorCorrection * createLedColorsCorrection(const unsigned ledCnt, const Json::Value & colorCorrectionConfig); + static MultiColorCorrection * createLedColorsTemperature(const unsigned ledCnt, const Json::Value & colorTemperatureConfig); static ColorTransform * createColorTransform(const Json::Value & transformConfig); + static ColorCorrection * createColorCorrection(const Json::Value & correctionConfig); static HsvTransform * createHsvTransform(const Json::Value & hsvConfig); + static HslTransform * createHslTransform(const Json::Value & hslConfig); static RgbChannelTransform * createRgbChannelTransform(const Json::Value& colorConfig); + static RgbChannelCorrection * createRgbChannelCorrection(const Json::Value& colorConfig); static LedDevice * createColorSmoothing(const Json::Value & smoothingConfig, LedDevice * ledDevice); @@ -192,9 +218,15 @@ private: /// The priority muxer PriorityMuxer _muxer; - /// The transformation from raw colors to led colors + /// The transformation from corrected colors to led colors MultiColorTransform * _raw2ledTransform; - + + /// The correction from raw colors to led colors + MultiColorCorrection * _raw2ledCorrection; + + /// The temperature from corrected colors to led colors + MultiColorCorrection * _raw2ledTemperature; + /// The actual LedDevice LedDevice * _device; From 0ba143cd2078fc8cbba460bbe42f8fcfe9cb6edb Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Tue, 22 Dec 2015 10:12:34 +0100 Subject: [PATCH 12/67] Update MultiColorCorrection.h Former-commit-id: 82dee880f9614e813758b2d5c7e08c3a33aa6d4d --- libsrc/hyperion/MultiColorCorrection.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libsrc/hyperion/MultiColorCorrection.h b/libsrc/hyperion/MultiColorCorrection.h index 5f90fb12..cdefce17 100644 --- a/libsrc/hyperion/MultiColorCorrection.h +++ b/libsrc/hyperion/MultiColorCorrection.h @@ -10,7 +10,7 @@ #include /// -/// The LedColorTransform is responsible for performing color transformation from 'raw' colors +/// The LedColorCorrection is responsible for performing color correction from 'raw' colors /// received as input to colors mapped to match the color-properties of the leds. /// class MultiColorCorrection @@ -20,9 +20,9 @@ public: ~MultiColorCorrection(); /** - * Adds a new ColorTransform to this MultiColorTransform + * Adds a new ColorCorrection to this MultiColorCorrection * - * @param transform The new ColorTransform (ownership is transfered) + * @param Correction The new ColorCorrection (ownership is transfered) */ void addCorrection(ColorCorrection * correction); @@ -31,17 +31,17 @@ public: bool verifyCorrections() const; /// - /// Returns the identifier of all the unique ColorTransform + /// Returns the identifier of all the unique ColorCorrection /// - /// @return The list with unique id's of the ColorTransforms + /// @return The list with unique id's of the ColorCorrections const std::vector & getCorrectionIds(); /// - /// Returns the pointer to the ColorTransform with the given id + /// Returns the pointer to the ColorCorrection with the given id /// - /// @param id The identifier of the ColorTransform + /// @param id The identifier of the ColorCorrection /// - /// @return The ColorTransform with the given id (or nullptr if it does not exist) + /// @return The ColorCorrection with the given id (or nullptr if it does not exist) /// ColorCorrection* getCorrection(const std::string& id); @@ -55,12 +55,12 @@ public: std::vector applyCorrection(const std::vector& rawColors); private: - /// List with transform ids + /// List with Correction ids std::vector _correctionIds; - /// List with unique ColorTransforms + /// List with unique ColorCorrections std::vector _correction; - /// List with a pointer to the ColorTransform for each individual led + /// List with a pointer to the ColorCorrection for each individual led std::vector _ledCorrections; }; From 5215e45f1088c1a9e46609c73a2aea7e428e1973 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Tue, 22 Dec 2015 10:13:01 +0100 Subject: [PATCH 13/67] Update MultiColorCorrection.cpp Former-commit-id: ec17038daea5061bf4910a4884d715e767604155 --- libsrc/hyperion/MultiColorCorrection.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libsrc/hyperion/MultiColorCorrection.cpp b/libsrc/hyperion/MultiColorCorrection.cpp index c104c31b..6388d27e 100644 --- a/libsrc/hyperion/MultiColorCorrection.cpp +++ b/libsrc/hyperion/MultiColorCorrection.cpp @@ -12,7 +12,7 @@ MultiColorCorrection::MultiColorCorrection(const unsigned ledCnt) : MultiColorCorrection::~MultiColorCorrection() { - // Clean up all the transforms + // Clean up all the correctinos for (ColorCorrection * correction : _correction) { delete correction; @@ -59,7 +59,7 @@ const std::vector & MultiColorCorrection::getCorrectionIds() ColorCorrection* MultiColorCorrection::getCorrection(const std::string& id) { - // Iterate through the unique transforms until we find the one with the given id + // Iterate through the unique corrections until we find the one with the given id for (ColorCorrection * correction : _correction) { if (correction->_id == id) @@ -68,13 +68,13 @@ ColorCorrection* MultiColorCorrection::getCorrection(const std::string& id) } } - // The ColorTransform was not found + // The ColorCorrection was not found return nullptr; } std::vector MultiColorCorrection::applyCorrection(const std::vector& rawColors) { - // Create a copy, as we will do the rest of the transformation in place + // Create a copy, as we will do the rest of the correction in place std::vector ledColors(rawColors); const size_t itCnt = std::min(_ledCorrections.size(), rawColors.size()); @@ -83,7 +83,7 @@ std::vector MultiColorCorrection::applyCorrection(const std::vector Date: Wed, 9 Mar 2016 19:36:08 +0100 Subject: [PATCH 14/67] Update Hyperion.h Former-commit-id: 2497c6ea7d153e01e49ed0683e92837106628d44 --- include/hyperion/Hyperion.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index 142e0523..516efc2d 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -15,6 +15,7 @@ #include #include #include +#include // Effect engine includes #include From 1fa54a1cee07426b370f7e81eefc772201807a59 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Wed, 9 Mar 2016 19:42:18 +0100 Subject: [PATCH 15/67] Update CMakeLists.txt Former-commit-id: 5182f0e28c8914a970db7c4c0d9fee68d7481e65 --- libsrc/hyperion/CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libsrc/hyperion/CMakeLists.txt b/libsrc/hyperion/CMakeLists.txt index f671fea5..68039881 100644 --- a/libsrc/hyperion/CMakeLists.txt +++ b/libsrc/hyperion/CMakeLists.txt @@ -19,6 +19,7 @@ SET(Hyperion_HEADERS ${CURRENT_SOURCE_DIR}/MultiColorTransform.h ${CURRENT_SOURCE_DIR}/MultiColorCorrection.h + ${CURRENT_HEADER_DIR}/MessageForwarder.h ) SET(Hyperion_SOURCES @@ -38,9 +39,13 @@ set(Hyperion_RESOURCES ${CURRENT_SOURCE_DIR}/resource.qrc ) +if(ENABLE_QT5) +QT5_WRAP_CPP(Hyperion_HEADERS_MOC ${Hyperion_QT_HEADERS}) +QT5_ADD_RESOURCES(Hyperion_RESOURCES_RCC ${Hyperion_RESOURCES} OPTIONS "-no-compress") +else(ENABLE_QT5) QT4_WRAP_CPP(Hyperion_HEADERS_MOC ${Hyperion_QT_HEADERS}) - QT4_ADD_RESOURCES(Hyperion_RESOURCES_RCC ${Hyperion_RESOURCES} OPTIONS "-no-compress") +endif(ENABLE_QT5) add_library(hyperion ${Hyperion_HEADERS} @@ -50,6 +55,10 @@ add_library(hyperion ${Hyperion_RESOURCES_RCC} ) +if(ENABLE_QT5) +qt5_use_modules(hyperion Widgets) +endif(ENABLE_QT5) + target_link_libraries(hyperion blackborder hyperion-utils From 88e4737b8b47f31a0bc429796dcb87f40eb3a0e2 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Wed, 9 Mar 2016 19:42:54 +0100 Subject: [PATCH 16/67] Update CMakeLists.txt Former-commit-id: 8afa5615ac8ff62ac6492083f2d2c487cf305dbc --- libsrc/hyperion/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/libsrc/hyperion/CMakeLists.txt b/libsrc/hyperion/CMakeLists.txt index 68039881..a2188127 100644 --- a/libsrc/hyperion/CMakeLists.txt +++ b/libsrc/hyperion/CMakeLists.txt @@ -33,6 +33,7 @@ SET(Hyperion_SOURCES ${CURRENT_SOURCE_DIR}/MultiColorTransform.cpp ${CURRENT_SOURCE_DIR}/MultiColorCorrection.cpp ${CURRENT_SOURCE_DIR}/LinearColorSmoothing.cpp + ${CURRENT_SOURCE_DIR}/MessageForwarder.cpp ) set(Hyperion_RESOURCES From 63e3380ff7574ad7b39401641a50b6736bad3c55 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Wed, 9 Mar 2016 19:45:00 +0100 Subject: [PATCH 17/67] Update Hyperion.cpp Former-commit-id: 24638e6009da0dc3a2168caef53e09664c1db095 --- libsrc/hyperion/Hyperion.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index eef3bd7d..29ee24a3 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -455,6 +455,37 @@ LedDevice * Hyperion::createColorSmoothing(const Json::Value & smoothingConfig, return ledDevice; } +MessageForwarder * Hyperion::createMessageForwarder(const Json::Value & forwarderConfig) +{ + MessageForwarder * forwarder = new MessageForwarder(); + if ( ! forwarderConfig.isNull() ) + { + if ( ! forwarderConfig["json"].isNull() && forwarderConfig["json"].isArray() ) + { + for (const Json::Value& addr : forwarderConfig["json"]) + { + std::cout << "Json forward to " << addr.asString() << std::endl; + forwarder->addJsonSlave(addr.asString()); + } + } + + if ( ! forwarderConfig["proto"].isNull() && forwarderConfig["proto"].isArray() ) + { + for (const Json::Value& addr : forwarderConfig["proto"]) + { + std::cout << "Proto forward to " << addr.asString() << std::endl; + forwarder->addProtoSlave(addr.asString()); + } + } + } + + return forwarder; +} + +MessageForwarder * Hyperion::getForwarder() +{ + return _messageForwarder; +} Hyperion::Hyperion(const Json::Value &jsonConfig) : _ledString(createLedString(jsonConfig["leds"], createColorOrder(jsonConfig["device"]))), @@ -519,6 +550,9 @@ Hyperion::~Hyperion() // delete the color temperature correction delete _raw2ledTemperature; + + // delete the message forwarder + delete _messageForwarder; } unsigned Hyperion::getLedCount() const From bcb080254251193ec877b216e5bd10d5aab94d6b Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Wed, 9 Mar 2016 19:55:55 +0100 Subject: [PATCH 18/67] Update Hyperion.h Former-commit-id: 877c98ea4c6f5503fda14914e315c2b9eb301a44 --- include/hyperion/Hyperion.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index 516efc2d..a8691953 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -140,6 +140,12 @@ public slots: /// @return The transform with the given identifier (or nullptr if the identifier does not exist) /// ColorCorrection * getCorrection(const std::string& id); + + /// + /// Returns MessageForwarder Object + /// @return instance of message forwarder object + /// + MessageForwarder * getForwarder(); /// Tell Hyperion that the transforms have changed and the leds need to be updated void transformsUpdated(); @@ -195,6 +201,7 @@ public: static RgbChannelCorrection * createRgbChannelCorrection(const Json::Value& colorConfig); static LedDevice * createColorSmoothing(const Json::Value & smoothingConfig, LedDevice * ledDevice); + static MessageForwarder * createMessageForwarder(const Json::Value & forwarderConfig); signals: /// Signal which is emitted when a priority channel is actively cleared @@ -233,6 +240,9 @@ private: /// Effect engine EffectEngine * _effectEngine; + + //protoo and json Message forwarder + MessageForwarder * _messageForwarder; /// The timer for handling priority channel timeouts QTimer _timer; From 90b9acf68e16f9982b9bef41fb4a14a28e7a8d3b Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Wed, 9 Mar 2016 19:57:03 +0100 Subject: [PATCH 19/67] Update Hyperion.cpp Former-commit-id: 4c3f0a561d7def20dd713add0d437bdf12431e0b --- libsrc/hyperion/Hyperion.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index 29ee24a3..79300f0c 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -495,6 +495,7 @@ Hyperion::Hyperion(const Json::Value &jsonConfig) : _raw2ledTransform(createLedColorsTransform(_ledString.leds().size(), jsonConfig["color"])), _device(LedDeviceFactory::construct(jsonConfig["device"])), _effectEngine(nullptr), + _messageForwarder(createMessageForwarder(jsonConfig["forwarder"])), _timer() { if (!_raw2ledCorrection->verifyCorrections()) @@ -512,8 +513,8 @@ Hyperion::Hyperion(const Json::Value &jsonConfig) : // initialize the image processor factory ImageProcessorFactory::getInstance().init( _ledString, - jsonConfig["blackborderdetector"].get("enable", true).asBool(), - jsonConfig["blackborderdetector"].get("threshold", 0.01).asDouble()); + jsonConfig["blackborderdetector"] + ); // initialize the color smoothing filter _device = createColorSmoothing(jsonConfig["color"]["smoothing"], _device); From 8b2603391545e564b10351f53b6dbea73663978f Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Wed, 9 Mar 2016 19:58:49 +0100 Subject: [PATCH 20/67] Update Hyperion.h Former-commit-id: 9e4ab548db0f2805386d90bfe9cde3aa9426aab5 --- include/hyperion/Hyperion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index a8691953..8ffc7fe5 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -241,7 +241,7 @@ private: /// Effect engine EffectEngine * _effectEngine; - //protoo and json Message forwarder + // proto and json Message forwarder MessageForwarder * _messageForwarder; /// The timer for handling priority channel timeouts From 49e867f5fc9ad6ab9eb879127924fecd08379df9 Mon Sep 17 00:00:00 2001 From: redpanther Date: Thu, 10 Mar 2016 06:53:21 +0100 Subject: [PATCH 21/67] add an auto generated version id Former-commit-id: df3ad6b08e24e73d957611e8be45e7e8cc717b8c --- CMakeLists.txt | 37 +++++++++++++++++++++---------------- HyperionConfig.h.in | 1 + cmake/FindGitVersion.cmake | 9 +++++++++ src/hyperiond/hyperiond.cpp | 2 +- 4 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 cmake/FindGitVersion.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c8e077a..7b52f7c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,25 +56,30 @@ if(ENABLE_OSX AND ENABLE_DISPMANX) message(FATAL_ERROR "dispmanx grabber and osx grabber cannot be used at the same time") endif(ENABLE_OSX AND ENABLE_DISPMANX) + + #if(ENABLE_QT5) # TODO vs ENABLE_QT4? #endif(ENABLE_QT5) # Createt the configuration file + +# Add project specific cmake modules (find, etc) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + +find_package(GitVersion) + # configure a header file to pass some of the CMake settings # to the source code configure_file("${PROJECT_SOURCE_DIR}/HyperionConfig.h.in" "${PROJECT_BINARY_DIR}/HyperionConfig.h") include_directories("${PROJECT_BINARY_DIR}") -# Add project specific cmake modules (find, etc) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) - if(ENABLE_QT5) -ADD_DEFINITIONS ( -DENABLE_QT5 ) -#find_package(Qt5Widgets) + ADD_DEFINITIONS ( -DENABLE_QT5 ) + #find_package(Qt5Widgets) else(ENABLE_QT5) -# Add specific cmake modules to find qt4 (default version finds first available QT which might not be qt4) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/qt4) + # Add specific cmake modules to find qt4 (default version finds first available QT which might not be qt4) + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/qt4) endif(ENABLE_QT5) # Define the global output path of binaries @@ -97,23 +102,23 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall") if(ENABLE_QT5) #find_package(Qt5Core REQUIRED) -find_package(Qt5 COMPONENTS Core Gui Widgets Network REQUIRED) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") -# set(CMAKE_CXX_FLAGS "-fPIC") + find_package(Qt5 COMPONENTS Core Gui Widgets Network REQUIRED) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") +# set(CMAKE_CXX_FLAGS "-fPIC") else(ENABLE_QT5) -# Configure the use of QT4 -find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork REQUIRED QUIET) + # Configure the use of QT4 + find_package(Qt4 COMPONENTS QtCore QtNetwork QtGui REQUIRED QUIET) endif(ENABLE_QT5) #add libusb and pthreads find_package(libusb-1.0 REQUIRED) find_package(Threads REQUIRED) if(ENABLE_QT5) -#include(${QT_USE_FILE}) -add_definitions(${QT_DEFINITIONS}) + #include(${QT_USE_FILE}) + add_definitions(${QT_DEFINITIONS}) else(ENABLE_QT5) -include(${QT_USE_FILE}) -add_definitions(${QT_DEFINITIONS}) + include(${QT_USE_FILE}) + add_definitions(${QT_DEFINITIONS}) endif(ENABLE_QT5) # TODO[TvdZ]: This linking directory should only be added if we are cross compiling diff --git a/HyperionConfig.h.in b/HyperionConfig.h.in index f5bd3ce1..f41b8078 100644 --- a/HyperionConfig.h.in +++ b/HyperionConfig.h.in @@ -27,3 +27,4 @@ // Define to enable the osx grabber #cmakedefine ENABLE_OSX +#define HYPERION_VERSION_ID "${HYPERION_VERSION_ID}" \ No newline at end of file diff --git a/cmake/FindGitVersion.cmake b/cmake/FindGitVersion.cmake new file mode 100644 index 00000000..3ce5fe93 --- /dev/null +++ b/cmake/FindGitVersion.cmake @@ -0,0 +1,9 @@ + +execute_process( COMMAND git log -1 --format=%cn-%t/%h-%ct WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE BUILD_ID ERROR_QUIET ) +execute_process( COMMAND sh -c "git branch | grep '^*' | sed 's;^*;;g' " WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE VERSION_ID ERROR_QUIET ) + +STRING ( STRIP "${BUILD_ID}" BUILD_ID ) +STRING ( STRIP "${VERSION_ID}" VERSION_ID ) +SET ( HYPERION_VERSION_ID "${VERSION_ID} (${BUILD_ID}" ) +message ( STATUS "Current Version: ${HYPERION_VERSION_ID})" ) + diff --git a/src/hyperiond/hyperiond.cpp b/src/hyperiond/hyperiond.cpp index 8af26879..be85a4b5 100644 --- a/src/hyperiond/hyperiond.cpp +++ b/src/hyperiond/hyperiond.cpp @@ -96,7 +96,7 @@ int main(int argc, char** argv) // Initialising QCoreApplication QCoreApplication app(argc, argv); - std::cout << "QCoreApplication initialised" << std::endl; + std::cout << "Hyperion initialised, Version: " << HYPERION_VERSION_ID << std::endl; signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); From 266f0e6694a27417d6361c7807d1505fff3e5f5d Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Thu, 10 Mar 2016 07:57:47 +0100 Subject: [PATCH 22/67] Update .gitignore Former-commit-id: b33283298729bdca7c78d855964c3126735fd57b --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index 7f9c9c20..3c242a4c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ /*.user /build* .DS_Store - -libsrc/hyperion/ImageProcessor.cpp -libsrc/hyperion/CMakeLists.txt From 9f273410a15ab0743d3bd22907964aae72d4c230 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Thu, 10 Mar 2016 07:58:30 +0100 Subject: [PATCH 23/67] Update .gitignore Former-commit-id: 416ddb32c74a723acc019283ab3330f88666a1e9 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3c242a4c..91a498c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /*.user /build* .DS_Store + From 153d1f0999030e7a1eaefcf5a8c4c7d8702086bd Mon Sep 17 00:00:00 2001 From: redpanther Date: Thu, 10 Mar 2016 12:01:10 +0100 Subject: [PATCH 24/67] print version for every standalone grabber and hyperiond Former-commit-id: 736894a87ba3d056a8e4f1def236ae4670f16407 --- src/hyperion-aml/hyperion-aml.cpp | 8 ++++++++ src/hyperion-dispmanx/hyperion-dispmanx.cpp | 7 +++++++ src/hyperion-remote/hyperion-remote.cpp | 8 ++++++++ src/hyperion-v4l2/hyperion-v4l2.cpp | 7 +++++++ src/hyperion-x11/hyperion-x11.cpp | 6 ++++++ src/hyperiond/hyperiond.cpp | 6 ++++-- 6 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/hyperion-aml/hyperion-aml.cpp b/src/hyperion-aml/hyperion-aml.cpp index cca5e688..b8ab1ff6 100644 --- a/src/hyperion-aml/hyperion-aml.cpp +++ b/src/hyperion-aml/hyperion-aml.cpp @@ -10,6 +10,9 @@ #include #include "AmlogicWrapper.h" +#include "HyperionConfig.h" + + using namespace vlofgren; // save the image as screenshot @@ -22,6 +25,11 @@ void saveScreenshot(const char * filename, const Image & image) int main(int argc, char ** argv) { + std::cout + << "hyperion-aml:" << std::endl + << "\tversion : " << HYPERION_VERSION_ID << std::endl + << "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl; + QCoreApplication app(argc, argv); try diff --git a/src/hyperion-dispmanx/hyperion-dispmanx.cpp b/src/hyperion-dispmanx/hyperion-dispmanx.cpp index abf78c8c..ed86f1dd 100644 --- a/src/hyperion-dispmanx/hyperion-dispmanx.cpp +++ b/src/hyperion-dispmanx/hyperion-dispmanx.cpp @@ -9,6 +9,8 @@ #include #include "DispmanxWrapper.h" +#include "HyperionConfig.h" + using namespace vlofgren; // save the image as screenshot @@ -21,6 +23,11 @@ void saveScreenshot(const char * filename, const Image & image) int main(int argc, char ** argv) { + std::cout + << "hyperion-dispmanx:" << std::endl + << "\tversion : " << HYPERION_VERSION_ID << std::endl + << "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl; + QCoreApplication app(argc, argv); try diff --git a/src/hyperion-remote/hyperion-remote.cpp b/src/hyperion-remote/hyperion-remote.cpp index 3636721f..42df87e9 100644 --- a/src/hyperion-remote/hyperion-remote.cpp +++ b/src/hyperion-remote/hyperion-remote.cpp @@ -13,6 +13,9 @@ #include "CustomParameter.h" #include "JsonConnection.h" +#include "HyperionConfig.h" + + using namespace vlofgren; /// Count the number of true values in a list of booleans @@ -28,6 +31,11 @@ int count(std::initializer_list values) int main(int argc, char * argv[]) { + std::cout + << "hyperion-remote:" << std::endl + << "\tversion : " << HYPERION_VERSION_ID << std::endl + << "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl; + QCoreApplication app(argc, argv); // force the locale diff --git a/src/hyperion-v4l2/hyperion-v4l2.cpp b/src/hyperion-v4l2/hyperion-v4l2.cpp index fe011f6d..2bb94018 100644 --- a/src/hyperion-v4l2/hyperion-v4l2.cpp +++ b/src/hyperion-v4l2/hyperion-v4l2.cpp @@ -24,6 +24,8 @@ #include "PixelFormatParameter.h" #include "ScreenshotHandler.h" +#include "HyperionConfig.h" + using namespace vlofgren; // save the image as screenshot @@ -36,6 +38,11 @@ void saveScreenshot(void *, const Image & image) int main(int argc, char** argv) { + std::cout + << "hyperion-v4l2:" << std::endl + << "\tversion : " << HYPERION_VERSION_ID << std::endl + << "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl; + QCoreApplication app(argc, argv); // force the locale diff --git a/src/hyperion-x11/hyperion-x11.cpp b/src/hyperion-x11/hyperion-x11.cpp index 7815aa34..31d5ab55 100644 --- a/src/hyperion-x11/hyperion-x11.cpp +++ b/src/hyperion-x11/hyperion-x11.cpp @@ -8,6 +8,7 @@ #include "protoserver/ProtoConnectionWrapper.h" #include "X11Wrapper.h" +#include "HyperionConfig.h" using namespace vlofgren; @@ -21,6 +22,11 @@ void saveScreenshot(const char * filename, const Image & image) int main(int argc, char ** argv) { + std::cout + << "hyperion-x11:" << std::endl + << "\tversion : " << HYPERION_VERSION_ID << std::endl + << "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl; + QCoreApplication app(argc, argv); try diff --git a/src/hyperiond/hyperiond.cpp b/src/hyperiond/hyperiond.cpp index be85a4b5..bc962464 100644 --- a/src/hyperiond/hyperiond.cpp +++ b/src/hyperiond/hyperiond.cpp @@ -92,11 +92,13 @@ Json::Value loadConfig(const std::string & configFile) int main(int argc, char** argv) { - std::cout << "Application build time: " << __DATE__ << " " << __TIME__ << std::endl; + std::cout + << "Hyperiond:" << std::endl + << "\tversion : " << HYPERION_VERSION_ID << std::endl + << "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl; // Initialising QCoreApplication QCoreApplication app(argc, argv); - std::cout << "Hyperion initialised, Version: " << HYPERION_VERSION_ID << std::endl; signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); From 12b406dd4bede99af8301be8dd17fd9f8685ae75 Mon Sep 17 00:00:00 2001 From: redpanther Date: Thu, 10 Mar 2016 12:06:03 +0100 Subject: [PATCH 25/67] make compile of tests optional and disabled by default Former-commit-id: dc05b637391ec5b7e79d66d94724828e8dbd2653 --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b52f7c2..04f54483 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,9 @@ message(STATUS "ENABLE_X11 = " ${ENABLE_X11}) option(ENABLE_QT5 "Enable QT5" OFF) message(STATUS "ENABLE_QT5 = " ${ENABLE_QT5}) +option(ENABLE_TESTS "Compile additional test applications" OFF) +message(STATUS "ENABLE_TESTS = " ${ENABLE_TESTS}) + if(ENABLE_V4L2 AND NOT ENABLE_PROTOBUF) message(FATAL_ERROR "V4L2 grabber requires PROTOBUF. Disable V4L2 or enable PROTOBUF") endif(ENABLE_V4L2 AND NOT ENABLE_PROTOBUF) @@ -57,7 +60,6 @@ if(ENABLE_OSX AND ENABLE_DISPMANX) endif(ENABLE_OSX AND ENABLE_DISPMANX) - #if(ENABLE_QT5) # TODO vs ENABLE_QT4? #endif(ENABLE_QT5) @@ -138,7 +140,10 @@ configure_file(config/hyperion_x86.config.json ${LIBRARY_OUTPUT_PATH} @ONLY) add_subdirectory(dependencies) add_subdirectory(libsrc) add_subdirectory(src) -add_subdirectory(test) +if (ENABLE_TESTS) + add_subdirectory(test) +endif (ENABLE_TESTS) + # Add the doxygen generation directory add_subdirectory(doc) From e01bcd708dd220c2b0d08398c59b8c51f74f2959 Mon Sep 17 00:00:00 2001 From: redpanther Date: Thu, 10 Mar 2016 12:22:44 +0100 Subject: [PATCH 26/67] add install commands instead of "make" use "make install/strip" release compile Former-commit-id: f4dd2d9e1a4d815b667665892a3bd9cec64218a3 --- CMakeLists.txt | 3 + src/hyperion-aml/CMakeLists.txt | 9 ++- src/hyperion-dispmanx/CMakeLists.txt | 3 + src/hyperion-remote/CMakeLists.txt | 84 ++++++++++++++-------------- src/hyperion-v4l2/CMakeLists.txt | 3 + src/hyperion-x11/CMakeLists.txt | 2 + src/hyperiond/CMakeLists.txt | 2 + 7 files changed, 62 insertions(+), 44 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04f54483..d8237edd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,9 @@ if(ENABLE_OSX AND ENABLE_DISPMANX) endif(ENABLE_OSX AND ENABLE_DISPMANX) +SET ( PROTOBUF_INSTALL_BIN_DIR ${CMAKE_SOURCE_DIR}/deploy ) +SET ( PROTOBUF_INSTALL_LIB_DIR ${CMAKE_SOURCE_DIR}/deploy ) + #if(ENABLE_QT5) # TODO vs ENABLE_QT4? #endif(ENABLE_QT5) diff --git a/src/hyperion-aml/CMakeLists.txt b/src/hyperion-aml/CMakeLists.txt index cd27c046..e7e7bdff 100644 --- a/src/hyperion-aml/CMakeLists.txt +++ b/src/hyperion-aml/CMakeLists.txt @@ -31,13 +31,13 @@ else(ENABLE_QT5) QT4_WRAP_CPP(Hyperion_AML_HEADERS_MOC ${Hyperion_AML_QT_HEADERS}) endif(ENABLE_QT5) -add_executable(hyperion-amlogic +add_executable(${PROJECT_NAME} ${Hyperion_AML_HEADERS} ${Hyperion_AML_SOURCES} ${Hyperion_AML_HEADERS_MOC} ) -target_link_libraries(hyperion-amlogic +target_link_libraries(${PROJECT_NAME} getoptPlusPlus blackborder hyperion-utils @@ -46,7 +46,10 @@ target_link_libraries(hyperion-amlogic pthread ) -qt4_use_modules(hyperion-amlogic +qt4_use_modules(${PROJECT_NAME} Core Gui Network) + +install ( TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_SOURCE_DIR}/deploy/bin" ) + diff --git a/src/hyperion-dispmanx/CMakeLists.txt b/src/hyperion-dispmanx/CMakeLists.txt index 130cb661..3263589f 100644 --- a/src/hyperion-dispmanx/CMakeLists.txt +++ b/src/hyperion-dispmanx/CMakeLists.txt @@ -63,3 +63,6 @@ else(ENABLE_QT5) Network ) endif(ENABLE_QT5) + + +install ( TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_SOURCE_DIR}/deploy/bin" ) diff --git a/src/hyperion-remote/CMakeLists.txt b/src/hyperion-remote/CMakeLists.txt index b8c73a59..c2bfdcff 100644 --- a/src/hyperion-remote/CMakeLists.txt +++ b/src/hyperion-remote/CMakeLists.txt @@ -1,41 +1,43 @@ -cmake_minimum_required(VERSION 2.8) - -project(hyperion-remote) - -# find Qt4 -if(ENABLE_QT5) -find_package(Qt5 COMPONENTS Core Gui Widgets Network REQUIRED) -# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") -# set(CMAKE_CXX_FLAGS "-fPIC") -else(ENABLE_QT5) -find_package(Qt4 REQUIRED QtCore QtGui QtNetwork) -endif(ENABLE_QT5) - -# The following I do not undrstand completely... -# libQtCore.so uses some hardcoded library path inside which are incorrect after copying the file RPi file system -# Therefor, an extra path is needed on which to find the required libraries -LINK_DIRECTORIES(${LINK_DIRECTORIES} ${CMAKE_FIND_ROOT_PATH}/lib/arm-linux-gnueabihf) - -include_directories(${QT_INCLUDES}) - -set(hyperion-remote_HEADERS - CustomParameter.h - JsonConnection.h - ColorTransformValues.h) - -set(hyperion-remote_SOURCES - hyperion-remote.cpp - JsonConnection.cpp) - -add_executable(hyperion-remote - ${hyperion-remote_HEADERS} - ${hyperion-remote_SOURCES}) - -if(ENABLE_QT5) -qt5_use_modules(hyperion-remote Widgets Network) -endif(ENABLE_QT5) - -target_link_libraries(hyperion-remote - jsoncpp - getoptPlusPlus - ${QT_LIBRARIES}) +cmake_minimum_required(VERSION 2.8) + +project(hyperion-remote) + +# find Qt4 +if(ENABLE_QT5) +find_package(Qt5 COMPONENTS Core Gui Widgets Network REQUIRED) +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") +# set(CMAKE_CXX_FLAGS "-fPIC") +else(ENABLE_QT5) +find_package(Qt4 REQUIRED QtCore QtGui QtNetwork) +endif(ENABLE_QT5) + +# The following I do not undrstand completely... +# libQtCore.so uses some hardcoded library path inside which are incorrect after copying the file RPi file system +# Therefor, an extra path is needed on which to find the required libraries +LINK_DIRECTORIES(${LINK_DIRECTORIES} ${CMAKE_FIND_ROOT_PATH}/lib/arm-linux-gnueabihf) + +include_directories(${QT_INCLUDES}) + +set(hyperion-remote_HEADERS + CustomParameter.h + JsonConnection.h + ColorTransformValues.h) + +set(hyperion-remote_SOURCES + hyperion-remote.cpp + JsonConnection.cpp) + +add_executable(hyperion-remote + ${hyperion-remote_HEADERS} + ${hyperion-remote_SOURCES}) + +if(ENABLE_QT5) +qt5_use_modules(hyperion-remote Widgets Network) +endif(ENABLE_QT5) + +target_link_libraries(hyperion-remote + jsoncpp + getoptPlusPlus + ${QT_LIBRARIES}) + +install ( TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_SOURCE_DIR}/deploy/bin" ) diff --git a/src/hyperion-v4l2/CMakeLists.txt b/src/hyperion-v4l2/CMakeLists.txt index ef051e2d..173e7fd2 100644 --- a/src/hyperion-v4l2/CMakeLists.txt +++ b/src/hyperion-v4l2/CMakeLists.txt @@ -53,3 +53,6 @@ target_link_libraries(hyperion-v4l2 pthread ${QT_LIBRARIES} ) + +install ( TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_SOURCE_DIR}/deploy/bin" ) + diff --git a/src/hyperion-x11/CMakeLists.txt b/src/hyperion-x11/CMakeLists.txt index 626781f9..a6f9c513 100644 --- a/src/hyperion-x11/CMakeLists.txt +++ b/src/hyperion-x11/CMakeLists.txt @@ -62,3 +62,5 @@ qt4_use_modules(hyperion-x11 Gui Network) endif(ENABLE_QT5) + +install ( TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_SOURCE_DIR}/deploy/bin" ) diff --git a/src/hyperiond/CMakeLists.txt b/src/hyperiond/CMakeLists.txt index 70c2381b..5aef74d2 100644 --- a/src/hyperiond/CMakeLists.txt +++ b/src/hyperiond/CMakeLists.txt @@ -33,3 +33,5 @@ endif (ENABLE_AMLOGIC) if (ENABLE_PROTOBUF) target_link_libraries(hyperiond protoserver) endif (ENABLE_PROTOBUF) + +install ( TARGETS hyperiond DESTINATION "${CMAKE_SOURCE_DIR}/deploy/bin" ) From e84841178549a6999cdc2e3ebefa8a4bc454e210 Mon Sep 17 00:00:00 2001 From: redpanther Date: Thu, 10 Mar 2016 17:11:02 +0100 Subject: [PATCH 27/67] install proto to binary dir Former-commit-id: aaac3a7094442b0bfc51a572fcfa6f7cc59b81a2 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d8237edd..a47771a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,8 +60,8 @@ if(ENABLE_OSX AND ENABLE_DISPMANX) endif(ENABLE_OSX AND ENABLE_DISPMANX) -SET ( PROTOBUF_INSTALL_BIN_DIR ${CMAKE_SOURCE_DIR}/deploy ) -SET ( PROTOBUF_INSTALL_LIB_DIR ${CMAKE_SOURCE_DIR}/deploy ) +SET ( PROTOBUF_INSTALL_BIN_DIR ${CMAKE_BINARY_DIR}/proto ) +SET ( PROTOBUF_INSTALL_LIB_DIR ${CMAKE_BINARY_DIR}/proto ) #if(ENABLE_QT5) # TODO vs ENABLE_QT4? From 9e13303a4ae7a1ae5bed49143255a14cca40e807 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Thu, 10 Mar 2016 17:27:25 +0100 Subject: [PATCH 28/67] Added files via upload Former-commit-id: 55b74524b06af6f5c443053a56216c0db465fb2f --- libsrc/utils/HslTransform.cpp | 158 ++++++++++++++++++++++++++ libsrc/utils/RgbChannelCorrection.cpp | 120 +++++++++++++++++++ 2 files changed, 278 insertions(+) create mode 100644 libsrc/utils/HslTransform.cpp create mode 100644 libsrc/utils/RgbChannelCorrection.cpp diff --git a/libsrc/utils/HslTransform.cpp b/libsrc/utils/HslTransform.cpp new file mode 100644 index 00000000..09056bb2 --- /dev/null +++ b/libsrc/utils/HslTransform.cpp @@ -0,0 +1,158 @@ +#include +#include +#include + +HslTransform::HslTransform() : + _saturationGain(1.0), + _luminanceGain(1.0) +{ +} + +HslTransform::HslTransform(double saturationGain, double luminanceGain) : + _saturationGain(saturationGain), + _luminanceGain(luminanceGain) +{ +} + +HslTransform::~HslTransform() +{ +} + +void HslTransform::setSaturationGain(double saturationGain) +{ + _saturationGain = saturationGain; +} + +double HslTransform::getSaturationGain() const +{ + return _saturationGain; +} + +void HslTransform::setLuminanceGain(double luminanceGain) +{ + _luminanceGain = luminanceGain; +} + +double HslTransform::getLuminanceGain() const +{ + return _luminanceGain; +} + +void HslTransform::transform(uint8_t & red, uint8_t & green, uint8_t & blue) const +{ + if (_saturationGain != 1.0 || _luminanceGain != 1.0) + { + uint16_t hue; + float saturation, luminance; + rgb2hsl(red, green, blue, hue, saturation, luminance); + + float s = saturation * _saturationGain; + if (s > 1.0f) + saturation = 1.0f; + else + saturation = s; + + float l = luminance * _luminanceGain; + if (l > 1.0f) + luminance = 1.0f; + else + luminance = l; + + hsl2rgb(hue, saturation, luminance, red, green, blue); + } +} + +void HslTransform::rgb2hsl(uint8_t red, uint8_t green, uint8_t blue, uint16_t & hue, float & saturation, float & luminance) +{ + float r = red / 255.0f; + float g = green / 255.0f; + float b = blue / 255.0f; + + float rgbMin = r < g ? (r < b ? r : b) : (g < b ? g : b); + float rgbMax = r > g ? (r > b ? r : b) : (g > b ? g : b); + float diff = rgbMax - rgbMin; + + //luminance + luminance = (rgbMin + rgbMax) / 2.0f; + + if (diff == 0.0f) { + saturation = 0.0f; + hue = 0; + return; + } + + //saturation + if (luminance < 0.5f) + saturation = diff / (rgbMin + rgbMax); + else + saturation = diff / (2.0f - rgbMin - rgbMax); + + if (rgbMax == r) + { + // start from 360 to be sure that we won't assign a negative number to the unsigned hue value + hue = 360 + 60 * (g - b) / (rgbMax - rgbMin); + + if (hue > 359) + hue -= 360; + } + else if (rgbMax == g) + { + hue = 120 + 60 * (b - r) / (rgbMax - rgbMin); + } + else + { + hue = 240 + 60 * (r - g) / (rgbMax - rgbMin); + } + +} + +void HslTransform::hsl2rgb(uint16_t hue, float saturation, float luminance, uint8_t & red, uint8_t & green, uint8_t & blue) +{ + if (saturation == 0.0f){ + red = (uint8_t)(luminance * 255.0f); + green = (uint8_t)(luminance * 255.0f); + blue = (uint8_t)(luminance * 255.0f); + return; + } + + float q; + + if (luminance < 0.5f) + q = luminance * (1.0f + saturation); + else + q = (luminance + saturation) - (luminance * saturation); + + float p = (2.0f * luminance) - q; + float h = hue / 360.0f; + + float t[3]; + + t[0] = h + (1.0f / 3.0f); + t[1] = h; + t[2] = h - (1.0f / 3.0f); + + for (int i = 0; i < 3; i++) { + if (t[i] < 0.0f) + t[i] += 1.0f; + if (t[i] > 1.0f) + t[i] -= 1.0f; + } + + float out[3]; + + for (int i = 0; i < 3; i++) { + if (t[i] * 6.0f < 1.0f) + out[i] = p + (q - p) * 6.0f * t[i]; + else if (t[i] * 2.0f < 1.0f) + out[i] = q; + else if (t[i] * 3.0f < 2.0f) + out[i] = p + (q - p) * ((2.0f / 3.0f) - t[i]) * 6.0f; + else out[i] = p; + } + + //convert back to 0...255 range + red = (uint8_t)(out[0] * 255.0f); + green = (uint8_t)(out[1] * 255.0f); + blue = (uint8_t)(out[2] * 255.0f); + +} diff --git a/libsrc/utils/RgbChannelCorrection.cpp b/libsrc/utils/RgbChannelCorrection.cpp new file mode 100644 index 00000000..2cced20b --- /dev/null +++ b/libsrc/utils/RgbChannelCorrection.cpp @@ -0,0 +1,120 @@ +// STL includes +#include + +// Utils includes +#include + +RgbChannelCorrection::RgbChannelCorrection() : + _correctionR(255), + _correctionB(255), + _correctionG(255) +{ + initializeMapping(); +} + +RgbChannelCorrection::RgbChannelCorrection(int correctionR, int correctionG, int correctionB) : + _correctionR(correctionR), + _correctionG(correctionG), + _correctionB(correctionB) +{ + initializeMapping(); +} + +RgbChannelCorrection::~RgbChannelCorrection() +{ +} + +uint8_t RgbChannelCorrection::getcorrectionR() const +{ + return _correctionR; +} + +void RgbChannelCorrection::setcorrectionR(uint8_t correctionR) +{ + _correctionR = correctionR; + initializeMapping(); +} + +uint8_t RgbChannelCorrection::getcorrectionG() const +{ + return _correctionG; +} + +void RgbChannelCorrection::setcorrectionG(uint8_t correctionG) +{ + _correctionG = correctionG; + initializeMapping(); +} + +uint8_t RgbChannelCorrection::getcorrectionB() const +{ + return _correctionB; +} + +void RgbChannelCorrection::setcorrectionB(uint8_t correctionB) +{ + _correctionB = correctionB; + initializeMapping(); +} + +uint8_t RgbChannelCorrection::correctionR(uint8_t inputR) const +{ + return _mappingR[inputR]; +} + +uint8_t RgbChannelCorrection::correctionG(uint8_t inputG) const +{ + return _mappingG[inputG]; +} + +uint8_t RgbChannelCorrection::correctionB(uint8_t inputB) const +{ + return _mappingB[inputB]; +} + +void RgbChannelCorrection::initializeMapping() +{ + // initialize the mapping + for (int i = 0; i < 256; ++i) + { + int outputR = (i * _correctionR) / 255; + if (outputR < -255) + { + outputR = -255; + } + else if (outputR > 255) + { + outputR = 255; + } + _mappingR[i] = outputR; + } + for (int i = 0; i < 256; ++i) + { + int outputG = (i * _correctionG) / 255; + if (outputG < -255) + { + outputG = -255; + } + else if (outputG > 255) + { + outputG = 255; + } + _mappingG[i] = outputG; + } + for (int i = 0; i < 256; ++i) + { + int outputB = (i * _correctionB) / 255; + if (outputB < -255) + { + outputB = -255; + } + else if (outputB > 255) + { + outputB = 255; + } + _mappingB[i] = outputB; + } + + +} + From b6c08ae34ff6ac3d83ac5fceec2bd14ceb5fc2a7 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Thu, 10 Mar 2016 17:28:34 +0100 Subject: [PATCH 29/67] Update CMakeLists.txt Former-commit-id: 808a5c9a22a57f6d6ee77adb1c1f112b291b7188 --- libsrc/utils/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libsrc/utils/CMakeLists.txt b/libsrc/utils/CMakeLists.txt index 1aad10cb..8de00707 100644 --- a/libsrc/utils/CMakeLists.txt +++ b/libsrc/utils/CMakeLists.txt @@ -23,8 +23,12 @@ add_library(hyperion-utils ${CURRENT_HEADER_DIR}/HsvTransform.h ${CURRENT_SOURCE_DIR}/HsvTransform.cpp + ${CURRENT_HEADER_DIR}/HslTransform.h + ${CURRENT_SOURCE_DIR}/HslTransform.cpp ${CURRENT_HEADER_DIR}/RgbChannelTransform.h ${CURRENT_SOURCE_DIR}/RgbChannelTransform.cpp + ${CURRENT_HEADER_DIR}/RgbChannelCorrection.h + ${CURRENT_SOURCE_DIR}/RgbChannelCorrection.cpp ${CURRENT_HEADER_DIR}/jsonschema/JsonFactory.h ${CURRENT_HEADER_DIR}/jsonschema/JsonSchemaChecker.h From 3370cc6271a332c92d7feaa8c52159b6372cecf5 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Thu, 10 Mar 2016 17:54:39 +0100 Subject: [PATCH 30/67] Update MultiColorTransform.cpp Former-commit-id: c743c2fec460d645b64c1172212469287af6a8db --- libsrc/hyperion/MultiColorTransform.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libsrc/hyperion/MultiColorTransform.cpp b/libsrc/hyperion/MultiColorTransform.cpp index d15f020e..0b524acf 100644 --- a/libsrc/hyperion/MultiColorTransform.cpp +++ b/libsrc/hyperion/MultiColorTransform.cpp @@ -89,6 +89,7 @@ std::vector MultiColorTransform::applyTransform(const std::vector_hsvTransform.transform(color.red, color.green, color.blue); + transform->_hslTransform.transform(color.red, color.green, color.blue); color.red = transform->_rgbRedTransform.transform(color.red); color.green = transform->_rgbGreenTransform.transform(color.green); color.blue = transform->_rgbBlueTransform.transform(color.blue); From b0d74b2dd8271fcb5a781e9133715aa42f2909e7 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Thu, 10 Mar 2016 17:57:52 +0100 Subject: [PATCH 31/67] Update ColorTransform.h Former-commit-id: 4c944b94cf26720906efa63ea4266064dc092134 --- include/hyperion/ColorTransform.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/hyperion/ColorTransform.h b/include/hyperion/ColorTransform.h index 50cbedba..998d6a60 100644 --- a/include/hyperion/ColorTransform.h +++ b/include/hyperion/ColorTransform.h @@ -6,6 +6,7 @@ // Utils includes #include #include +#include class ColorTransform { @@ -23,4 +24,7 @@ public: /// The HSV Transform for applying Saturation and Value transforms HsvTransform _hsvTransform; + + /// The HSL Transform for applying Saturation and Value transforms + HslTransform _hslTransform; }; From 6e7157c5715b9e6d6155ca6584ba6fc079ddada2 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Thu, 10 Mar 2016 18:08:34 +0100 Subject: [PATCH 32/67] Update Hyperion.h Former-commit-id: c1bd4a7397e8ae2e72b9ef5dcc32ee3b866e2c36 --- include/hyperion/Hyperion.h | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index 8ffc7fe5..88c480d3 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -124,11 +124,17 @@ public slots: const std::vector & getTransformIds() const; /// - /// Returns the list with unique transform identifiers + /// Returns the list with unique correction identifiers /// @return The list with correction identifiers /// const std::vector & getCorrectionIds() const; - + + /// + /// Returns the list with unique correction identifiers + /// @return The list with correction identifiers + /// + const std::vector & getTemperatureIds() const; + /// /// Returns the ColorTransform with the given identifier /// @return The transform with the given identifier (or nullptr if the identifier does not exist) @@ -136,11 +142,17 @@ public slots: ColorTransform * getTransform(const std::string& id); /// - /// Returns the ColorTransform with the given identifier - /// @return The transform with the given identifier (or nullptr if the identifier does not exist) + /// Returns the ColorCorrection with the given identifier + /// @return The correction with the given identifier (or nullptr if the identifier does not exist) /// ColorCorrection * getCorrection(const std::string& id); + /// + /// Returns the ColorCorrection with the given identifier + /// @return The correction with the given identifier (or nullptr if the identifier does not exist) + /// + ColorCorrection * getTemperature(const std::string& id); + /// /// Returns MessageForwarder Object /// @return instance of message forwarder object @@ -152,6 +164,9 @@ public slots: /// Tell Hyperion that the corrections have changed and the leds need to be updated void correctionsUpdated(); + + /// Tell Hyperion that the corrections have changed and the leds need to be updated + void temperaturesUpdated(); /// /// Clears the given priority channel. This will switch the led-colors to the colors of the next From da7183d28bd4485b26113303097aaac759310bc1 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Thu, 10 Mar 2016 18:13:46 +0100 Subject: [PATCH 33/67] Update Hyperion.cpp Former-commit-id: 5bad6209c49a8fd9eba5582119d9e130b9bea565 --- libsrc/hyperion/Hyperion.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index 79300f0c..b564b3a6 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -634,6 +634,11 @@ void Hyperion::correctionsUpdated() update(); } +void Hyperion::temperaturesUpdated() +{ + update(); +} + void Hyperion::clear(int priority) { if (_muxer.hasPriority(priority)) From 0baebe387342b8a544dd6c7b388a5dda78b25f28 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Fri, 11 Mar 2016 12:20:59 +0100 Subject: [PATCH 34/67] Update hyperion-remote.cpp Former-commit-id: bb2282e48bdd93d4dffcd763ff34e33d3f00670c --- src/hyperion-remote/hyperion-remote.cpp | 84 +++++++++++++++++++++---- 1 file changed, 72 insertions(+), 12 deletions(-) diff --git a/src/hyperion-remote/hyperion-remote.cpp b/src/hyperion-remote/hyperion-remote.cpp index 3636721f..e548fbdc 100644 --- a/src/hyperion-remote/hyperion-remote.cpp +++ b/src/hyperion-remote/hyperion-remote.cpp @@ -53,20 +53,30 @@ int main(int argc, char * argv[]) IntParameter & argDuration = parameters.add ('d', "duration" , "Specify how long the leds should be switched on in millseconds [default: infinity]"); ColorParameter & argColor = parameters.add ('c', "color" , "Set all leds to a constant color (either RRGGBB hex value or a color name. The color may be repeated multiple time like: RRGGBBRRGGBB)"); ImageParameter & argImage = parameters.add ('i', "image" , "Set the leds to the colors according to the given image file"); - StringParameter & argEffect = parameters.add ('e', "effect" , "Enable the effect with the given name"); - StringParameter & argEffectArgs = parameters.add (0x0, "effectArgs", "Arguments to use in combination with the specified effect. Should be a Json object string."); + StringParameter & argEffect = parameters.add ('e', "effect" , "Enable the effect with the given name"); + StringParameter & argEffectArgs = parameters.add (0x0, "effectArgs", "Arguments to use in combination with the specified effect. Should be a Json object string."); SwitchParameter<> & argServerInfo = parameters.add >('l', "list" , "List server info"); SwitchParameter<> & argClear = parameters.add >('x', "clear" , "Clear data for the priority channel provided by the -p option"); SwitchParameter<> & argClearAll = parameters.add >(0x0, "clearall" , "Clear data for all active priority channels"); StringParameter & argId = parameters.add ('q', "qualifier" , "Identifier(qualifier) of the transform to set"); DoubleParameter & argSaturation = parameters.add ('s', "saturation", "Set the HSV saturation gain of the leds"); DoubleParameter & argValue = parameters.add ('v', "value" , "Set the HSV value gain of the leds"); + DoubleParameter & argSaturationL = parameters.add ('u', "saturationL", "Set the HSL saturation gain of the leds"); + DoubleParameter & argLuminance = parameters.add ('m', "luminance" , "Set the HSL luminance gain of the leds"); TransformParameter & argGamma = parameters.add('g', "gamma" , "Set the gamma of the leds (requires 3 space seperated values)"); TransformParameter & argThreshold = parameters.add('t', "threshold" , "Set the threshold of the leds (requires 3 space seperated values between 0.0 and 1.0)"); TransformParameter & argBlacklevel = parameters.add('b', "blacklevel", "Set the blacklevel of the leds (requires 3 space seperated values which are normally between 0.0 and 1.0)"); TransformParameter & argWhitelevel = parameters.add('w', "whitelevel", "Set the whitelevel of the leds (requires 3 space seperated values which are normally between 0.0 and 1.0)"); SwitchParameter<> & argPrint = parameters.add >(0x0, "print" , "Print the json input and output messages on stdout"); SwitchParameter<> & argHelp = parameters.add >('h', "help" , "Show this help message and exit"); + StringParameter & argIdC = parameters.add ('cq', "qualifier" , "Identifier(qualifier) of the correction to set"); + IntParameter & argCorrR = parameters.add ('cr', "correctionR" , "Specify the red channel correction factor"); + IntParameter & argCorrG = parameters.add ('cg', "correctionG" , "Specify the green channel correction factor"); + IntParameter & argCorrB = parameters.add ('cb', "correctionB" , "Specify the blue channel correction factor"); + StringParameter & argIdT = parameters.add ('tq', "qualifier" , "Identifier(qualifier) of the temperature to set"); + IntParameter & argTempR = parameters.add ('tr', "tempR" , "Specify the red channel temperature factor"); + IntParameter & argTempG = parameters.add ('tg', "tempG" , "Specify the red channel temperature factor"); + IntParameter & argTempB = parameters.add ('tb', "tempB" , "Specify the red channel temperature factor"); // set the default values argAddress.setDefault(defaultServerAddress.toStdString()); @@ -85,27 +95,41 @@ int main(int argc, char * argv[]) } // check if at least one of the available color transforms is set - bool colorTransform = argSaturation.isSet() || argValue.isSet() || argThreshold.isSet() || argGamma.isSet() || argBlacklevel.isSet() || argWhitelevel.isSet(); + bool colorTransform = argSaturation.isSet() || argValue.isSet() || argSaturationL.isSet() || argLuminance.isSet() || argThreshold.isSet() || argGamma.isSet() || argBlacklevel.isSet() || argWhitelevel.isSet(); + bool colorCorrection = argCorrR.isSet() || argCorrG.isSet() || argCorrB.isSet(); + bool colorTemp = argTempR.isSet() || argTempG.isSet() || argTempB.isSet(); // check that exactly one command was given - int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorTransform}); + int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorTransform, colorCorrection, colorTemp}); if (commandCount != 1) { std::cerr << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:" << std::endl; std::cerr << " " << argColor.usageLine() << std::endl; std::cerr << " " << argImage.usageLine() << std::endl; - std::cerr << " " << argEffect.usageLine() << std::endl; + std::cerr << " " << argEffect.usageLine() << std::endl; std::cerr << " " << argServerInfo.usageLine() << std::endl; std::cerr << " " << argClear.usageLine() << std::endl; std::cerr << " " << argClearAll.usageLine() << std::endl; - std::cerr << "or one or more of the available color transformations:" << std::endl; + std::cerr << "one or more of the available color transformations:" << std::endl; std::cerr << " " << argId.usageLine() << std::endl; std::cerr << " " << argSaturation.usageLine() << std::endl; std::cerr << " " << argValue.usageLine() << std::endl; + std::cerr << " " << argSaturationL.usageLine() << std::endl; + std::cerr << " " << argLuminance.usageLine() << std::endl; std::cerr << " " << argThreshold.usageLine() << std::endl; 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 << " " << argCorrR.usageLine() << std::endl; + std::cerr << " " << argCorrG.usageLine() << std::endl; + std::cerr << " " << argCorrB.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 << " " << argTempR.usageLine() << std::endl; + std::cerr << " " << argTempG.usageLine() << std::endl; + std::cerr << " " << argTempB.usageLine() << std::endl; return 1; } @@ -121,11 +145,11 @@ int main(int argc, char * argv[]) { connection.setImage(argImage.getValue(), argPriority.getValue(), argDuration.getValue()); } - else if (argEffect.isSet()) - { - connection.setEffect(argEffect.getValue(), argEffectArgs.getValue(), argPriority.getValue(), argDuration.getValue()); - } - else if (argServerInfo.isSet()) + else if (argEffect.isSet()) + { + connection.setEffect(argEffect.getValue(), argEffectArgs.getValue(), argPriority.getValue(), argDuration.getValue()); + } + else if (argServerInfo.isSet()) { QString info = connection.getServerInfo(); std::cout << "Server info:\n" << info.toStdString() << std::endl; @@ -141,12 +165,14 @@ int main(int argc, char * argv[]) else if (colorTransform) { std::string transId; - double saturation, value; + 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(); @@ -156,11 +182,45 @@ int main(int argc, char * argv[]) argId.isSet() ? &transId : nullptr, argSaturation.isSet() ? &saturation : nullptr, argValue.isSet() ? &value : nullptr, + argSaturationL.isSet() ? &saturationL : nullptr, + argLuminance.isSet() ? &luminance : nullptr, argThreshold.isSet() ? &threshold : nullptr, argGamma.isSet() ? &gamma : nullptr, argBlacklevel.isSet() ? &blacklevel : nullptr, argWhitelevel.isSet() ? &whitelevel : nullptr); } + else if (colorCorrection) + { + std::string transId; + int red, green, blue; + + if (argIdC.isSet()) transId = argId.getValue(); + if (argCorrR.isSet()) red = argCorrR.getValue(); + if (argCorrG.isSet()) green = argCorrG.getValue(); + if (argCorrB.isSet()) blue = argCorrB.getValue(); + + connection.setCorrection( + argIdC.isSet() ? &transId : nullptr, + argCorrR.isSet() ? &red : nullptr, + argCorrG.isSet() ? &green : nullptr, + argCorrB.isSet() ? &blue : nullptr, + } + else if (colorTemp) + { + std::string transId; + int red, green, blue; + + if (argIdT.isSet()) transId = argId.getValue(); + if (argTempR.isSet()) red = argTempR.getValue(); + if (argTempG.isSet()) green = argTempG.getValue(); + if (argTempB.isSet()) blue = argTempB.getValue(); + + connection.setCorrection( + argIdC.isSet() ? &transId : nullptr, + argTempR.isSet() ? &red : nullptr, + argTempG.isSet() ? &green : nullptr, + argTempB.isSet() ? &blue : nullptr, + } } catch (const std::runtime_error & e) { From 8caf69e5414430f657eb0fd17c264bf18260bf61 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Fri, 11 Mar 2016 12:21:04 +0100 Subject: [PATCH 35/67] Update JsonConnection.h Former-commit-id: fa07c01ab5bb34029d8b13ea93187a54686d784c --- src/hyperion-remote/JsonConnection.h | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/hyperion-remote/JsonConnection.h b/src/hyperion-remote/JsonConnection.h index 472c5565..2f170fef 100644 --- a/src/hyperion-remote/JsonConnection.h +++ b/src/hyperion-remote/JsonConnection.h @@ -89,6 +89,8 @@ public: /// @param transformId The identifier of the transform to set /// @param saturation The HSV saturation gain /// @param value The HSV value gain + /// @param saturationL The HSL saturation gain + /// @param luminance The HSL luminance gain /// @param threshold The threshold /// @param gamma The gamma value /// @param blacklevel The blacklevel @@ -98,10 +100,42 @@ public: std::string * transformId, double * saturation, double * value, + double * saturationL, + double * luminance, ColorTransformValues * threshold, ColorTransformValues * gamma, ColorTransformValues * blacklevel, ColorTransformValues * whitelevel); + + /// + /// Set the color correction of the leds + /// + /// @note Note that providing a NULL will leave the settings on the server unchanged + /// + /// @param correctionId The identifier of the correction to set + /// @param red The red correction value + /// @param green The green correction value + /// @param blue The blue correction value + void setCorrection( + std::string * correctionId, + int * red, + int * green, + int * blue); + + /// + /// Set the color temperature of the leds + /// + /// @note Note that providing a NULL will leave the settings on the server unchanged + /// + /// @param temperatureId The identifier of the correction to set + /// @param red The red temperature value + /// @param green The green temperature value + /// @param blue The blue temperature value + void setCorrection( + std::string * temperaturenId, + int * red, + int * green, + int * blue); private: /// From 39b318e842d7207fd886319afcd0c3604a5c7147 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Fri, 11 Mar 2016 12:28:45 +0100 Subject: [PATCH 36/67] Update JsonConnection.h Former-commit-id: 5191309bb65f446d8d60e21193ece00560d5e67b --- src/hyperion-remote/JsonConnection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hyperion-remote/JsonConnection.h b/src/hyperion-remote/JsonConnection.h index 2f170fef..85f4ddb0 100644 --- a/src/hyperion-remote/JsonConnection.h +++ b/src/hyperion-remote/JsonConnection.h @@ -131,7 +131,7 @@ public: /// @param red The red temperature value /// @param green The green temperature value /// @param blue The blue temperature value - void setCorrection( + void setTemperature( std::string * temperaturenId, int * red, int * green, From 8fce604ccb1809033fb2786abcdf98f3f7a2380e Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Fri, 11 Mar 2016 12:29:07 +0100 Subject: [PATCH 37/67] Update JsonConnection.h Former-commit-id: 5d44428cd95e2b81b867ace67eb1f77aceb47856 --- src/hyperion-remote/JsonConnection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hyperion-remote/JsonConnection.h b/src/hyperion-remote/JsonConnection.h index 85f4ddb0..ccda9f1c 100644 --- a/src/hyperion-remote/JsonConnection.h +++ b/src/hyperion-remote/JsonConnection.h @@ -132,7 +132,7 @@ public: /// @param green The green temperature value /// @param blue The blue temperature value void setTemperature( - std::string * temperaturenId, + std::string * temperatureId, int * red, int * green, int * blue); From a5e042225e640c117d32bad34287e292f0e0c854 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Fri, 11 Mar 2016 12:30:32 +0100 Subject: [PATCH 38/67] Update JsonConnection.cpp Former-commit-id: 7b748e605939b65f02cb768a924faa48787618c3 --- src/hyperion-remote/JsonConnection.cpp | 83 +++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/src/hyperion-remote/JsonConnection.cpp b/src/hyperion-remote/JsonConnection.cpp index 652a3dfa..7e296af7 100644 --- a/src/hyperion-remote/JsonConnection.cpp +++ b/src/hyperion-remote/JsonConnection.cpp @@ -192,7 +192,7 @@ void JsonConnection::clearAll() parseReply(reply); } -void JsonConnection::setTransform(std::string * transformId, double * saturation, double * value, ColorTransformValues *threshold, ColorTransformValues *gamma, ColorTransformValues *blacklevel, ColorTransformValues *whitelevel) +void JsonConnection::setTransform(std::string * transformId, double * saturation, double * value, double * saturationL, double * luminance, ColorTransformValues *threshold, ColorTransformValues *gamma, ColorTransformValues *blacklevel, ColorTransformValues *whitelevel) { std::cout << "Set color transforms" << std::endl; @@ -215,7 +215,16 @@ void JsonConnection::setTransform(std::string * transformId, double * saturation { transform["valueGain"] = *value; } + + if (saturation != nullptr) + { + transform["saturationLGain"] = *saturationL; + } + if (value != nullptr) + { + transform["luminanceGain"] = *luminance; + } if (threshold != nullptr) { Json::Value & v = transform["threshold"]; @@ -255,6 +264,78 @@ void JsonConnection::setTransform(std::string * transformId, double * saturation parseReply(reply); } +void JsonConnection::setCorrection(std::string * correctionId, int * red, int * green, int * blue) +{ + std::cout << "Set color corrections" << std::endl; + + // create command + Json::Value command; + command["command"] = "correction"; + Json::Value & correction = command["correction"]; + + if (correctionId != nullptr) + { + correction["id"] = *correctionId; + } + + if (red != nullptr) + { + correction["red"] = *red; + } + + if (green != nullptr) + { + correction["green"] = *green; + } + + if (blue != nullptr) + { + correction["blue"] = *blue; + } + + // send command message + Json::Value reply = sendMessage(command); + + // parse reply message + parseReply(reply); +} + +void JsonConnection::setTemperature(std::string * temperatureId, int * red, int * green, int * blue) +{ + std::cout << "Set color temperature corrections" << std::endl; + + // create command + Json::Value command; + command["command"] = "temperature"; + Json::Value & temperature = command["temperature"]; + + if (correctionId != nullptr) + { + temperature["id"] = *temperatureId; + } + + if (red != nullptr) + { + temperature["red"] = *red; + } + + if (green != nullptr) + { + temperature["green"] = *green; + } + + if (blue != nullptr) + { + temperature["blue"] = *blue; + } + + // send command message + Json::Value reply = sendMessage(command); + + // parse reply message + parseReply(reply); +} + Json::Value JsonConnection::sendMessage(const Json::Value & message) { // serialize message (FastWriter already appends a newline) From c937dfa67410576b6b6686016e1b68833abb3ef2 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Fri, 11 Mar 2016 12:32:48 +0100 Subject: [PATCH 39/67] Update JsonClientConnection.h Former-commit-id: adc564d5259638c3e79ab5a12550a89c0d719186 --- libsrc/jsonserver/JsonClientConnection.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libsrc/jsonserver/JsonClientConnection.h b/libsrc/jsonserver/JsonClientConnection.h index 01db54b1..acf58d7d 100644 --- a/libsrc/jsonserver/JsonClientConnection.h +++ b/libsrc/jsonserver/JsonClientConnection.h @@ -112,6 +112,20 @@ private: /// @param message the incoming message /// void handleTransformCommand(const Json::Value & message); + + /// + /// Handle an incoming JSON Correction message + /// + /// @param message the incoming message + /// + void handleCorrectionCommand(const Json::Value & message); + + /// + /// Handle an incoming JSON Temperature message + /// + /// @param message the incoming message + /// + void handleTemperatureCommand(const Json::Value & message); /// /// Handle an incoming JSON message of unknown type From 28fd10cdcd87cbe16bde1a31104324a47b5af203 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Fri, 11 Mar 2016 12:46:09 +0100 Subject: [PATCH 40/67] Update JsonClientConnection.cpp Former-commit-id: 6216d16565b82427094b030cede48ee589f5c969 --- libsrc/jsonserver/JsonClientConnection.cpp | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index e4dbc096..3eea8320 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -486,6 +486,16 @@ void JsonClientConnection::handleTransformCommand(const Json::Value &message) { colorTransform->_hsvTransform.setValueGain(transform["valueGain"].asDouble()); } + + if (transform.isMember("saturationLGain")) + { + colorTransform->_hslTransform.setSaturationGain(transform["saturationLGain"].asDouble()); + } + + if (transform.isMember("luminanceGain")) + { + colorTransform->_hslTransform.setLuminanceGain(transform["luminanceGain"].asDouble()); + } if (transform.isMember("threshold")) { @@ -525,6 +535,72 @@ void JsonClientConnection::handleTransformCommand(const Json::Value &message) sendSuccessReply(); } +void JsonClientConnection::handleCorrectionCommand(const Json::Value &message) +{ + const Json::Value & correction = message["correction"]; + + const std::string correctionId = correction.get("id", _hyperion->getCorrectionIds().front()).asString(); + ColorCorrection * colorCorrection = _hyperion->getCorrection(CorrectionId); + if (colorCorrection == nullptr) + { + //sendErrorReply(std::string("Incorrect transform identifier: ") + transformId); + return; + } + + if (correction.isMember("red")) + { + colorCorrection->_rgbCorrection.setcorrectionR(correction["red"].asInt()); + } + + if (correction.isMember("green")) + { + colorCorrection->_rgbCorrection.setcorrectionG(correction["green"].asInt()); + } + + if (correction.isMember("blue")) + { + colorCorrection->_rgbCorrection.setcorrectionB(correction["blue"].asInt()); + } + + // commit the changes + _hyperion->correctionsUpdated(); + + sendSuccessReply(); +} + +void JsonClientConnection::handleTemperatureCommand(const Json::Value &message) +{ + const Json::Value & temperature = message["temperature"]; + + const std::string tempId = temperature.get("id", _hyperion->getTemperatureIds().front()).asString(); + ColorCorrection * colorTemperature = _hyperion->getTemperature(TemperatureId); + if (colorTemperature == nullptr) + { + //sendErrorReply(std::string("Incorrect transform identifier: ") + transformId); + return; + } + + if (temperature.isMember("red")) + { + colorTemperature->_rgbCorrection.setcorrectionR(temperature["red"].asInt()); + } + + if (temperature.isMember("green")) + { + colorTemperature->_rgbCorrection.setcorrectionG(temperature["green"].asInt()); + } + + if (temperature.isMember("blue")) + { + colorTemperature->_rgbCorrection.setcorrectionB(temperature["blue"].asInt()); + } + + // commit the changes + _hyperion->temperaturesUpdated(); + + sendSuccessReply(); +} + void JsonClientConnection::handleNotImplemented() { sendErrorReply("Command not implemented"); From fd2cb44b1c2ebec31810511c0aa8e4a31e232c12 Mon Sep 17 00:00:00 2001 From: redpanther Date: Sun, 13 Mar 2016 08:07:58 +0100 Subject: [PATCH 41/67] merge upstream Former-commit-id: 041b6fab005766e1e5be56db2ce264c060504e47 --- src/hyperion-remote/CMakeLists.txt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/hyperion-remote/CMakeLists.txt b/src/hyperion-remote/CMakeLists.txt index aef98214..36ca8cc2 100644 --- a/src/hyperion-remote/CMakeLists.txt +++ b/src/hyperion-remote/CMakeLists.txt @@ -2,15 +2,6 @@ cmake_minimum_required(VERSION 2.8) project(hyperion-remote) -<<<<<<< HEAD -# find Qt4 -if(ENABLE_QT5) -find_package(Qt5 COMPONENTS Core Gui Widgets Network REQUIRED) -# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") -# set(CMAKE_CXX_FLAGS "-fPIC") -else(ENABLE_QT5) -find_package(Qt4 REQUIRED QtCore QtGui QtNetwork) -======= # find Qt if(ENABLE_QT5) find_package(Qt5 COMPONENTS Core Gui Widgets Network REQUIRED) @@ -18,7 +9,6 @@ if(ENABLE_QT5) # set(CMAKE_CXX_FLAGS "-fPIC") else(ENABLE_QT5) find_package(Qt4 REQUIRED QtCore QtGui QtNetwork) ->>>>>>> upstream/master/master endif(ENABLE_QT5) # The following I do not undrstand completely... From e4d77660a4526814afae4aa0e4055d9c62c9b83e Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Sun, 13 Mar 2016 11:59:36 +0100 Subject: [PATCH 42/67] Bug fixes Former-commit-id: a6783a75edb83988d1737df3d4a7a14c71ec4223 --- libsrc/jsonserver/JsonClientConnection.cpp | 13 ++++-- libsrc/jsonserver/JsonSchemas.qrc | 2 + .../jsonserver/schema/schema-correction.json | 41 +++++++++++++++++++ .../jsonserver/schema/schema-temperature.json | 41 +++++++++++++++++++ .../jsonserver/schema/schema-transform.json | 10 +++++ libsrc/jsonserver/schema/schema.json | 2 +- src/hyperion-remote/JsonConnection.cpp | 2 +- src/hyperion-remote/hyperion-remote.cpp | 20 ++++----- 8 files changed, 115 insertions(+), 16 deletions(-) create mode 100644 libsrc/jsonserver/schema/schema-correction.json create mode 100644 libsrc/jsonserver/schema/schema-temperature.json diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index 3eea8320..9298a3d2 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include // project includes @@ -247,6 +248,10 @@ void JsonClientConnection::handleMessage(const std::string &messageString) handleClearallCommand(message); else if (command == "transform") handleTransformCommand(message); + else if (command == "correction") + handleCorrectionCommand(message); + else if (command == "temperature") + handleTemperatureCommand(message); else handleNotImplemented(); } @@ -540,10 +545,10 @@ void JsonClientConnection::handleCorrectionCommand(const Json::Value &message) const Json::Value & correction = message["correction"]; const std::string correctionId = correction.get("id", _hyperion->getCorrectionIds().front()).asString(); - ColorCorrection * colorCorrection = _hyperion->getCorrection(CorrectionId); + ColorCorrection * colorCorrection = _hyperion->getCorrection(correctionId); if (colorCorrection == nullptr) { - //sendErrorReply(std::string("Incorrect transform identifier: ") + transformId); + //sendErrorReply(std::string("Incorrect correction identifier: ") + correctionId); return; } @@ -573,10 +578,10 @@ void JsonClientConnection::handleTemperatureCommand(const Json::Value &message) const Json::Value & temperature = message["temperature"]; const std::string tempId = temperature.get("id", _hyperion->getTemperatureIds().front()).asString(); - ColorCorrection * colorTemperature = _hyperion->getTemperature(TemperatureId); + ColorCorrection * colorTemperature = _hyperion->getTemperature(tempId); if (colorTemperature == nullptr) { - //sendErrorReply(std::string("Incorrect transform identifier: ") + transformId); + //sendErrorReply(std::string("Incorrect temperature identifier: ") + tempId); return; } diff --git a/libsrc/jsonserver/JsonSchemas.qrc b/libsrc/jsonserver/JsonSchemas.qrc index 7736e530..193624ba 100644 --- a/libsrc/jsonserver/JsonSchemas.qrc +++ b/libsrc/jsonserver/JsonSchemas.qrc @@ -7,6 +7,8 @@ schema/schema-clear.json schema/schema-clearall.json schema/schema-transform.json + schema/schema-correction.json + schema/schema-temperature.json schema/schema-effect.json diff --git a/libsrc/jsonserver/schema/schema-correction.json b/libsrc/jsonserver/schema/schema-correction.json new file mode 100644 index 00000000..f156d8fd --- /dev/null +++ b/libsrc/jsonserver/schema/schema-correction.json @@ -0,0 +1,41 @@ +{ + "type":"object", + "required":true, + "properties":{ + "command": { + "type" : "string", + "required" : true, + "enum" : ["correction"] + }, + "correction": { + "type": "object", + "required": true, + "properties": { + "id" : { + "type" : "string", + "required" : false + }, + "red" : { + "type" : "number", + "required" : false, + "minimum": 0.0, + "maximum": 255.0 + }, + "green" : { + "type" : "number", + "required" : false, + "minimum": 0.0, + "maximum": 255.0 + }, + "blue" : { + "type" : "number", + "required" : false, + "minimum": 0.0, + "maximum": 255.0 + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false +} diff --git a/libsrc/jsonserver/schema/schema-temperature.json b/libsrc/jsonserver/schema/schema-temperature.json new file mode 100644 index 00000000..1e2b7058 --- /dev/null +++ b/libsrc/jsonserver/schema/schema-temperature.json @@ -0,0 +1,41 @@ +{ + "type":"object", + "required":true, + "properties":{ + "command": { + "type" : "string", + "required" : true, + "enum" : ["temperature"] + }, + "temperature": { + "type": "object", + "required": true, + "properties": { + "id" : { + "type" : "string", + "required" : false + }, + "red" : { + "type" : "number", + "required" : false, + "minimum": 0.0, + "maximum": 255.0 + }, + "green" : { + "type" : "number", + "required" : false, + "minimum": 0.0, + "maximum": 255.0 + }, + "blue" : { + "type" : "number", + "required" : false, + "minimum": 0.0, + "maximum": 255.0 + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false +} diff --git a/libsrc/jsonserver/schema/schema-transform.json b/libsrc/jsonserver/schema/schema-transform.json index 7b939839..8b194eab 100644 --- a/libsrc/jsonserver/schema/schema-transform.json +++ b/libsrc/jsonserver/schema/schema-transform.json @@ -25,6 +25,16 @@ "required" : false, "minimum" : 0.0 }, + "saturationLGain" : { + "type" : "number", + "required" : false, + "minimum" : 0.0 + }, + "luminanceGain" : { + "type" : "number", + "required" : false, + "minimum" : 0.0 + }, "threshold": { "type": "array", "required": false, diff --git a/libsrc/jsonserver/schema/schema.json b/libsrc/jsonserver/schema/schema.json index e931f7b7..061339d1 100644 --- a/libsrc/jsonserver/schema/schema.json +++ b/libsrc/jsonserver/schema/schema.json @@ -5,7 +5,7 @@ "command": { "type" : "string", "required" : true, - "enum" : ["color", "image", "effect", "serverinfo", "clear", "clearall", "transform"] + "enum" : ["color", "image", "effect", "serverinfo", "clear", "clearall", "transform", "correction", "temperature"] } } } diff --git a/src/hyperion-remote/JsonConnection.cpp b/src/hyperion-remote/JsonConnection.cpp index 7e296af7..150fa63a 100644 --- a/src/hyperion-remote/JsonConnection.cpp +++ b/src/hyperion-remote/JsonConnection.cpp @@ -309,7 +309,7 @@ void JsonConnection::setTemperature(std::string * temperatureId, int * red, int command["command"] = "temperature"; Json::Value & temperature = command["temperature"]; - if (correctionId != nullptr) + if (temperatureId != nullptr) { temperature["id"] = *temperatureId; } diff --git a/src/hyperion-remote/hyperion-remote.cpp b/src/hyperion-remote/hyperion-remote.cpp index e548fbdc..9d02011c 100644 --- a/src/hyperion-remote/hyperion-remote.cpp +++ b/src/hyperion-remote/hyperion-remote.cpp @@ -69,14 +69,14 @@ int main(int argc, char * argv[]) TransformParameter & argWhitelevel = parameters.add('w', "whitelevel", "Set the whitelevel of the leds (requires 3 space seperated values which are normally between 0.0 and 1.0)"); SwitchParameter<> & argPrint = parameters.add >(0x0, "print" , "Print the json input and output messages on stdout"); SwitchParameter<> & argHelp = parameters.add >('h', "help" , "Show this help message and exit"); - StringParameter & argIdC = parameters.add ('cq', "qualifier" , "Identifier(qualifier) of the correction to set"); - IntParameter & argCorrR = parameters.add ('cr', "correctionR" , "Specify the red channel correction factor"); - IntParameter & argCorrG = parameters.add ('cg', "correctionG" , "Specify the green channel correction factor"); - IntParameter & argCorrB = parameters.add ('cb', "correctionB" , "Specify the blue channel correction factor"); - StringParameter & argIdT = parameters.add ('tq', "qualifier" , "Identifier(qualifier) of the temperature to set"); - IntParameter & argTempR = parameters.add ('tr', "tempR" , "Specify the red channel temperature factor"); - IntParameter & argTempG = parameters.add ('tg', "tempG" , "Specify the red channel temperature factor"); - IntParameter & argTempB = parameters.add ('tb', "tempB" , "Specify the red channel temperature factor"); + StringParameter & argIdC = parameters.add ('y', "qualifier" , "Identifier(qualifier) of the correction to set"); + IntParameter & argCorrR = parameters.add ('1', "correctionR" , "Specify the red channel correction factor"); + IntParameter & argCorrG = parameters.add ('2', "correctionG" , "Specify the green channel correction factor"); + IntParameter & argCorrB = parameters.add ('3', "correctionB" , "Specify the blue channel correction factor"); + StringParameter & argIdT = parameters.add ('z', "qualifier" , "Identifier(qualifier) of the temperature to set"); + IntParameter & argTempR = parameters.add ('4', "tempR" , "Specify the red channel temperature factor"); + IntParameter & argTempG = parameters.add ('5', "tempG" , "Specify the red channel temperature factor"); + IntParameter & argTempB = parameters.add ('6', "tempB" , "Specify the red channel temperature factor"); // set the default values argAddress.setDefault(defaultServerAddress.toStdString()); @@ -203,7 +203,7 @@ int main(int argc, char * argv[]) argIdC.isSet() ? &transId : nullptr, argCorrR.isSet() ? &red : nullptr, argCorrG.isSet() ? &green : nullptr, - argCorrB.isSet() ? &blue : nullptr, + argCorrB.isSet() ? &blue : nullptr); } else if (colorTemp) { @@ -219,7 +219,7 @@ int main(int argc, char * argv[]) argIdC.isSet() ? &transId : nullptr, argTempR.isSet() ? &red : nullptr, argTempG.isSet() ? &green : nullptr, - argTempB.isSet() ? &blue : nullptr, + argTempB.isSet() ? &blue : nullptr); } } catch (const std::runtime_error & e) From a5a17776d49e0f14604b626c7812b8fc2dfb5326 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Sun, 13 Mar 2016 12:10:54 +0100 Subject: [PATCH 43/67] BugFix Former-commit-id: 8887ee93d5bcaa7ee13f4f5afb601a65d59ee113 --- config/hyperion.config.json | 31 ++++++++++++++ libsrc/hyperion/hyperion.schema.json | 42 +++++++++++++++++++ .../jsonserver/schema/schema-correction.json | 18 ++++---- .../jsonserver/schema/schema-temperature.json | 18 ++++---- src/hyperion-remote/hyperion-remote.cpp | 16 +++---- 5 files changed, 99 insertions(+), 26 deletions(-) diff --git a/config/hyperion.config.json b/config/hyperion.config.json index 8c9d1ecc..fbb61a69 100644 --- a/config/hyperion.config.json +++ b/config/hyperion.config.json @@ -42,6 +42,32 @@ /// - 'updateDelay' The delay of the output to leds (in periods of smoothing) "color" : { + "correction" : + [ + { + "id" : "default", + "leds" : "*", + "correctionValues" : + { + "red" : 255, + "green" : 255, + "blue" : 255 + } + } + ], + "temperature" : + [ + { + "id" : "default", + "leds" : "*", + "correctionValues" : + { + "red" : 255, + "green" : 255, + "blue" : 255 + } + } + ], "transform" : [ { @@ -52,6 +78,11 @@ "saturationGain" : 1.0000, "valueGain" : 1.0000 }, + "hsl" : + { + "saturationGain" : 1.0000, + "luminanceGain" : 1.0000 + },` "red" : { "threshold" : 0.0000, diff --git a/libsrc/hyperion/hyperion.schema.json b/libsrc/hyperion/hyperion.schema.json index e459425b..165bd906 100644 --- a/libsrc/hyperion/hyperion.schema.json +++ b/libsrc/hyperion/hyperion.schema.json @@ -38,6 +38,31 @@ "type":"object", "required":false, "properties": { + "correctionValues" : { + "type" : "object", + "required" : false, + "properties" : { + "red" : { + "type" : "integer", + "required" : false, + "minimum" : 0 + "maximum" : 255 + }, + "green" : { + "type" : "integer", + "required" : false, + "minimum" : 0 + "maximum" : 255 + } + "blue" : { + "type" : "integer", + "required" : false, + "minimum" : 0 + "maximum" : 255 + } + }, + "additionalProperties" : false + }, "hsv" : { "type" : "object", "required" : false, @@ -54,6 +79,23 @@ } }, "additionalProperties" : false + }, + "hsl" : { + "type" : "object", + "required" : false, + "properties" : { + "saturationGain" : { + "type" : "number", + "required" : false, + "minimum" : 0.0 + }, + "luminanceGain" : { + "type" : "number", + "required" : false, + "minimum" : 0.0 + } + }, + "additionalProperties" : false }, "red": { "type":"object", diff --git a/libsrc/jsonserver/schema/schema-correction.json b/libsrc/jsonserver/schema/schema-correction.json index f156d8fd..37bbee6f 100644 --- a/libsrc/jsonserver/schema/schema-correction.json +++ b/libsrc/jsonserver/schema/schema-correction.json @@ -16,22 +16,22 @@ "required" : false }, "red" : { - "type" : "number", + "type" : "integer", "required" : false, - "minimum": 0.0, - "maximum": 255.0 + "minimum": 0, + "maximum": 255 }, "green" : { - "type" : "number", + "type" : "integer", "required" : false, - "minimum": 0.0, - "maximum": 255.0 + "minimum": 0, + "maximum": 255 }, "blue" : { - "type" : "number", + "type" : "integer", "required" : false, - "minimum": 0.0, - "maximum": 255.0 + "minimum": 0, + "maximum": 255 } }, "additionalProperties": false diff --git a/libsrc/jsonserver/schema/schema-temperature.json b/libsrc/jsonserver/schema/schema-temperature.json index 1e2b7058..14ce465b 100644 --- a/libsrc/jsonserver/schema/schema-temperature.json +++ b/libsrc/jsonserver/schema/schema-temperature.json @@ -16,22 +16,22 @@ "required" : false }, "red" : { - "type" : "number", + "type" : "integer", "required" : false, - "minimum": 0.0, - "maximum": 255.0 + "minimum": 0, + "maximum": 255 }, "green" : { - "type" : "number", + "type" : "integer", "required" : false, - "minimum": 0.0, - "maximum": 255.0 + "minimum": 0, + "maximum": 255 }, "blue" : { - "type" : "number", + "type" : "integer", "required" : false, - "minimum": 0.0, - "maximum": 255.0 + "minimum": 0, + "maximum": 255 } }, "additionalProperties": false diff --git a/src/hyperion-remote/hyperion-remote.cpp b/src/hyperion-remote/hyperion-remote.cpp index 9d02011c..ee3530df 100644 --- a/src/hyperion-remote/hyperion-remote.cpp +++ b/src/hyperion-remote/hyperion-remote.cpp @@ -61,7 +61,7 @@ int main(int argc, char * argv[]) StringParameter & argId = parameters.add ('q', "qualifier" , "Identifier(qualifier) of the transform to set"); DoubleParameter & argSaturation = parameters.add ('s', "saturation", "Set the HSV saturation gain of the leds"); DoubleParameter & argValue = parameters.add ('v', "value" , "Set the HSV value gain of the leds"); - DoubleParameter & argSaturationL = parameters.add ('u', "saturationL", "Set the HSL saturation gain of the leds"); + DoubleParameter & argSaturationL = parameters.add ('u', "saturationL", "Set the HSL saturation gain of the leds"); DoubleParameter & argLuminance = parameters.add ('m', "luminance" , "Set the HSL luminance gain of the leds"); TransformParameter & argGamma = parameters.add('g', "gamma" , "Set the gamma of the leds (requires 3 space seperated values)"); TransformParameter & argThreshold = parameters.add('t', "threshold" , "Set the threshold of the leds (requires 3 space seperated values between 0.0 and 1.0)"); @@ -70,13 +70,13 @@ int main(int argc, char * argv[]) SwitchParameter<> & argPrint = parameters.add >(0x0, "print" , "Print the json input and output messages on stdout"); 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"); - IntParameter & argCorrR = parameters.add ('1', "correctionR" , "Specify the red channel correction factor"); - IntParameter & argCorrG = parameters.add ('2', "correctionG" , "Specify the green channel correction factor"); - IntParameter & argCorrB = parameters.add ('3', "correctionB" , "Specify the blue channel correction factor"); + IntParameter & argCorrR = parameters.add ('1', "correctionR" , "Specify the red channel correction"); + IntParameter & argCorrG = parameters.add ('2', "correctionG" , "Specify the green channel correction"); + IntParameter & argCorrB = parameters.add ('3', "correctionB" , "Specify the blue channel correction"); StringParameter & argIdT = parameters.add ('z', "qualifier" , "Identifier(qualifier) of the temperature to set"); - IntParameter & argTempR = parameters.add ('4', "tempR" , "Specify the red channel temperature factor"); - IntParameter & argTempG = parameters.add ('5', "tempG" , "Specify the red channel temperature factor"); - IntParameter & argTempB = parameters.add ('6', "tempB" , "Specify the red channel temperature factor"); + IntParameter & argTempR = parameters.add ('4', "tempR" , "Specify the red channel temperature correction"); + IntParameter & argTempG = parameters.add ('5', "tempG" , "Specify the red channel temperature correction"); + IntParameter & argTempB = parameters.add ('6', "tempB" , "Specify the red channel temperature correction"); // set the default values argAddress.setDefault(defaultServerAddress.toStdString()); @@ -106,7 +106,7 @@ int main(int argc, char * argv[]) std::cerr << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:" << std::endl; std::cerr << " " << argColor.usageLine() << std::endl; std::cerr << " " << argImage.usageLine() << std::endl; - std::cerr << " " << argEffect.usageLine() << std::endl; + std::cerr << " " << argEffect.usageLine() << std::endl; std::cerr << " " << argServerInfo.usageLine() << std::endl; std::cerr << " " << argClear.usageLine() << std::endl; std::cerr << " " << argClearAll.usageLine() << std::endl; From 28f67871dc1fa4cc764ef8442241dbc87c7fae93 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Sun, 13 Mar 2016 13:05:47 +0100 Subject: [PATCH 44/67] More fixes Former-commit-id: 331ba604dba8aa16f9cf42c5827c8542502be545 --- libsrc/hyperion/hyperion.schema.json | 25 ---------------------- libsrc/jsonserver/JsonClientConnection.cpp | 2 ++ src/hyperion-remote/JsonConnection.cpp | 4 ++-- 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/libsrc/hyperion/hyperion.schema.json b/libsrc/hyperion/hyperion.schema.json index 165bd906..6ace729f 100644 --- a/libsrc/hyperion/hyperion.schema.json +++ b/libsrc/hyperion/hyperion.schema.json @@ -38,31 +38,6 @@ "type":"object", "required":false, "properties": { - "correctionValues" : { - "type" : "object", - "required" : false, - "properties" : { - "red" : { - "type" : "integer", - "required" : false, - "minimum" : 0 - "maximum" : 255 - }, - "green" : { - "type" : "integer", - "required" : false, - "minimum" : 0 - "maximum" : 255 - } - "blue" : { - "type" : "integer", - "required" : false, - "minimum" : 0 - "maximum" : 255 - } - }, - "additionalProperties" : false - }, "hsv" : { "type" : "object", "required" : false, diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index 9298a3d2..5a11dc59 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -409,6 +409,8 @@ void JsonClientConnection::handleServerInfoCommand(const Json::Value &) transform["saturationGain"] = colorTransform->_hsvTransform.getSaturationGain(); transform["valueGain"] = colorTransform->_hsvTransform.getValueGain(); + transform["saturationLGain"] = colorTransform->_hslTransform.getSaturationGain(); + transform["luminanceGain"] = colorTransform->_hslTransform.getLuminanceGain(); Json::Value & threshold = transform["threshold"]; threshold.append(colorTransform->_rgbRedTransform.getThreshold()); diff --git a/src/hyperion-remote/JsonConnection.cpp b/src/hyperion-remote/JsonConnection.cpp index 150fa63a..009647af 100644 --- a/src/hyperion-remote/JsonConnection.cpp +++ b/src/hyperion-remote/JsonConnection.cpp @@ -216,12 +216,12 @@ void JsonConnection::setTransform(std::string * transformId, double * saturation transform["valueGain"] = *value; } - if (saturation != nullptr) + if (saturationL != nullptr) { transform["saturationLGain"] = *saturationL; } - if (value != nullptr) + if (luminance != nullptr) { transform["luminanceGain"] = *luminance; } From 1f1aee0c37bfa718cfb20f9ea7b6b3f19729f7bb Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Sun, 13 Mar 2016 21:14:22 +0100 Subject: [PATCH 45/67] Final fixex Former-commit-id: 7b2e1a33ab7705dddadfa1ec99d3d7c379ab10dd --- libsrc/hyperion/hyperion.schema.json | 2 +- libsrc/jsonserver/JsonClientConnection.cpp | 6 +++--- src/hyperion-remote/hyperion-remote.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libsrc/hyperion/hyperion.schema.json b/libsrc/hyperion/hyperion.schema.json index 6ace729f..f30e1a27 100644 --- a/libsrc/hyperion/hyperion.schema.json +++ b/libsrc/hyperion/hyperion.schema.json @@ -38,7 +38,7 @@ "type":"object", "required":false, "properties": { - "hsv" : { + "hsv" : { "type" : "object", "required" : false, "properties" : { diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index 5a11dc59..ca0cf46e 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -232,7 +232,7 @@ void JsonClientConnection::handleMessage(const std::string &messageString) sendErrorReply("Error while validating json: " + errors); return; } - + // switch over all possible commands and handle them if (command == "color") handleColorCommand(message); @@ -483,7 +483,7 @@ void JsonClientConnection::handleTransformCommand(const Json::Value &message) //sendErrorReply(std::string("Incorrect transform identifier: ") + transformId); return; } - + if (transform.isMember("saturationGain")) { colorTransform->_hsvTransform.setSaturationGain(transform["saturationGain"].asDouble()); @@ -535,7 +535,7 @@ void JsonClientConnection::handleTransformCommand(const Json::Value &message) colorTransform->_rgbGreenTransform.setWhitelevel(values[1u].asDouble()); colorTransform->_rgbBlueTransform .setWhitelevel(values[2u].asDouble()); } - + // commit the changes _hyperion->transformsUpdated(); diff --git a/src/hyperion-remote/hyperion-remote.cpp b/src/hyperion-remote/hyperion-remote.cpp index ee3530df..b59d87e4 100644 --- a/src/hyperion-remote/hyperion-remote.cpp +++ b/src/hyperion-remote/hyperion-remote.cpp @@ -177,7 +177,7 @@ int main(int argc, char * argv[]) 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, From ef92488c979547dcd19c4e5c2203c416d7348765 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Tue, 15 Mar 2016 11:01:29 +0100 Subject: [PATCH 46/67] Update hyperion.config.json Former-commit-id: 0febd7e5e4651880d9debd6516e47f1700bd351e --- config/hyperion.config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/hyperion.config.json b/config/hyperion.config.json index fbb61a69..355ad7d7 100644 --- a/config/hyperion.config.json +++ b/config/hyperion.config.json @@ -60,7 +60,7 @@ { "id" : "default", "leds" : "*", - "correctionValues" : + "temperatureValues" : { "red" : 255, "green" : 255, From d75a88eb9f97fcf8b2ff4a0ede00684de46a83d4 Mon Sep 17 00:00:00 2001 From: ntim Date: Thu, 17 Mar 2016 09:06:28 +0100 Subject: [PATCH 47/67] Retreived one light more than necessary. Former-commit-id: 6ee5b0f4a86210fcf4bf3ee96b369aff20c25720 --- libsrc/leddevice/LedDevicePhilipsHue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/leddevice/LedDevicePhilipsHue.cpp b/libsrc/leddevice/LedDevicePhilipsHue.cpp index 332176ad..20c347f8 100755 --- a/libsrc/leddevice/LedDevicePhilipsHue.cpp +++ b/libsrc/leddevice/LedDevicePhilipsHue.cpp @@ -263,7 +263,7 @@ void LedDevicePhilipsHue::saveStates(unsigned int nLights) { throw std::runtime_error("No lights found"); } // Loop over all children. - for (Json::ValueIterator it = json.begin(); it != json.end() && lightIds.size() <= nLights; it++) { + for (Json::ValueIterator it = json.begin(); it != json.end() && lightIds.size() < nLights; it++) { int lightId = atoi(it.key().asCString()); lightIds.push_back(lightId); std::cout << "LedDevicePhilipsHue::saveStates(nLights=" << nLights << "): found light with id " << lightId From 926f47fc1ac9c0784987cb2eac26042a6b34261b Mon Sep 17 00:00:00 2001 From: ntim Date: Sat, 19 Mar 2016 12:36:55 +0100 Subject: [PATCH 48/67] Added more precise outputs on failures as well as some additional checks. Former-commit-id: a0def586410d90abda002504d9c2ae88abc43088 --- libsrc/leddevice/LedDevicePhilipsHue.cpp | 30 ++++++++++++++++++++---- libsrc/leddevice/LedDevicePhilipsHue.h | 7 ++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/libsrc/leddevice/LedDevicePhilipsHue.cpp b/libsrc/leddevice/LedDevicePhilipsHue.cpp index 20c347f8..e638d5ab 100755 --- a/libsrc/leddevice/LedDevicePhilipsHue.cpp +++ b/libsrc/leddevice/LedDevicePhilipsHue.cpp @@ -216,7 +216,7 @@ int LedDevicePhilipsHue::switchOff() { } void LedDevicePhilipsHue::put(QString route, QString content) { - QString url = QString("http://%1/api/%2/%3").arg(host).arg(username).arg(route); + QString url = getUrl(route); // Perfrom request QNetworkRequest request(url); QNetworkReply* reply = manager->put(request, content.toLatin1()); @@ -228,7 +228,7 @@ void LedDevicePhilipsHue::put(QString route, QString content) { } QByteArray LedDevicePhilipsHue::get(QString route) { - QString url = QString("http://%1/api/%2/%3").arg(host).arg(username).arg(route); + QString url = getUrl(route); // Perfrom request QNetworkRequest request(url); QNetworkReply* reply = manager->get(request); @@ -249,6 +249,10 @@ QString LedDevicePhilipsHue::getRoute(unsigned int lightId) { return QString("lights/%1").arg(lightId); } +QString LedDevicePhilipsHue::getUrl(QString route) { + return QString("http://%1/api/%2/%3").arg(host).arg(username).arg(route); +} + void LedDevicePhilipsHue::saveStates(unsigned int nLights) { // Clear saved lamps. lights.clear(); @@ -257,10 +261,12 @@ void LedDevicePhilipsHue::saveStates(unsigned int nLights) { Json::FastWriter writer; // Read light ids if none have been supplied by the user. if (lightIds.size() != nLights) { + lightIds.clear(); + // QByteArray response = get("lights"); Json::Value json; if (!reader.parse(QString(response).toStdString(), json)) { - throw std::runtime_error("No lights found"); + throw std::runtime_error(("No lights found at " + getUrl("lights")).toStdString()); } // Loop over all children. for (Json::ValueIterator it = json.begin(); it != json.end() && lightIds.size() < nLights; it++) { @@ -269,6 +275,10 @@ void LedDevicePhilipsHue::saveStates(unsigned int nLights) { std::cout << "LedDevicePhilipsHue::saveStates(nLights=" << nLights << "): found light with id " << lightId << "." << std::endl; } + // Check if we found enough lights. + if (lightIds.size() != nLights) { + throw std::runtime_error(("Not enough lights found at " + getUrl("lights")).toStdString()); + } } // Iterate lights. for (unsigned int i = 0; i < nLights; i++) { @@ -278,12 +288,22 @@ void LedDevicePhilipsHue::saveStates(unsigned int nLights) { Json::Value json; if (!reader.parse(QString(response).toStdString(), json)) { // Error occured, break loop. - std::cerr << "LedDevicePhilipsHue::saveStates(nLights=" << nLights - << "): got invalid response from light with id " << lightIds.at(i) << "." << std::endl; + std::cerr << "LedDevicePhilipsHue::saveStates(nLights=" << nLights << "): got invalid response from light " + << getUrl(getRoute(lightIds.at(i))).toStdString() << "." << std::endl; break; } // Get state object values which are subject to change. Json::Value state(Json::objectValue); + if (!json.isMember("state")) { + std::cerr << "LedDevicePhilipsHue::saveStates(nLights=" << nLights << "): got no state for light from " + << getUrl(getRoute(lightIds.at(i))).toStdString() << std::endl; + break; + } + if (!json["state"].isMember("on")) { + std::cerr << "LedDevicePhilipsHue::saveStates(nLights=" << nLights << "): got no valid state from light " + << getUrl(getRoute(lightIds.at(i))).toStdString() << std::endl; + break; + } state["on"] = json["state"]["on"]; if (json["state"]["on"] == true) { state["xy"] = json["state"]["xy"]; diff --git a/libsrc/leddevice/LedDevicePhilipsHue.h b/libsrc/leddevice/LedDevicePhilipsHue.h index 61047062..5e5409b6 100755 --- a/libsrc/leddevice/LedDevicePhilipsHue.h +++ b/libsrc/leddevice/LedDevicePhilipsHue.h @@ -207,6 +207,13 @@ private: /// QString getRoute(unsigned int lightId); + /// + /// @param route + /// + /// @return the full URL of the request. + /// + QString getUrl(QString route); + /// /// Queries the status of all lights and saves it. /// From e0c3ece80d1455a722022b2f99a49c1aa7d2286d Mon Sep 17 00:00:00 2001 From: ntim Date: Sun, 20 Mar 2016 13:33:41 +0100 Subject: [PATCH 49/67] Deletion of qt network reply objects. Former-commit-id: 258badb680014a187d76d9183080ea3de6895692 --- libsrc/leddevice/LedDevicePhilipsHue.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libsrc/leddevice/LedDevicePhilipsHue.cpp b/libsrc/leddevice/LedDevicePhilipsHue.cpp index e638d5ab..eec1c824 100755 --- a/libsrc/leddevice/LedDevicePhilipsHue.cpp +++ b/libsrc/leddevice/LedDevicePhilipsHue.cpp @@ -225,6 +225,8 @@ void LedDevicePhilipsHue::put(QString route, QString content) { loop.connect(reply, SIGNAL(finished()), SLOT(quit())); // Go into the loop until the request is finished. loop.exec(); + // Free space. + reply->deleteLater(); } QByteArray LedDevicePhilipsHue::get(QString route) { @@ -238,7 +240,11 @@ QByteArray LedDevicePhilipsHue::get(QString route) { // Go into the loop until the request is finished. loop.exec(); // Read all data of the response. - return reply->readAll(); + QByteArray response = reply->readAll(); + // Free space. + reply->deleteLater(); + // Return response + return response; } QString LedDevicePhilipsHue::getStateRoute(unsigned int lightId) { From d2973ff20bd248591e5300432d2a4415c67b23de Mon Sep 17 00:00:00 2001 From: Mark Walker Date: Sun, 20 Mar 2016 21:22:19 -0700 Subject: [PATCH 50/67] Add ws281x driver parameter for PWM channel The RPi 2 and 3 have two PWM channels and 3 PWM pins available to the gpio header. BCM18 and BCM12 run on PWM channel 0. BCM13 runs on PWM channel 1. This change allows BCM13 to be used by allowing the PWM channel to be specified. Former-commit-id: 3693ab438c2b369e6307c262d32bba509409e5b9 --- libsrc/leddevice/LedDeviceFactory.cpp | 3 ++- libsrc/leddevice/LedDeviceWS281x.cpp | 39 +++++++++++++++------------ libsrc/leddevice/LedDeviceWS281x.h | 3 ++- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/libsrc/leddevice/LedDeviceFactory.cpp b/libsrc/leddevice/LedDeviceFactory.cpp index 49b197f6..e693ae7c 100755 --- a/libsrc/leddevice/LedDeviceFactory.cpp +++ b/libsrc/leddevice/LedDeviceFactory.cpp @@ -327,8 +327,9 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig) const int leds = deviceConfig.get("leds", 12).asInt(); const uint32_t freq = deviceConfig.get("freq", (Json::UInt)800000ul).asInt(); const int dmanum = deviceConfig.get("dmanum", 5).asInt(); + const int pwmchannel = deviceConfig.get("pwmchannel", 0).asInt(); - LedDeviceWS281x * ledDeviceWS281x = new LedDeviceWS281x(gpio, leds, freq, dmanum); + LedDeviceWS281x * ledDeviceWS281x = new LedDeviceWS281x(gpio, leds, freq, dmanum, pwmchannel); device = ledDeviceWS281x; } #endif diff --git a/libsrc/leddevice/LedDeviceWS281x.cpp b/libsrc/leddevice/LedDeviceWS281x.cpp index 10b5d2e0..3871b553 100644 --- a/libsrc/leddevice/LedDeviceWS281x.cpp +++ b/libsrc/leddevice/LedDeviceWS281x.cpp @@ -3,22 +3,27 @@ #include "LedDeviceWS281x.h" // Constructor -LedDeviceWS281x::LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, const int dmanum) +LedDeviceWS281x::LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, const int dmanum, const int pwmchannel) { initialized = false; led_string.freq = freq; led_string.dmanum = dmanum; - led_string.channel[0].gpionum = gpio; - led_string.channel[0].invert = 0; - led_string.channel[0].count = leds; - led_string.channel[0].brightness = 255; - led_string.channel[0].strip_type = WS2811_STRIP_RGB; + if (pwmchannel != 0 && pwmchannel != 1) { + std::cout << "WS281x: invalid PWM channel; must be 0 or 1." << std::endl; + throw -1; + } + chan = pwmchannel; + led_string.channel[chan].gpionum = gpio; + led_string.channel[chan].invert = 0; + led_string.channel[chan].count = leds; + led_string.channel[chan].brightness = 255; + led_string.channel[chan].strip_type = WS2811_STRIP_RGB; - led_string.channel[1].gpionum = 0; - led_string.channel[1].invert = 0; - led_string.channel[1].count = 0; - led_string.channel[1].brightness = 0; - led_string.channel[0].strip_type = WS2811_STRIP_RGB; + led_string.channel[!chan].gpionum = 0; + led_string.channel[!chan].invert = 0; + led_string.channel[!chan].count = 0; + led_string.channel[!chan].brightness = 0; + led_string.channel[!chan].strip_type = WS2811_STRIP_RGB; if (ws2811_init(&led_string) < 0) { std::cout << "Unable to initialize ws281x library." << std::endl; throw -1; @@ -35,12 +40,12 @@ int LedDeviceWS281x::write(const std::vector &ledValues) int idx = 0; for (const ColorRgb& color : ledValues) { - if (idx >= led_string.channel[0].count) + if (idx >= led_string.channel[chan].count) break; - led_string.channel[0].leds[idx++] = ((uint32_t)color.red << 16) + ((uint32_t)color.green << 8) + color.blue; + led_string.channel[chan].leds[idx++] = ((uint32_t)color.red << 16) + ((uint32_t)color.green << 8) + color.blue; } - while (idx < led_string.channel[0].count) - led_string.channel[0].leds[idx++] = 0; + while (idx < led_string.channel[chan].count) + led_string.channel[chan].leds[idx++] = 0; if (ws2811_render(&led_string)) return -1; @@ -57,8 +62,8 @@ int LedDeviceWS281x::switchOff() return -1; int idx = 0; - while (idx < led_string.channel[0].count) - led_string.channel[0].leds[idx++] = 0; + while (idx < led_string.channel[chan].count) + led_string.channel[chan].leds[idx++] = 0; if (ws2811_render(&led_string)) return -1; diff --git a/libsrc/leddevice/LedDeviceWS281x.h b/libsrc/leddevice/LedDeviceWS281x.h index 429a092f..61a58800 100644 --- a/libsrc/leddevice/LedDeviceWS281x.h +++ b/libsrc/leddevice/LedDeviceWS281x.h @@ -17,7 +17,7 @@ public: /// @param freq The target frequency for the data line, default is 800000 /// @param dmanum The DMA channel to use, default is 5 /// - LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, int dmanum); + LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, int dmanum, int pwmchannel); /// /// Destructor of the LedDevice, waits for DMA to complete and then cleans up @@ -37,6 +37,7 @@ public: private: ws2811_t led_string; + int chan; bool initialized; }; From 35b7707b3f862f922a12c91d2799b547b001f92f Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Mon, 21 Mar 2016 16:59:46 +0100 Subject: [PATCH 51/67] Update schema-temperature.json Former-commit-id: 3f5a96e0275e239ba0361905282b59a9bd4412d0 --- .../jsonserver/schema/schema-temperature.json | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/libsrc/jsonserver/schema/schema-temperature.json b/libsrc/jsonserver/schema/schema-temperature.json index 14ce465b..b7be1f4f 100644 --- a/libsrc/jsonserver/schema/schema-temperature.json +++ b/libsrc/jsonserver/schema/schema-temperature.json @@ -15,23 +15,16 @@ "type" : "string", "required" : false }, - "red" : { - "type" : "integer", - "required" : false, - "minimum": 0, - "maximum": 255 - }, - "green" : { - "type" : "integer", - "required" : false, - "minimum": 0, - "maximum": 255 - }, - "blue" : { - "type" : "integer", - "required" : false, - "minimum": 0, - "maximum": 255 + "correctionValues" : { + "type": "array", + "required": false, + "items" : { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "minItems": 3, + "maxItems": 3 } }, "additionalProperties": false From ef1f269c51832ab59cd351718d5f8419bba0f751 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Mon, 21 Mar 2016 17:00:01 +0100 Subject: [PATCH 52/67] Update schema-correction.json Former-commit-id: 223e5d183fd2ec83f61421aaa142bc86958fff6a --- .../jsonserver/schema/schema-correction.json | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/libsrc/jsonserver/schema/schema-correction.json b/libsrc/jsonserver/schema/schema-correction.json index 37bbee6f..ad7dbfca 100644 --- a/libsrc/jsonserver/schema/schema-correction.json +++ b/libsrc/jsonserver/schema/schema-correction.json @@ -15,23 +15,16 @@ "type" : "string", "required" : false }, - "red" : { - "type" : "integer", - "required" : false, - "minimum": 0, - "maximum": 255 - }, - "green" : { - "type" : "integer", - "required" : false, - "minimum": 0, - "maximum": 255 - }, - "blue" : { - "type" : "integer", - "required" : false, - "minimum": 0, - "maximum": 255 + "correctionValues" : { + "type": "array", + "required": false, + "items" : { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "minItems": 3, + "maxItems": 3 } }, "additionalProperties": false From 642de44c7c37ba1135afa914642f944c54fb50a5 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Mon, 21 Mar 2016 17:04:02 +0100 Subject: [PATCH 53/67] Update JsonClientConnection.cpp Former-commit-id: 53b8cf73df6f3cec49886169b870e5490828716b --- libsrc/jsonserver/JsonClientConnection.cpp | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index ca0cf46e..e6275ae6 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -392,6 +392,47 @@ void JsonClientConnection::handleServerInfoCommand(const Json::Value &) item["duration_ms"] = Json::Value::UInt(priorityInfo.timeoutTime_ms - now); } } + + // collect correction information + Json::Value & correctionArray = info["correction"]; + for (const std::string& correctionId : _hyperion->getCorrectionIds()) + { + const ColorCorrection * colorCorrection = _hyperion->getCorrection(correctionId); + if (colorCorrection == nullptr) + { + std::cerr << "Incorrect color correction id: " << correctionId << std::endl; + continue; + } + + Json::Value & correction = correctionArray.append(Json::Value()); + correction["id"] = correctionId; + + Json::Value & corrValues = correction["correctionValues"]; + corrValues.append(colorCorrection->_rgbCorrection.getcorrectionR()); + corrValues.append(colorCorrection->_rgbCorrection.getcorrectionG()); + corrValues.append(colorCorrection->_rgbCorrection.getcorrectionB()); + } + + // collect temperature correction information + Json::Value & temperatureArray = info["temperature"]; + for (const std::string& tempId : _hyperion->getTemperatureIds()) + { + const ColorCorrection * colorTemp = _hyperion->getTemperature(tempId); + if (colorTemp == nullptr) + { + std::cerr << "Incorrect color temperature correction id: " << tempId << std::endl; + continue; + } + + Json::Value & temperature = temperatureArray.append(Json::Value()); + temperature["id"] = tempId; + + Json::Value & tempValues = temperature["correctionValues"]; + tempValues.append(colorTemp->_rgbCorrection.getcorrectionR()); + tempValues.append(colorTemp->_rgbCorrection.getcorrectionG()); + tempValues.append(colorTemp->_rgbCorrection.getcorrectionB()); + } + // collect transform information Json::Value & transformArray = info["transform"]; From b46d231f75d3ad41e1cb3185f8405b89f4b02984 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Mon, 21 Mar 2016 17:07:02 +0100 Subject: [PATCH 54/67] Update JsonClientConnection.cpp Former-commit-id: fef896ef86f04901cf2227a0897dd9ea999325b7 --- libsrc/jsonserver/JsonClientConnection.cpp | 36 ++++++---------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index e6275ae6..d146b1c8 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -595,20 +595,12 @@ void JsonClientConnection::handleCorrectionCommand(const Json::Value &message) return; } - if (correction.isMember("red")) + if (correction.isMember("correctionValues")) { - colorCorrection->_rgbCorrection.setcorrectionR(correction["red"].asInt()); - } - - if (correction.isMember("green")) - { - colorCorrection->_rgbCorrection.setcorrectionG(correction["green"].asInt()); - } - - if (correction.isMember("blue")) - { - colorCorrection->_rgbCorrection.setcorrectionB(correction["blue"].asInt()); - } + const Json::Value & values = correction["correctionValues"]; + colorCorrection->_rgbCorrection.setcorrectionR(values[0u].asInt()); + colorCorrection->_rgbCorrection.setcorrectionG(values[1u].asInt()); + colorCorrection->_rgbCorrection.setcorrectionB(values[2u].asInt()); // commit the changes _hyperion->correctionsUpdated(); @@ -628,20 +620,12 @@ void JsonClientConnection::handleTemperatureCommand(const Json::Value &message) return; } - if (temperature.isMember("red")) + if (temperature.isMember("correctionValues")) { - colorTemperature->_rgbCorrection.setcorrectionR(temperature["red"].asInt()); - } - - if (temperature.isMember("green")) - { - colorTemperature->_rgbCorrection.setcorrectionG(temperature["green"].asInt()); - } - - if (temperature.isMember("blue")) - { - colorTemperature->_rgbCorrection.setcorrectionB(temperature["blue"].asInt()); - } + const Json::Value & values = temperature["correctionValues"]; + colorTemperature->_rgbCorrection.setcorrectionR(values[0u].asInt()); + colorTemperature->_rgbCorrection.setcorrectionG(values[1u].asInt()); + colorTemperature->_rgbCorrection.setcorrectionB(values[2u].asInt()); // commit the changes _hyperion->temperaturesUpdated(); From 0bafc4a3cc1989a16d789494cd11e6dd74291caf Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Mon, 21 Mar 2016 17:08:10 +0100 Subject: [PATCH 55/67] Create ColorCorrectionValues.h Former-commit-id: d765e8c7562d6eac5e03e939bd88c858c50597bb --- src/hyperion-remote/ColorCorrectionValues.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/hyperion-remote/ColorCorrectionValues.h diff --git a/src/hyperion-remote/ColorCorrectionValues.h b/src/hyperion-remote/ColorCorrectionValues.h new file mode 100644 index 00000000..0cd0e911 --- /dev/null +++ b/src/hyperion-remote/ColorCorrectionValues.h @@ -0,0 +1,12 @@ +#pragma once + +/// Simple structure to contain the values of a color transformation +struct ColorCorrectionValues +{ + /// The value for the red color-channel + int valueRed; + /// The value for the green color-channel + int valueGreen; + /// The value for the blue color-channel + int valueBlue; +}; From a15a680dc324ab3c914459449f968f56fbd92b03 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Mon, 21 Mar 2016 17:09:10 +0100 Subject: [PATCH 56/67] Update CustomParameter.h Former-commit-id: 99fa0c1a3d6321dc41f4fb1623aee5b364220a67 --- src/hyperion-remote/CustomParameter.h | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/hyperion-remote/CustomParameter.h b/src/hyperion-remote/CustomParameter.h index 4f336dd7..af1836a6 100644 --- a/src/hyperion-remote/CustomParameter.h +++ b/src/hyperion-remote/CustomParameter.h @@ -12,6 +12,7 @@ // hyperion-remote includes #include "ColorTransformValues.h" +#include "ColorCorrectionValues.h" /// Data parameter for a color typedef vlofgren::PODParameter> ColorParameter; @@ -22,6 +23,9 @@ typedef vlofgren::PODParameter ImageParameter; /// Data parameter for color transform values (list of three values) typedef vlofgren::PODParameter TransformParameter; +/// Data parameter for color correction values (list of three values) +typedef vlofgren::PODParameter CorrectionParameter; + namespace vlofgren { /// /// Translates a string (as passed on the commandline) to a vector of colors @@ -128,4 +132,33 @@ namespace vlofgren { return transform; } + + template<> + ColorCorrectionValues CorrectionParameter::validate(const std::string& s) throw (Parameter::ParameterRejected) + { + ColorCorrectionValues correction; + + // s should be split in 3 parts + // seperators are either a ',' or a space + QStringList components = QString(s.c_str()).split(" ", QString::SkipEmptyParts); + + if (components.size() == 3) + { + bool ok1, ok2, ok3; + correction.valueRed = components[0].toInt(&ok1); + correction.valueGreen = components[1].toInt(&ok2); + correction.valueBlue = components[2].toInt(&ok3); + + if (ok1 && ok2 && ok3) + { + return correction; + } + } + + std::stringstream errorMessage; + errorMessage << "Argument " << s << " can not be parsed to 3 integer values"; + throw Parameter::ParameterRejected(errorMessage.str()); + + return correction; + } } From 4836bfc863f70c4dfefde4a89bbd8be307eb552b Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Mon, 21 Mar 2016 17:10:01 +0100 Subject: [PATCH 57/67] Update JsonConnection.h Former-commit-id: 4a0983b135f8386ee4e0db81c044dbaa87e05c03 --- src/hyperion-remote/JsonConnection.h | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/hyperion-remote/JsonConnection.h b/src/hyperion-remote/JsonConnection.h index ccda9f1c..48455110 100644 --- a/src/hyperion-remote/JsonConnection.h +++ b/src/hyperion-remote/JsonConnection.h @@ -14,6 +14,7 @@ // hyperion-remote includes #include "ColorTransformValues.h" +#include "ColorCorrectionValues.h" /// /// Connection class to setup an connection to the hyperion server and execute commands @@ -113,14 +114,10 @@ public: /// @note Note that providing a NULL will leave the settings on the server unchanged /// /// @param correctionId The identifier of the correction to set - /// @param red The red correction value - /// @param green The green correction value - /// @param blue The blue correction value + /// @param correction The correction values void setCorrection( std::string * correctionId, - int * red, - int * green, - int * blue); + ColorCorrectionValues * correction); /// /// Set the color temperature of the leds @@ -128,14 +125,10 @@ public: /// @note Note that providing a NULL will leave the settings on the server unchanged /// /// @param temperatureId The identifier of the correction to set - /// @param red The red temperature value - /// @param green The green temperature value - /// @param blue The blue temperature value + /// @param temperature The temperature correction values void setTemperature( std::string * temperatureId, - int * red, - int * green, - int * blue); + ColorCorrectionValues * temperature); private: /// From 909112fbfb54fa433375932a0eae4a3c58c9561b Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Mon, 21 Mar 2016 17:13:46 +0100 Subject: [PATCH 58/67] Update JsonConnection.cpp Former-commit-id: 712db0e3d8e525353d62bd7dfc6e2dd708b09b85 --- src/hyperion-remote/JsonConnection.cpp | 48 +++++++++----------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/src/hyperion-remote/JsonConnection.cpp b/src/hyperion-remote/JsonConnection.cpp index 009647af..e00488e1 100644 --- a/src/hyperion-remote/JsonConnection.cpp +++ b/src/hyperion-remote/JsonConnection.cpp @@ -264,33 +264,26 @@ void JsonConnection::setTransform(std::string * transformId, double * saturation parseReply(reply); } -void JsonConnection::setCorrection(std::string * correctionId, int * red, int * green, int * blue) +void JsonConnection::setCorrection(std::string * correctionId, ColorCorrectionValues *correction) { std::cout << "Set color corrections" << std::endl; // create command Json::Value command; command["command"] = "correction"; - Json::Value & correction = command["correction"]; - + Json::Value & correct = command["correction"]; + if (correctionId != nullptr) { - correction["id"] = *correctionId; + correct["id"] = *correctionId; } - if (red != nullptr) + if (correction != nullptr) { - correction["red"] = *red; - } - - if (green != nullptr) - { - correction["green"] = *green; - } - - if (blue != nullptr) - { - correction["blue"] = *blue; + Json::Value & v = correction["correctionValues"]; + v.append(correction->valueRed); + v.append(correction->valueGreen); + v.append(correction->valueBlue); } // send command message @@ -300,33 +293,26 @@ void JsonConnection::setCorrection(std::string * correctionId, int * red, int * parseReply(reply); } -void JsonConnection::setTemperature(std::string * temperatureId, int * red, int * green, int * blue) +void JsonConnection::setTemperature(std::string * temperatureId, ColorCorrectionValues *temperature) { std::cout << "Set color temperature corrections" << std::endl; // create command Json::Value command; command["command"] = "temperature"; - Json::Value & temperature = command["temperature"]; + Json::Value & temp = command["temperature"]; if (temperatureId != nullptr) { - temperature["id"] = *temperatureId; + temp["id"] = *temperatureId; } - if (red != nullptr) + if (temperature != nullptr) { - temperature["red"] = *red; - } - - if (green != nullptr) - { - temperature["green"] = *green; - } - - if (blue != nullptr) - { - temperature["blue"] = *blue; + Json::Value & v = temp["correctionValues"]; + v.append(temperature->valueRed); + v.append(temperature->valueGreen); + v.append(temperature->valueBlue); } // send command message From 9987590e5e8652fac46ca33f499b04cfe255d8b1 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Mon, 21 Mar 2016 17:19:06 +0100 Subject: [PATCH 59/67] Update hyperion-remote.cpp Former-commit-id: 652cde0ee1ef0fed1492c63bf78787467f9dd2b6 --- src/hyperion-remote/hyperion-remote.cpp | 62 +++++++++---------------- 1 file changed, 22 insertions(+), 40 deletions(-) diff --git a/src/hyperion-remote/hyperion-remote.cpp b/src/hyperion-remote/hyperion-remote.cpp index b59d87e4..59fc6997 100644 --- a/src/hyperion-remote/hyperion-remote.cpp +++ b/src/hyperion-remote/hyperion-remote.cpp @@ -70,13 +70,9 @@ int main(int argc, char * argv[]) SwitchParameter<> & argPrint = parameters.add >(0x0, "print" , "Print the json input and output messages on stdout"); 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"); - IntParameter & argCorrR = parameters.add ('1', "correctionR" , "Specify the red channel correction"); - IntParameter & argCorrG = parameters.add ('2', "correctionG" , "Specify the green channel correction"); - IntParameter & argCorrB = parameters.add ('3', "correctionB" , "Specify the blue channel correction"); + 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"); - IntParameter & argTempR = parameters.add ('4', "tempR" , "Specify the red channel temperature correction"); - IntParameter & argTempG = parameters.add ('5', "tempG" , "Specify the red channel temperature correction"); - IntParameter & argTempB = parameters.add ('6', "tempB" , "Specify the red channel temperature correction"); + 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 argAddress.setDefault(defaultServerAddress.toStdString()); @@ -96,17 +92,15 @@ 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 colorCorrection = argCorrR.isSet() || argCorrG.isSet() || argCorrB.isSet(); - bool colorTemp = argTempR.isSet() || argTempG.isSet() || argTempB.isSet(); // check that exactly one command was given - int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorTransform, colorCorrection, colorTemp}); + int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorTransform, argCorrection.isSet(), argTemperature.isSet()}); if (commandCount != 1) { std::cerr << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:" << std::endl; std::cerr << " " << argColor.usageLine() << std::endl; std::cerr << " " << argImage.usageLine() << std::endl; - std::cerr << " " << argEffect.usageLine() << std::endl; + std::cerr << " " << argEffect.usageLine() << std::endl; std::cerr << " " << argServerInfo.usageLine() << std::endl; std::cerr << " " << argClear.usageLine() << std::endl; std::cerr << " " << argClearAll.usageLine() << std::endl; @@ -122,14 +116,10 @@ int main(int argc, char * argv[]) 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 << " " << argCorrR.usageLine() << std::endl; - std::cerr << " " << argCorrG.usageLine() << std::endl; - std::cerr << " " << argCorrB.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 << " " << argTempR.usageLine() << std::endl; - std::cerr << " " << argTempG.usageLine() << std::endl; - std::cerr << " " << argTempB.usageLine() << std::endl; + std::cerr << " " << argTemperature.usageLine() << std::endl; return 1; } @@ -183,43 +173,35 @@ int main(int argc, char * argv[]) argSaturation.isSet() ? &saturation : nullptr, argValue.isSet() ? &value : nullptr, argSaturationL.isSet() ? &saturationL : nullptr, - argLuminance.isSet() ? &luminance : nullptr, + argLuminance.isSet() ? &luminance : nullptr, argThreshold.isSet() ? &threshold : nullptr, argGamma.isSet() ? &gamma : nullptr, argBlacklevel.isSet() ? &blacklevel : nullptr, argWhitelevel.isSet() ? &whitelevel : nullptr); } - else if (colorCorrection) + else if (argCorrection.isSet()) { - std::string transId; - int red, green, blue; + std::string corrId; + ColorCorrectionValues correction; + + if (argIdC.isSet()) corrId = argIdC.getValue(); + if (argCorrection.isSet()) correction = argCorrection.getValue(); - if (argIdC.isSet()) transId = argId.getValue(); - if (argCorrR.isSet()) red = argCorrR.getValue(); - if (argCorrG.isSet()) green = argCorrG.getValue(); - if (argCorrB.isSet()) blue = argCorrB.getValue(); - connection.setCorrection( - argIdC.isSet() ? &transId : nullptr, - argCorrR.isSet() ? &red : nullptr, - argCorrG.isSet() ? &green : nullptr, - argCorrB.isSet() ? &blue : nullptr); + argIdC.isSet() ? &corrId : nullptr, + argCorrection.isSet() ? &correction : nullptr); } - else if (colorTemp) + else if (argTemperature.isSet()) { - std::string transId; - int red, green, blue; + std::string tempId; + ColorCorrectionValues temperature; - if (argIdT.isSet()) transId = argId.getValue(); - if (argTempR.isSet()) red = argTempR.getValue(); - if (argTempG.isSet()) green = argTempG.getValue(); - if (argTempB.isSet()) blue = argTempB.getValue(); + if (argIdT.isSet()) tempId = argIdT.getValue(); + if (argTemperature.isSet()) temperature = argTemperature.getValue(); connection.setCorrection( - argIdC.isSet() ? &transId : nullptr, - argTempR.isSet() ? &red : nullptr, - argTempG.isSet() ? &green : nullptr, - argTempB.isSet() ? &blue : nullptr); + argIdT.isSet() ? &tempId : nullptr, + argTemperature.isSet() ? &temperature : nullptr); } } catch (const std::runtime_error & e) From fa3b3388948e9a6d2aa58ac9762bdc953df3220f Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Mon, 21 Mar 2016 17:20:06 +0100 Subject: [PATCH 60/67] Update hyperion-remote.cpp Former-commit-id: 2ef2b5d21eda53e2286af8edf7200eb73f5ae3bf --- src/hyperion-remote/hyperion-remote.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hyperion-remote/hyperion-remote.cpp b/src/hyperion-remote/hyperion-remote.cpp index 59fc6997..3fd9549e 100644 --- a/src/hyperion-remote/hyperion-remote.cpp +++ b/src/hyperion-remote/hyperion-remote.cpp @@ -199,7 +199,7 @@ int main(int argc, char * argv[]) if (argIdT.isSet()) tempId = argIdT.getValue(); if (argTemperature.isSet()) temperature = argTemperature.getValue(); - connection.setCorrection( + connection.setTemperature( argIdT.isSet() ? &tempId : nullptr, argTemperature.isSet() ? &temperature : nullptr); } From 4a6a0ea9bd6db2501d2761747e6111be71ae6a7a Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Mon, 21 Mar 2016 17:21:24 +0100 Subject: [PATCH 61/67] Update hyperion.config.json Former-commit-id: 1b104a073df59cf87d3188ab3c1399943da81ece --- config/hyperion.config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/hyperion.config.json b/config/hyperion.config.json index 355ad7d7..86597162 100644 --- a/config/hyperion.config.json +++ b/config/hyperion.config.json @@ -13,7 +13,7 @@ "name" : "MyPi", "type" : "ws2801", "output" : "/dev/spidev0.0", - "rate" : 1000000, + "rate" : 250000, "colorOrder" : "rgb" }, @@ -82,7 +82,7 @@ { "saturationGain" : 1.0000, "luminanceGain" : 1.0000 - },` + }, "red" : { "threshold" : 0.0000, From 2d0eeb0a69685b54ddb4a71ae501b4d3a12a422a Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Mon, 21 Mar 2016 17:22:22 +0100 Subject: [PATCH 62/67] Update hyperion.config.json Former-commit-id: ababa8d21284fb7808c571c1db6c400c5bffa4a6 --- config/hyperion.config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/hyperion.config.json b/config/hyperion.config.json index 86597162..0b8c5d8c 100644 --- a/config/hyperion.config.json +++ b/config/hyperion.config.json @@ -13,7 +13,7 @@ "name" : "MyPi", "type" : "ws2801", "output" : "/dev/spidev0.0", - "rate" : 250000, + "rate" : 1000000, "colorOrder" : "rgb" }, From 7da3e83597551c599700c6e0bcb9611e51cff11b Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Mon, 21 Mar 2016 17:39:02 +0100 Subject: [PATCH 63/67] Update JsonConnection.cpp Former-commit-id: c701972ecddcd9655f0aa56b69301ad463f8dcb0 --- src/hyperion-remote/JsonConnection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hyperion-remote/JsonConnection.cpp b/src/hyperion-remote/JsonConnection.cpp index e00488e1..61367104 100644 --- a/src/hyperion-remote/JsonConnection.cpp +++ b/src/hyperion-remote/JsonConnection.cpp @@ -280,7 +280,7 @@ void JsonConnection::setCorrection(std::string * correctionId, ColorCorrectionVa if (correction != nullptr) { - Json::Value & v = correction["correctionValues"]; + Json::Value & v = correct["correctionValues"]; v.append(correction->valueRed); v.append(correction->valueGreen); v.append(correction->valueBlue); From 3c2682b626328c0af3ba74915610bac7cd52c5ec Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Mon, 21 Mar 2016 17:42:13 +0100 Subject: [PATCH 64/67] Update JsonClientConnection.cpp Former-commit-id: 5014c392b3c7629b6f02ead321621f7edc560680 --- libsrc/jsonserver/JsonClientConnection.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index d146b1c8..2d3cfa45 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -601,6 +601,7 @@ void JsonClientConnection::handleCorrectionCommand(const Json::Value &message) colorCorrection->_rgbCorrection.setcorrectionR(values[0u].asInt()); colorCorrection->_rgbCorrection.setcorrectionG(values[1u].asInt()); colorCorrection->_rgbCorrection.setcorrectionB(values[2u].asInt()); + } // commit the changes _hyperion->correctionsUpdated(); @@ -626,6 +627,7 @@ void JsonClientConnection::handleTemperatureCommand(const Json::Value &message) colorTemperature->_rgbCorrection.setcorrectionR(values[0u].asInt()); colorTemperature->_rgbCorrection.setcorrectionG(values[1u].asInt()); colorTemperature->_rgbCorrection.setcorrectionB(values[2u].asInt()); + } // commit the changes _hyperion->temperaturesUpdated(); From 2b7b8cd26483964d4534c4e5059ab9fcc248fabd Mon Sep 17 00:00:00 2001 From: tpmodding Date: Mon, 21 Mar 2016 23:23:41 +0100 Subject: [PATCH 65/67] Update create_oe_depedencies.sh Former-commit-id: be4c2091e59d2c150908e7836468676bfeed0aee --- bin/create_oe_depedencies.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/create_oe_depedencies.sh b/bin/create_oe_depedencies.sh index dd2883e4..194da7a8 100644 --- a/bin/create_oe_depedencies.sh +++ b/bin/create_oe_depedencies.sh @@ -23,5 +23,6 @@ tar --create --verbose --gzip --absolute-names --show-transformed-names --derefe "$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libXrender.so.1" \ "$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libXt.so.6" \ "./openelec/hyperiond.sh" \ + "./openelec/hyperion-v4l2.sh" \ "./openelec/hyperion-remote.sh" From fb7445b54583281a531ff8025aa4205fe61e907a Mon Sep 17 00:00:00 2001 From: brindosch Date: Tue, 22 Mar 2016 01:01:54 +0100 Subject: [PATCH 66/67] Update Former-commit-id: 3c6ac5d2f618cd7499c16bca950ff3d41f855318 --- CompileHowto.txt | 2 +- ISSUE_TEMPLATE | 2 +- bin/install_hyperion.sh | 62 +++++++++++++++++++++++---- bin/remove_hyperion.sh | 1 + libsrc/leddevice/LedDeviceFactory.cpp | 2 +- 5 files changed, 58 insertions(+), 11 deletions(-) diff --git a/CompileHowto.txt b/CompileHowto.txt index da8f38c9..0aa3f059 100644 --- a/CompileHowto.txt +++ b/CompileHowto.txt @@ -27,7 +27,7 @@ cd "$HYPERION_DIR/build" cmake -DCMAKE_BUILD_TYPE=Release -Wno-dev .. # run cmake to generate make files on the raspberry pi WITH PWM SUPPORT cmake -DENABLE_WS2812BPWM=ON -DENABLE_WS281XPWM=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev .. -# or if you are not compiling on the raspberry pi and need to disable the Dispmanx grabber and support for spi devices +# or if you are not compiling on the raspberry pi (e.g. OrangePi) and need to disable the Dispmanx grabber and support for spi devices cmake -DENABLE_DISPMANX=OFF -DENABLE_SPIDEV=OFF -DENABLE_X11=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev .. # as an alternative for the dispmanx grabber on non-rpi devices (e.g. cubox-i) you could try the framebuffer grabber cmake -DENABLE_DISPMANX=OFF -DENABLE_SPIDEV=OFF -DENABLE_FB=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev .. diff --git a/ISSUE_TEMPLATE b/ISSUE_TEMPLATE index 7b2f9f22..e8f12f0a 100644 --- a/ISSUE_TEMPLATE +++ b/ISSUE_TEMPLATE @@ -4,5 +4,5 @@ Please check the wiki in case your problem is already known/feature requested.** **1.** Used hardware and sofware (Wetek,RPi1,Rpi2,... Ubuntu 14.04(64bit),OSX,OpenELEC,OSMC,XBian,...) **2.** Your LED device and additional hardware (if used) (WS2801,APA102,WS2812B,... connected through (direct,arduino uno,...)) **3.** Please upload your Hyperion log to pastebin.com and insert the link. Have a look at the wiki how you get one. -**4.** Please upload your "Hyperion Configuration File" to www.jsoneditoronline.org and insert the link. +**4.** Please upload your "Hyperion Configuration File" to pastebin.com and insert the link. diff --git a/bin/install_hyperion.sh b/bin/install_hyperion.sh index 5bdc5c2a..40ae503a 100755 --- a/bin/install_hyperion.sh +++ b/bin/install_hyperion.sh @@ -4,8 +4,18 @@ # Make sure /sbin is on the path (for service to find sub scripts) PATH="/sbin:$PATH" +#Check which arguments are used +if [ "$1" = "HyperConInstall" ] || [ "$2" = "HyperConInstall" ]; then + HCInstall=1 +else HCInstall=0 +fi +if [ "$1" = "WS281X" ] || [ "$2" = "WS281X" ]; then + PWM=1 +else PWM=0 +fi + #Check if HyperCon is logged in as root -if [ $(id -u) != 0 ] && [ "$1" = "HyperConInstall" ]; then +if [ $(id -u) != 0 ] && [ $HCInstall -eq 1 ]; then echo '---> Critical Error: Please connect as user "root" through HyperCon' echo '---> We need admin privileges to install/update your Hyperion! -> abort' exit 1 @@ -78,7 +88,7 @@ if [ $OS_OPENELEC -ne 1 ]; then fi #Check, if dtparam=spi=on is in place (not for OPENELEC) -if [ $CPU_RPI -eq 1 ] && [ $OS_OPENELEC -ne 1 ]; then +if [ $PWM -ne 1 ] && [ $CPU_RPI -eq 1 ] && [ $OS_OPENELEC -ne 1 ]; then SPIOK=`grep '^\dtparam=spi=on' /boot/config.txt | wc -l` if [ $SPIOK -ne 1 ]; then echo '---> Raspberry Pi found, but SPI is not ready, we write "dtparam=spi=on" to /boot/config.txt' @@ -88,7 +98,7 @@ if [ $CPU_RPI -eq 1 ] && [ $OS_OPENELEC -ne 1 ]; then fi #Check, if dtparam=spi=on is in place (just for OPENELEC) -if [ $CPU_RPI -eq 1 ] && [ $OS_OPENELEC -eq 1 ]; then +if [ $PWM -ne 1 ] && [ $CPU_RPI -eq 1 ] && [ $OS_OPENELEC -eq 1 ]; then SPIOK=`grep '^\dtparam=spi=on' /flash/config.txt | wc -l` if [ $SPIOK -ne 1 ]; then mount -o remount,rw /flash @@ -98,6 +108,28 @@ if [ $CPU_RPI -eq 1 ] && [ $OS_OPENELEC -eq 1 ]; then REBOOTMESSAGE="echo Please reboot your OpenELEC, we inserted dtparam=spi=on to /flash/config.txt" fi fi + +#Check, if dtoverlay=pwm is in place (not for OPENELEC) +#if [ $PWM -eq 1 ] && [ $CPU_RPI -eq 1 ] && [ $OS_OPENELEC -ne 1 ]; then +# PWMOK=`grep '^\dtoverlay=pwm' /boot/config.txt | wc -l` +# if [ $PWMOK -ne 1 ]; then +# echo '---> Raspberry Pi found, but PWM is not ready, we write "dtoverlay=pwm" to /boot/config.txt' +# sed -i '$a dtoverlay=pwm' /boot/config.txt +# PWMREBOOTMESSAGE="echo Please reboot your Raspberry Pi, we inserted dtoverlay=pwm to /boot/config.txt" +# fi +#fi + +#Check, if dtoverlay=pwm is in place (just for OPENELEC) +if [ $PWM -eq 1 ] && [ $CPU_RPI -eq 1 ] && [ $OS_OPENELEC -eq 1 ]; then + PWMOK=`grep '^\dtoverlay=pwm' /flash/config.txt | wc -l` + if [ $PWMOK -ne 1 ]; then + mount -o remount,rw /flash + echo '---> Raspberry Pi with OpenELEC found, but PWM is not ready, we write "dtoverlay=pwm" to /flash/config.txt' + sed -i '$a dtoverlay=pwm' /flash/config.txt + mount -o remount,ro /flash + PWMREBOOTMESSAGE="echo Please reboot your OpenELEC, we inserted dtoverlay=pwm to /flash/config.txt" + fi +fi #Backup the .conf files, if present echo '---> Backup Hyperion configuration(s), if present' rm -f /tmp/*.json 2>/dev/null @@ -177,16 +209,29 @@ elif [ $OS_OPENELEC -eq 1 ]; then echo "/storage/hyperion/bin/hyperiond.sh /storage/.config/hyperion.config.json > /dev/null 2>&1 &" >> /storage/.config/autostart.sh chmod +x /storage/.config/autostart.sh fi + # only add hyperion-x11 to startup, if not found and x32x64 detected + if [ $CPU_X32X64 -eq 1 ] && [ `cat /storage/.config/autostart.sh 2>/dev/null | grep hyperion-x11 | wc -l` -eq 0 ]; then + echo '---> Adding Hyperion-x11 to OpenELEC autostart.sh' + echo "DISPLAY=:0.0 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/storage/hyperion/bin /storage/hyperion/bin/hyperion-x11 /dev/null 2>&1 &" >> /storage/.config/autostart.sh + fi elif [ $USE_SYSTEMD -eq 1 ]; then echo '---> Installing systemd script' #place startup script for systemd and activate #Problem with systemd to enable symlinks - Bug? Workaround cp -n (overwrite never) - #Bad workaround for Jessie users that used the official script for install + #Bad workaround for Jessie (systemd) users that used the official script for install update-rc.d -f hyperion remove 2>/dev/null rm /etc/init.d/hyperion 2>/dev/null cp -n /opt/hyperion/init.d/hyperion.systemd.sh /etc/systemd/system/hyperion.service systemctl -q enable hyperion.service - if [ $OS_OSMC -eq 1 ]; then + if [ $PWM -eq 1 ] && [ $OS_OSMC -eq 1 ]; then + echo '---> Modify systemd script for OSMC usage (PWM Support)' + # Wait until kodi is sarted (for xbmc checker) and FIX user in case it is wrong (need root for access to pwm!)! + sed -i '/After = mediacenter.service/d' /etc/systemd/system/hyperion.service + sed -i '/Unit/a After = mediacenter.service' /etc/systemd/system/hyperion.service + sed -i 's/User=osmc/User=root/g' /etc/systemd/system/hyperion.service + sed -i 's/Group=osmc/Group=root/g' /etc/systemd/system/hyperion.service + systemctl -q daemon-reload + elif [ $OS_OSMC -eq 1 ]; then echo '---> Modify systemd script for OSMC usage' # Wait until kodi is sarted (for xbmc checker) and replace user (for remote control through osmc) sed -i '/After = mediacenter.service/d' /etc/systemd/system/hyperion.service @@ -226,15 +271,16 @@ echo 'Please get a new HyperCon version to benefit from the latest features!' echo 'Create a new config file, if you encounter problems!' $HINTMESSAGE $REBOOTMESSAGE +$PWMREBOOTMESSAGE echo '*******************************************************************************' ## Force reboot and prevent prompt if spi is added during a HyperCon Install -if [ "$1" = "HyperConInstall" ] && [ $CPU_RPI -eq 1 ] && [ $SPIOK -ne 1 ]; then - echo "Rebooting now, we added dtparam=spi=on to config.txt" +if ( [ "$HCInstall" = "1" ] && [ "$CPU_RPI" = "1" ] ) && ( [ "$SPIOK" = "0" ] || [ "$PWMOK" = "0" ] ); then + echo "Rebooting now, we added dtparam=spi=on and/or dtoverlay=pwm to config.txt" reboot exit 0 fi #Prompt for reboot, if spi added to config.txt -if [ $CPU_RPI -eq 1 ] && [ $SPIOK -ne 1 ];then +if ( [ "$CPU_RPI" = "1" ] ) && ( [ "$SPIOK" = "0" ] || [ "$PWMOK" = "0" ] ); then while true do echo -n "---> Do you want to reboot your Raspberry Pi now? (y or n) :" diff --git a/bin/remove_hyperion.sh b/bin/remove_hyperion.sh index 1b56b84c..8ce5fd38 100644 --- a/bin/remove_hyperion.sh +++ b/bin/remove_hyperion.sh @@ -70,6 +70,7 @@ elif [ $OS_OPENELEC -eq 1 ]; then # Remove Hyperion from OpenELEC autostart.sh echo "---> Remove Hyperion from OpenELEC autostart.sh" sed -i "/hyperiond/d" /storage/.config/autostart.sh 2>/dev/null + sed -i "/hyperion-x11/d" /storage/.config/autostart.sh 2>/dev/null elif [ $USE_SYSTEMD -eq 1 ]; then # Delete and disable Hyperion systemd script echo '---> Delete and disable Hyperion systemd script' diff --git a/libsrc/leddevice/LedDeviceFactory.cpp b/libsrc/leddevice/LedDeviceFactory.cpp index e693ae7c..3c925e8d 100755 --- a/libsrc/leddevice/LedDeviceFactory.cpp +++ b/libsrc/leddevice/LedDeviceFactory.cpp @@ -180,7 +180,7 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig) device = deviceLightpack; } - else if (type == "multi-lightpack" || type == "multi_lightpack") + else if (type == "multi-lightpack") { LedDeviceMultiLightpack* deviceLightpack = new LedDeviceMultiLightpack(); deviceLightpack->open(); From 22819b65babc2c6a8814dc908119d0f1da7b6553 Mon Sep 17 00:00:00 2001 From: brindosch Date: Tue, 22 Mar 2016 01:49:26 +0100 Subject: [PATCH 67/67] Hyperion update to V1.01.0 Former-commit-id: 35d177b762308320686caddfe56e9c4b753a4fdd --- deploy/hyperion_rpi.tar.gz.REMOVED.git-id | 2 +- deploy/hyperion_wetek.tar.gz.REMOVED.git-id | 2 +- deploy/hyperion_x32x64.tar.gz.REMOVED.git-id | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deploy/hyperion_rpi.tar.gz.REMOVED.git-id b/deploy/hyperion_rpi.tar.gz.REMOVED.git-id index df62cd1b..59522dc2 100644 --- a/deploy/hyperion_rpi.tar.gz.REMOVED.git-id +++ b/deploy/hyperion_rpi.tar.gz.REMOVED.git-id @@ -1 +1 @@ -63bda72fdb3fb504564f067795f74e9b45eb99ba \ No newline at end of file +bc3bead4aa43a0f90fb15fb300e63eb6ba6885bf \ No newline at end of file diff --git a/deploy/hyperion_wetek.tar.gz.REMOVED.git-id b/deploy/hyperion_wetek.tar.gz.REMOVED.git-id index 9cc7dee0..e5d26a68 100644 --- a/deploy/hyperion_wetek.tar.gz.REMOVED.git-id +++ b/deploy/hyperion_wetek.tar.gz.REMOVED.git-id @@ -1 +1 @@ -03e78585af86a18889ecd1d8b910d76155608cd6 \ No newline at end of file +e3cbd5bb82a29a50ee85a2fab6a1a0d610938f37 \ No newline at end of file diff --git a/deploy/hyperion_x32x64.tar.gz.REMOVED.git-id b/deploy/hyperion_x32x64.tar.gz.REMOVED.git-id index d2485017..977b46b5 100644 --- a/deploy/hyperion_x32x64.tar.gz.REMOVED.git-id +++ b/deploy/hyperion_x32x64.tar.gz.REMOVED.git-id @@ -1 +1 @@ -9a00f3dc5684cab0fede56348df91c046634ff11 \ No newline at end of file +dc2a99908af86a6e3a2b81721bc69e7d614623c3 \ No newline at end of file