mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
implement optional color correction for V4L only (#267)
* remove color temperatire, its the same as color adjustment * remove temperature from schema * implement most part of v4l only colro settings, now hyperion update knows from which component the colors come * update configs * fix webui config write * reomve correction and temperature from hyperion-remote
This commit is contained in:
parent
d9c2a2d91a
commit
e889996ae7
@ -195,9 +195,11 @@ function requestSetSource(prio)
|
||||
websocket.send('{"command":"sourceselect", "tan":'+wsTan+', "priority" : '+prio+'}');
|
||||
}
|
||||
|
||||
function requestWriteConfig(config, create, overwrite)
|
||||
function requestWriteConfig(config)
|
||||
{
|
||||
var create = (typeof create !== 'undefined') ? create : false;
|
||||
var overwrite = (typeof overwrite !== 'undefined') ? overwrite : false;
|
||||
websocket.send('{"command":"config","subcommand":"setconfig", "tan":'+wsTan+', "config":'+JSON.stringify(config)+',"create":'+create+', "overwrite":'+overwrite+'}');
|
||||
var complete_config = parsedConfJSON;
|
||||
jQuery.each(config, function(i, val) {
|
||||
complete_config[i] = val;
|
||||
});
|
||||
websocket.send('{"command":"config","subcommand":"setconfig", "tan":'+wsTan+', "config":'+JSON.stringify(complete_config)+'}');
|
||||
}
|
||||
|
@ -28,21 +28,16 @@
|
||||
/// Color manipulation configuration used to tune the output colors to specific surroundings.
|
||||
/// The configuration contains a list of color-transforms. Each transform contains the
|
||||
/// following fields:
|
||||
/// * 'channelAdjustment_enable' : true/false enables/disables this channelAdjustment section
|
||||
/// * 'channelAdjustment_enable' : true/false enables/disables this channelAdjustment section
|
||||
/// * 'channelAdjustment_v4l_only' : if enabled and set to true, then channelAdjustment is only for v4l devices
|
||||
/// * 'channelAdjustment'
|
||||
/// * 'id' : The unique identifier of the channel adjustments (eg 'device_1')
|
||||
/// * 'leds' : The indices (or index ranges) of the leds to which this channel adjustment applies
|
||||
/// (eg '0-5, 9, 11, 12-17'). The indices are zero based.
|
||||
/// * 'pureRed'/'pureGreen'/'pureBlue' : The manipulation in the Red-Green-Blue color domain with the
|
||||
/// following tuning parameters for each channel:
|
||||
/// * 'temperature_enable' : true/false enables/disables this temperature section
|
||||
/// * 'temperature'
|
||||
/// * 'id' : The unique identifier of the temperature (eg 'device_1')
|
||||
/// * 'leds' : The indices (or index ranges) of the leds to which this temperature applies
|
||||
/// (eg '0-5, 9, 11, 12-17'). The indices are zero based.
|
||||
/// * 'red'/'green'/'blue' : The temperature manipulation in the Red-Green-Blue color domain with the
|
||||
/// following tuning parameters for each channel:
|
||||
/// * 'transform_enable' : true/false enables/disables this transform section
|
||||
/// * 'transform_enable' : true/false enables/disables this transform section
|
||||
/// * 'transform_v4l_only' : if enabled and set to true, then transform is only for v4l devices
|
||||
/// * 'transform'
|
||||
/// * 'id' : The unique identifier of the color transformation (eg 'device_1')
|
||||
/// * 'leds' : The indices (or index ranges) of the leds to which this color transform applies
|
||||
@ -60,6 +55,7 @@
|
||||
"color" :
|
||||
{
|
||||
"channelAdjustment_enable" : true,
|
||||
"channelAdjustment_v4l_only" : true,
|
||||
"channelAdjustment" :
|
||||
[
|
||||
{
|
||||
@ -85,21 +81,8 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"temperature_enable" : true,
|
||||
"temperature" :
|
||||
[
|
||||
{
|
||||
"id" : "default",
|
||||
"leds" : "*",
|
||||
"correctionValues" :
|
||||
{
|
||||
"red" : 255,
|
||||
"green" : 255,
|
||||
"blue" : 255
|
||||
}
|
||||
}
|
||||
],
|
||||
"transform_enable" : true,
|
||||
"transform_v4l_only" : true,
|
||||
"transform" :
|
||||
[
|
||||
{
|
||||
|
@ -16,6 +16,7 @@
|
||||
"color" :
|
||||
{
|
||||
"channelAdjustment_enable" : true,
|
||||
"channelAdjustment_v4l_only" : true,
|
||||
"channelAdjustment" :
|
||||
[
|
||||
{
|
||||
@ -41,21 +42,8 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"temperature_enable" : true,
|
||||
"temperature" :
|
||||
[
|
||||
{
|
||||
"id" : "default",
|
||||
"leds" : "*",
|
||||
"correctionValues" :
|
||||
{
|
||||
"red" : 255,
|
||||
"green" : 255,
|
||||
"blue" : 255
|
||||
}
|
||||
}
|
||||
],
|
||||
"transform_enable" : true,
|
||||
"transform_v4l_only" : true,
|
||||
"transform" :
|
||||
[
|
||||
{
|
||||
|
@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// STL includes
|
||||
#include <string>
|
||||
|
||||
// Utils includes
|
||||
#include <utils/RgbChannelAdjustment.h>
|
||||
|
||||
class ColorCorrection
|
||||
{
|
||||
public:
|
||||
|
||||
/// Unique identifier for this color correction
|
||||
std::string _id;
|
||||
|
||||
/// The RGB correction
|
||||
RgbChannelAdjustment _rgbCorrection;
|
||||
};
|
@ -52,6 +52,7 @@ protected:
|
||||
virtual void kodiOff();
|
||||
virtual void kodiPause();
|
||||
|
||||
void setColors(const std::vector<ColorRgb> &ledColors, const int timeout_ms);
|
||||
std::string _grabberName;
|
||||
|
||||
/// Pointer to Hyperion for writing led values
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <hyperion/LedString.h>
|
||||
#include <hyperion/PriorityMuxer.h>
|
||||
#include <hyperion/ColorTransform.h>
|
||||
#include <hyperion/ColorCorrection.h>
|
||||
#include <hyperion/ColorAdjustment.h>
|
||||
#include <hyperion/MessageForwarder.h>
|
||||
#include <hyperion/ComponentRegister.h>
|
||||
@ -42,10 +41,8 @@ class EffectEngine;
|
||||
class HsvTransform;
|
||||
class HslTransform;
|
||||
class RgbChannelTransform;
|
||||
class RgbChannelCorrection;
|
||||
class RgbChannelAdjustment;
|
||||
class MultiColorTransform;
|
||||
class MultiColorCorrection;
|
||||
class MultiColorAdjustment;
|
||||
class KODIVideoChecker;
|
||||
///
|
||||
@ -189,20 +186,14 @@ public slots:
|
||||
/// @param[in] ledColors The colors to write to the leds
|
||||
/// @param[in] timeout_ms The time the leds are set to the given colors [ms]
|
||||
///
|
||||
void setColors(int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms, bool clearEffects = true);
|
||||
void setColors(int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms, bool clearEffects = true, hyperion::Components component=hyperion::COMP_INVALID);
|
||||
|
||||
///
|
||||
/// Returns the list with unique transform identifiers
|
||||
/// @return The list with transform identifiers
|
||||
///
|
||||
const std::vector<std::string> & getTransformIds() const;
|
||||
|
||||
///
|
||||
/// Returns the list with unique correction identifiers
|
||||
/// @return The list with correction identifiers
|
||||
///
|
||||
const std::vector<std::string> & getTemperatureIds() const;
|
||||
|
||||
|
||||
///
|
||||
/// Returns the list with unique adjustment identifiers
|
||||
/// @return The list with adjustment identifiers
|
||||
@ -214,19 +205,13 @@ public slots:
|
||||
/// @return The transform with the given identifier (or nullptr if the identifier does not exist)
|
||||
///
|
||||
ColorTransform * getTransform(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 the ColorAdjustment with the given identifier
|
||||
/// @return The adjustment with the given identifier (or nullptr if the identifier does not exist)
|
||||
///
|
||||
ColorAdjustment * getAdjustment(const std::string& id);
|
||||
|
||||
|
||||
///
|
||||
/// Returns MessageForwarder Object
|
||||
/// @return instance of message forwarder object
|
||||
@ -235,12 +220,6 @@ public slots:
|
||||
|
||||
/// 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();
|
||||
|
||||
/// Tell Hyperion that the corrections have changed and the leds need to be updated
|
||||
void temperaturesUpdated();
|
||||
|
||||
/// Tell Hyperion that the corrections have changed and the leds need to be updated
|
||||
void adjustmentsUpdated();
|
||||
@ -286,10 +265,8 @@ public:
|
||||
static LedString createLedStringClone(const QJsonValue & ledsConfig, const ColorOrder deviceOrder);
|
||||
|
||||
static MultiColorTransform * createLedColorsTransform(const unsigned ledCnt, const QJsonObject & colorTransformConfig);
|
||||
static MultiColorCorrection * createLedColorsTemperature(const unsigned ledCnt, const QJsonObject & colorTemperatureConfig);
|
||||
static MultiColorAdjustment * createLedColorsAdjustment(const unsigned ledCnt, const QJsonObject & colorAdjustmentConfig);
|
||||
static ColorTransform * createColorTransform(const QJsonObject & transformConfig);
|
||||
static ColorCorrection * createColorCorrection(const QJsonObject & correctionConfig);
|
||||
static ColorAdjustment * createColorAdjustment(const QJsonObject & adjustmentConfig);
|
||||
static HsvTransform * createHsvTransform(const QJsonObject & hsvConfig);
|
||||
static HslTransform * createHslTransform(const QJsonObject & hslConfig);
|
||||
@ -340,10 +317,7 @@ private:
|
||||
|
||||
/// The transformation from raw colors to led colors
|
||||
MultiColorTransform * _raw2ledTransform;
|
||||
|
||||
/// The temperature from raw colors to led colors
|
||||
MultiColorCorrection * _raw2ledTemperature;
|
||||
|
||||
|
||||
/// The adjustment from raw colors to led colors
|
||||
MultiColorAdjustment * _raw2ledAdjustment;
|
||||
|
||||
@ -383,15 +357,18 @@ private:
|
||||
/// register of input sources and it's prio channel
|
||||
PriorityRegister _priorityRegister;
|
||||
|
||||
/// flag for v4l color correction
|
||||
bool _colorAdjustmentV4Lonly;
|
||||
|
||||
/// flag for v4l color correction
|
||||
bool _colorTransformV4Lonly;
|
||||
|
||||
/// flag for color transform enable
|
||||
bool _transformEnabled;
|
||||
|
||||
/// flag for color adjustment enable
|
||||
bool _adjustmentEnabled;
|
||||
|
||||
/// flag for color temperature enable
|
||||
bool _temperatureEnabled;
|
||||
|
||||
/// flag indicates state for autoselection of input source
|
||||
bool _sourceAutoSelectEnabled;
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
// Utils includes
|
||||
#include <utils/ColorRgb.h>
|
||||
#include <utils/Components.h>
|
||||
|
||||
///
|
||||
/// The PriorityMuxer handles the priority channels. Led values input is written to the priority map
|
||||
@ -32,6 +33,7 @@ public:
|
||||
int64_t timeoutTime_ms;
|
||||
/// The colors for each led of the channel
|
||||
std::vector<ColorRgb> ledColors;
|
||||
hyperion::Components componentId;
|
||||
};
|
||||
|
||||
/// The lowest possible priority, which is used when no priority channels are active
|
||||
@ -89,7 +91,7 @@ public:
|
||||
/// @param[in] ledColors The led colors of the priority channel
|
||||
/// @param[in] timeoutTime_ms The absolute timeout time of the channel
|
||||
///
|
||||
void setInput(const int priority, const std::vector<ColorRgb>& ledColors, const int64_t timeoutTime_ms=-1);
|
||||
void setInput(const int priority, const std::vector<ColorRgb>& ledColors, const int64_t timeoutTime_ms=-1, hyperion::Components component=hyperion::COMP_INVALID);
|
||||
|
||||
///
|
||||
/// Clears the specified priority channel
|
||||
|
@ -16,7 +16,9 @@ enum Components
|
||||
COMP_UDPLISTENER,
|
||||
COMP_BOBLIGHTSERVER,
|
||||
COMP_GRABBER,
|
||||
COMP_V4L
|
||||
COMP_V4L,
|
||||
COMP_COLOR,
|
||||
COMP_EFFECT
|
||||
};
|
||||
|
||||
inline const char* componentToString(Components c)
|
||||
@ -30,7 +32,9 @@ inline const char* componentToString(Components c)
|
||||
case COMP_UDPLISTENER: return "UDP listener";
|
||||
case COMP_BOBLIGHTSERVER:return "Boblight server";
|
||||
case COMP_GRABBER: return "Framegrabber";
|
||||
case COMP_V4L: return "V4l Capture device";
|
||||
case COMP_V4L: return "V4L capture device";
|
||||
case COMP_COLOR: return "solid color";
|
||||
case COMP_EFFECT: return "effect";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
@ -47,6 +51,8 @@ inline const char* componentToIdString(Components c)
|
||||
case COMP_BOBLIGHTSERVER:return "BOBLIGHTSERVER";
|
||||
case COMP_GRABBER: return "GRABBER";
|
||||
case COMP_V4L: return "V4L";
|
||||
case COMP_COLOR: return "COLOR";
|
||||
case COMP_EFFECT: return "EFFECT";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
@ -62,6 +68,8 @@ inline Components stringToComponent(QString component)
|
||||
if (component == "BOBLIGHTSERVER")return COMP_BOBLIGHTSERVER;
|
||||
if (component == "GRABBER") return COMP_GRABBER;
|
||||
if (component == "V4L") return COMP_V4L;
|
||||
if (component == "COLOR") return COMP_COLOR;
|
||||
if (component == "EFFECT") return COMP_EFFECT;
|
||||
|
||||
return COMP_INVALID;
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ void BoblightClientConnection::handleMessage(const QString & message)
|
||||
// send current color values to hyperion if this is the last led assuming leds values are send in order of id
|
||||
if ((ledIndex == _ledColors.size() -1) && _priority < 255)
|
||||
{
|
||||
_hyperion->setColors(_priority, _ledColors, -1);
|
||||
_hyperion->setColors(_priority, _ledColors, -1, hyperion::COMP_BOBLIGHTSERVER);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -203,7 +203,7 @@ void BoblightClientConnection::handleMessage(const QString & message)
|
||||
// send current color values to hyperion
|
||||
if (_priority < 255)
|
||||
{
|
||||
_hyperion->setColors(_priority, _ledColors, -1);
|
||||
_hyperion->setColors(_priority, _ledColors, -1, hyperion::COMP_BOBLIGHTSERVER);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ PyObject* Effect::wrapSetColor(PyObject *self, PyObject *args)
|
||||
if (PyArg_ParseTuple(args, "bbb", &color.red, &color.green, &color.blue))
|
||||
{
|
||||
std::fill(effect->_colors.begin(), effect->_colors.end(), color);
|
||||
effect->setColors(effect->_priority, effect->_colors, timeout, false);
|
||||
effect->setColors(effect->_priority, effect->_colors, timeout, false, hyperion::COMP_EFFECT);
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
else
|
||||
@ -282,7 +282,7 @@ PyObject* Effect::wrapSetColor(PyObject *self, PyObject *args)
|
||||
{
|
||||
char * data = PyByteArray_AS_STRING(bytearray);
|
||||
memcpy(effect->_colors.data(), data, length);
|
||||
effect->setColors(effect->_priority, effect->_colors, timeout, false);
|
||||
effect->setColors(effect->_priority, effect->_colors, timeout, false, hyperion::COMP_EFFECT);
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
else
|
||||
@ -352,7 +352,7 @@ PyObject* Effect::wrapSetImage(PyObject *self, PyObject *args)
|
||||
memcpy(image.memptr(), data, length);
|
||||
|
||||
effect->_imageProcessor->process(image, effect->_colors);
|
||||
effect->setColors(effect->_priority, effect->_colors, timeout, false);
|
||||
effect->setColors(effect->_priority, effect->_colors, timeout, false, hyperion::COMP_EFFECT);
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
else
|
||||
@ -428,7 +428,7 @@ PyObject* Effect::wrapImageShow(PyObject *self, PyObject *args)
|
||||
|
||||
memcpy(image.memptr(), binaryImage.data(), binaryImage.size());
|
||||
effect->_imageProcessor->process(image, effect->_colors);
|
||||
effect->setColors(effect->_priority, effect->_colors, timeout, false);
|
||||
effect->setColors(effect->_priority, effect->_colors, timeout, false, hyperion::COMP_EFFECT);
|
||||
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
// Hyperion includes
|
||||
#include <hyperion/ImageProcessor.h>
|
||||
#include <utils/Components.h>
|
||||
|
||||
class Effect : public QThread
|
||||
{
|
||||
@ -42,7 +43,7 @@ public slots:
|
||||
signals:
|
||||
void effectFinished(Effect * effect);
|
||||
|
||||
void setColors(int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms, bool clearEffects);
|
||||
void setColors(int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms, bool clearEffects, hyperion::Components component);
|
||||
|
||||
private slots:
|
||||
void effectFinished();
|
||||
|
@ -13,6 +13,7 @@
|
||||
// hyperion util includes
|
||||
#include <utils/jsonschema/QJsonSchemaChecker.h>
|
||||
#include <utils/FileUtils.h>
|
||||
#include <utils/Components.h>
|
||||
|
||||
// effect engine includes
|
||||
#include <effectengine/EffectEngine.h>
|
||||
@ -28,6 +29,7 @@ EffectEngine::EffectEngine(Hyperion * hyperion, const QJsonObject & jsonEffectCo
|
||||
{
|
||||
Q_INIT_RESOURCE(EffectEngine);
|
||||
qRegisterMetaType<std::vector<ColorRgb>>("std::vector<ColorRgb>");
|
||||
qRegisterMetaType<hyperion::Components>("hyperion::Components");
|
||||
|
||||
// connect the Hyperion channel clear feedback
|
||||
connect(_hyperion, SIGNAL(channelCleared(int)), this, SLOT(channelCleared(int)));
|
||||
@ -272,7 +274,7 @@ int EffectEngine::runEffectScript(const QString &script, const QString &name, co
|
||||
|
||||
// create the effect
|
||||
Effect * effect = new Effect(_mainThreadState, priority, timeout, script, name, args);
|
||||
connect(effect, SIGNAL(setColors(int,std::vector<ColorRgb>,int,bool)), _hyperion, SLOT(setColors(int,std::vector<ColorRgb>,int,bool)), Qt::QueuedConnection);
|
||||
connect(effect, SIGNAL(setColors(int,std::vector<ColorRgb>,int,bool,hyperion::Components)), _hyperion, SLOT(setColors(int,std::vector<ColorRgb>,int,bool,hyperion::Components)), Qt::QueuedConnection);
|
||||
connect(effect, SIGNAL(effectFinished(Effect*)), this, SLOT(effectFinished(Effect*)));
|
||||
_activeEffects.push_back(effect);
|
||||
|
||||
|
@ -47,7 +47,7 @@ void AmlogicWrapper::action()
|
||||
}
|
||||
|
||||
_processor->process(_image, _ledColors);
|
||||
_hyperion->setColors(_priority, _ledColors, _timeout_ms);
|
||||
setColors(_ledColors, _timeout_ms);
|
||||
}
|
||||
|
||||
void AmlogicWrapper::setVideoMode(const VideoMode mode)
|
||||
|
@ -43,7 +43,7 @@ void DispmanxWrapper::action()
|
||||
}
|
||||
|
||||
_processor->process(_image, _ledColors);
|
||||
_hyperion->setColors(_priority, _ledColors, _timeout_ms);
|
||||
setColors(_ledColors, _timeout_ms);
|
||||
}
|
||||
|
||||
void DispmanxWrapper::kodiPlay()
|
||||
|
@ -37,7 +37,7 @@ void FramebufferWrapper::action()
|
||||
}
|
||||
|
||||
_processor->process(_image, _ledColors);
|
||||
_hyperion->setColors(_priority, _ledColors, _timeout_ms);
|
||||
setColors(_ledColors, _timeout_ms);
|
||||
}
|
||||
|
||||
void FramebufferWrapper::setVideoMode(const VideoMode mode)
|
||||
|
@ -37,7 +37,7 @@ void OsxWrapper::action()
|
||||
}
|
||||
|
||||
_processor->process(_image, _ledColors);
|
||||
_hyperion->setColors(_priority, _ledColors, _timeout_ms);
|
||||
setColors(_ledColors, _timeout_ms);
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,6 +35,7 @@ V4L2Wrapper::V4L2Wrapper(const std::string &device,
|
||||
// register the image type
|
||||
qRegisterMetaType<Image<ColorRgb>>("Image<ColorRgb>");
|
||||
qRegisterMetaType<std::vector<ColorRgb>>("std::vector<ColorRgb>");
|
||||
qRegisterMetaType<hyperion::Components>("hyperion::Components");
|
||||
|
||||
// Handle the image in the captured thread using a direct connection
|
||||
QObject::connect(&_grabber, SIGNAL(newFrame(Image<ColorRgb>)), this, SLOT(newFrame(Image<ColorRgb>)), Qt::DirectConnection);
|
||||
@ -88,7 +89,7 @@ void V4L2Wrapper::newFrame(const Image<ColorRgb> &image)
|
||||
|
||||
// process the new image
|
||||
_processor->process(image, _ledColors);
|
||||
_hyperion->setColors(_priority, _ledColors, _timeout_ms);
|
||||
setColors(_ledColors, _timeout_ms);
|
||||
}
|
||||
|
||||
void V4L2Wrapper::readError(const char* err)
|
||||
|
@ -70,7 +70,7 @@ void X11Wrapper::action()
|
||||
}
|
||||
|
||||
_processor->process(_image, _ledColors);
|
||||
_hyperion->setColors(_priority, _ledColors, _timeout_ms);
|
||||
setColors(_ledColors, _timeout_ms);
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,7 +20,6 @@ SET(Hyperion_HEADERS
|
||||
${CURRENT_HEADER_DIR}/PriorityMuxer.h
|
||||
|
||||
${CURRENT_SOURCE_DIR}/MultiColorTransform.h
|
||||
${CURRENT_SOURCE_DIR}/MultiColorCorrection.h
|
||||
${CURRENT_SOURCE_DIR}/MultiColorAdjustment.h
|
||||
${CURRENT_HEADER_DIR}/MessageForwarder.h
|
||||
)
|
||||
@ -34,7 +33,6 @@ SET(Hyperion_SOURCES
|
||||
|
||||
${CURRENT_SOURCE_DIR}/ImageToLedsMap.cpp
|
||||
${CURRENT_SOURCE_DIR}/MultiColorTransform.cpp
|
||||
${CURRENT_SOURCE_DIR}/MultiColorCorrection.cpp
|
||||
${CURRENT_SOURCE_DIR}/MultiColorAdjustment.cpp
|
||||
${CURRENT_SOURCE_DIR}/LinearColorSmoothing.cpp
|
||||
${CURRENT_SOURCE_DIR}/MessageForwarder.cpp
|
||||
|
@ -18,9 +18,10 @@ GrabberWrapper::GrabberWrapper(std::string grabberName, const int priority, hype
|
||||
|
||||
_forward = _hyperion->getForwarder()->protoForwardingEnabled();
|
||||
_hyperion->getComponentRegister().componentStateChanged(hyperion::COMP_BLACKBORDER, _processor->blackBorderDetectorEnabled());
|
||||
qRegisterMetaType<hyperion::Components>("hyperion::Components");
|
||||
|
||||
connect(_hyperion, SIGNAL(componentStateChanged(hyperion::Components,bool)), this, SLOT(componentStateChanged(hyperion::Components,bool)));
|
||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(action()));
|
||||
|
||||
}
|
||||
|
||||
GrabberWrapper::~GrabberWrapper()
|
||||
@ -116,3 +117,8 @@ void GrabberWrapper::setGrabbingMode(const GrabbingMode mode)
|
||||
}
|
||||
}
|
||||
|
||||
void GrabberWrapper::setColors(const std::vector<ColorRgb> &ledColors, const int timeout_ms)
|
||||
{
|
||||
_hyperion->setColors(_priority, ledColors, timeout_ms, true, _grabberComponentId);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include <hyperion/Hyperion.h>
|
||||
#include <hyperion/ImageProcessorFactory.h>
|
||||
#include <hyperion/ColorTransform.h>
|
||||
#include <hyperion/ColorCorrection.h>
|
||||
#include <hyperion/ColorAdjustment.h>
|
||||
|
||||
// Leddevice includes
|
||||
@ -28,7 +27,6 @@
|
||||
#include <leddevice/LedDeviceFactory.h>
|
||||
|
||||
#include "MultiColorTransform.h"
|
||||
#include "MultiColorCorrection.h"
|
||||
#include "MultiColorAdjustment.h"
|
||||
#include "LinearColorSmoothing.h"
|
||||
|
||||
@ -90,23 +88,6 @@ ColorTransform * Hyperion::createColorTransform(const QJsonObject & transformCon
|
||||
}
|
||||
|
||||
|
||||
ColorCorrection * Hyperion::createColorCorrection(const QJsonObject & correctionConfig)
|
||||
{
|
||||
const std::string id = correctionConfig["id"].toString("default").toStdString();
|
||||
|
||||
RgbChannelAdjustment * rgbCorrection = createRgbChannelCorrection(correctionConfig["correctionValues"].toObject());
|
||||
|
||||
ColorCorrection * correction = new ColorCorrection();
|
||||
correction->_id = id;
|
||||
correction->_rgbCorrection = *rgbCorrection;
|
||||
|
||||
// Cleanup the allocated individual transforms
|
||||
delete rgbCorrection;
|
||||
|
||||
return correction;
|
||||
}
|
||||
|
||||
|
||||
ColorAdjustment * Hyperion::createColorAdjustment(const QJsonObject & adjustmentConfig)
|
||||
{
|
||||
const std::string id = adjustmentConfig["id"].toString("default").toStdString();
|
||||
@ -205,83 +186,6 @@ MultiColorTransform * Hyperion::createLedColorsTransform(const unsigned ledCnt,
|
||||
return transform;
|
||||
}
|
||||
|
||||
MultiColorCorrection * Hyperion::createLedColorsTemperature(const unsigned ledCnt, const QJsonObject & colorConfig)
|
||||
{
|
||||
// Create the result, the corrections are added to this
|
||||
MultiColorCorrection * correction = new MultiColorCorrection(ledCnt);
|
||||
Logger * log = Logger::getInstance("Core");
|
||||
|
||||
const QString jsonKey = colorConfig.contains("temperature") ? "temperature" : "correction";
|
||||
const QJsonValue correctionConfig = colorConfig[jsonKey];
|
||||
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.isObject())
|
||||
{
|
||||
ColorCorrection * colorCorrection = createColorCorrection(correctionConfig.toObject());
|
||||
correction->addCorrection(colorCorrection);
|
||||
correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1);
|
||||
}
|
||||
else if (correctionConfig.isArray())
|
||||
{
|
||||
const QRegExp overallExp("([0-9]+(\\-[0-9]+)?)(,[ ]*([0-9]+(\\-[0-9]+)?))*");
|
||||
|
||||
const QJsonArray & correctionConfigArray = correctionConfig.toArray();
|
||||
for (signed i = 0; i < correctionConfigArray.size(); ++i)
|
||||
{
|
||||
const QJsonObject & config = correctionConfigArray.at(i).toObject();
|
||||
ColorCorrection * colorCorrection = createColorCorrection(config);
|
||||
correction->addCorrection(colorCorrection);
|
||||
|
||||
const QString ledIndicesStr = config["leds"].toString("").trimmed();
|
||||
if (ledIndicesStr.compare("*") == 0)
|
||||
{
|
||||
// Special case for indices '*' => all leds
|
||||
correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1);
|
||||
Info(log, "ColorTemperature '%s' => [0; %d]", colorCorrection->_id.c_str(), ledCnt-1);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!overallExp.exactMatch(ledIndicesStr))
|
||||
{
|
||||
Error(log, "Given led indices %d not correct format: %s", i, ledIndicesStr.toStdString().c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
const QStringList ledIndexList = ledIndicesStr.split(",");
|
||||
for (int i=0; i<ledIndexList.size(); ++i) {
|
||||
if (i > 0)
|
||||
{
|
||||
ss << ", ";
|
||||
}
|
||||
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);
|
||||
ss << startInd << "-" << endInd;
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = ledIndexList[i].toInt();
|
||||
correction->setCorrectionForLed(colorCorrection->_id, index, index);
|
||||
ss << index;
|
||||
}
|
||||
}
|
||||
Info(log, "ColorTemperature '%s' => [%s]", colorCorrection->_id.c_str(), ss.str().c_str());
|
||||
}
|
||||
}
|
||||
return correction;
|
||||
}
|
||||
|
||||
|
||||
MultiColorAdjustment * Hyperion::createLedColorsAdjustment(const unsigned ledCnt, const QJsonObject & colorConfig)
|
||||
{
|
||||
// Create the result, the transforms are added to this
|
||||
@ -385,16 +289,6 @@ RgbChannelTransform* Hyperion::createRgbChannelTransform(const QJsonObject& colo
|
||||
return transform;
|
||||
}
|
||||
|
||||
RgbChannelAdjustment* Hyperion::createRgbChannelCorrection(const QJsonObject& colorConfig)
|
||||
{
|
||||
const int varR = colorConfig["red"].toInt(255);
|
||||
const int varG = colorConfig["green"].toInt(255);
|
||||
const int varB = colorConfig["blue"].toInt(255);
|
||||
|
||||
RgbChannelAdjustment* correction = new RgbChannelAdjustment(varR, varG, varB);
|
||||
return correction;
|
||||
}
|
||||
|
||||
RgbChannelAdjustment* Hyperion::createRgbChannelAdjustment(const QJsonObject& colorConfig, const RgbChannel color)
|
||||
{
|
||||
int varR=0, varG=0, varB=0;
|
||||
@ -628,7 +522,6 @@ Hyperion::Hyperion(const Json::Value &jsonConfig, const QJsonObject &qjsonConfig
|
||||
, _ledStringClone(createLedStringClone(qjsonConfig["leds"], createColorOrder(qjsonConfig["device"].toObject())))
|
||||
, _muxer(_ledString.leds().size())
|
||||
, _raw2ledTransform(createLedColorsTransform(_ledString.leds().size(), qjsonConfig["color"].toObject()))
|
||||
, _raw2ledTemperature(createLedColorsTemperature(_ledString.leds().size(), qjsonConfig["color"].toObject()))
|
||||
, _raw2ledAdjustment(createLedColorsAdjustment(_ledString.leds().size(), qjsonConfig["color"].toObject()))
|
||||
, _effectEngine(nullptr)
|
||||
, _messageForwarder(createMessageForwarder(qjsonConfig["forwarder"].toObject()))
|
||||
@ -638,6 +531,8 @@ Hyperion::Hyperion(const Json::Value &jsonConfig, const QJsonObject &qjsonConfig
|
||||
, _timer()
|
||||
, _log(Logger::getInstance("Core"))
|
||||
, _hwLedCount(_ledString.leds().size())
|
||||
, _colorAdjustmentV4Lonly(false)
|
||||
, _colorTransformV4Lonly(false)
|
||||
, _sourceAutoSelectEnabled(true)
|
||||
, _configHash()
|
||||
, _ledGridSize(getLedLayoutGridSize(qjsonConfig["leds"]))
|
||||
@ -648,10 +543,6 @@ Hyperion::Hyperion(const Json::Value &jsonConfig, const QJsonObject &qjsonConfig
|
||||
{
|
||||
throw std::runtime_error("Color adjustment incorrectly set");
|
||||
}
|
||||
if (!_raw2ledTemperature->verifyCorrections())
|
||||
{
|
||||
throw std::runtime_error("Color temperature incorrectly set");
|
||||
}
|
||||
if (!_raw2ledTransform->verifyTransforms())
|
||||
{
|
||||
throw std::runtime_error("Color transformation incorrectly set");
|
||||
@ -660,11 +551,15 @@ Hyperion::Hyperion(const Json::Value &jsonConfig, const QJsonObject &qjsonConfig
|
||||
const QJsonObject& color = qjsonConfig["color"].toObject();
|
||||
_transformEnabled = color["transform_enable"].toBool(true);
|
||||
_adjustmentEnabled = color["channelAdjustment_enable"].toBool(true);
|
||||
_temperatureEnabled = color["temperature_enable"].toBool(true);
|
||||
|
||||
_colorTransformV4Lonly = color["transform_v4l_only"].toBool(false);
|
||||
_colorAdjustmentV4Lonly = color["channelAdjustment_v4l_only"].toBool(false);
|
||||
|
||||
InfoIf(!_transformEnabled , _log, "Color transformation disabled" );
|
||||
InfoIf(!_adjustmentEnabled , _log, "Color adjustment disabled" );
|
||||
InfoIf(!_temperatureEnabled, _log, "Color temperature disabled" );
|
||||
|
||||
InfoIf(_colorTransformV4Lonly , _log, "Color transformation for v4l inputs only" );
|
||||
InfoIf(_colorAdjustmentV4Lonly , _log, "Color adjustment for v4l inputs only" );
|
||||
|
||||
// initialize the image processor factory
|
||||
ImageProcessorFactory::getInstance().init(
|
||||
@ -709,7 +604,6 @@ Hyperion::~Hyperion()
|
||||
delete _effectEngine;
|
||||
delete _device;
|
||||
delete _raw2ledTransform;
|
||||
delete _raw2ledTemperature;
|
||||
delete _raw2ledAdjustment;
|
||||
delete _messageForwarder;
|
||||
}
|
||||
@ -807,10 +701,10 @@ void Hyperion::setColor(int priority, const ColorRgb &color, const int timeout_m
|
||||
std::vector<ColorRgb> ledColors(_ledString.leds().size(), color);
|
||||
|
||||
// set colors
|
||||
setColors(priority, ledColors, timeout_ms, clearEffects);
|
||||
setColors(priority, ledColors, timeout_ms, clearEffects, hyperion::COMP_COLOR);
|
||||
}
|
||||
|
||||
void Hyperion::setColors(int priority, const std::vector<ColorRgb>& ledColors, const int timeout_ms, bool clearEffects)
|
||||
void Hyperion::setColors(int priority, const std::vector<ColorRgb>& ledColors, const int timeout_ms, bool clearEffects, hyperion::Components component)
|
||||
{
|
||||
// clear effects if this call does not come from an effect
|
||||
if (clearEffects)
|
||||
@ -821,11 +715,11 @@ void Hyperion::setColors(int priority, const std::vector<ColorRgb>& ledColors, c
|
||||
if (timeout_ms > 0)
|
||||
{
|
||||
const uint64_t timeoutTime = QDateTime::currentMSecsSinceEpoch() + timeout_ms;
|
||||
_muxer.setInput(priority, ledColors, timeoutTime);
|
||||
_muxer.setInput(priority, ledColors, timeoutTime, component);
|
||||
}
|
||||
else
|
||||
{
|
||||
_muxer.setInput(priority, ledColors);
|
||||
_muxer.setInput(priority, ledColors, -1, component);
|
||||
}
|
||||
|
||||
if (! _sourceAutoSelectEnabled || priority == _muxer.getCurrentPriority())
|
||||
@ -839,11 +733,6 @@ const std::vector<std::string> & Hyperion::getTransformIds() const
|
||||
return _raw2ledTransform->getTransformIds();
|
||||
}
|
||||
|
||||
const std::vector<std::string> & Hyperion::getTemperatureIds() const
|
||||
{
|
||||
return _raw2ledTemperature->getCorrectionIds();
|
||||
}
|
||||
|
||||
const std::vector<std::string> & Hyperion::getAdjustmentIds() const
|
||||
{
|
||||
return _raw2ledAdjustment->getAdjustmentIds();
|
||||
@ -854,11 +743,6 @@ ColorTransform * Hyperion::getTransform(const std::string& id)
|
||||
return _raw2ledTransform->getTransform(id);
|
||||
}
|
||||
|
||||
ColorCorrection * Hyperion::getTemperature(const std::string& id)
|
||||
{
|
||||
return _raw2ledTemperature->getCorrection(id);
|
||||
}
|
||||
|
||||
ColorAdjustment * Hyperion::getAdjustment(const std::string& id)
|
||||
{
|
||||
return _raw2ledAdjustment->getAdjustment(id);
|
||||
@ -869,16 +753,6 @@ void Hyperion::transformsUpdated()
|
||||
update();
|
||||
}
|
||||
|
||||
void Hyperion::correctionsUpdated()
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
void Hyperion::temperaturesUpdated()
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
void Hyperion::adjustmentsUpdated()
|
||||
{
|
||||
update();
|
||||
@ -962,11 +836,14 @@ void Hyperion::update()
|
||||
_ledBuffer.reserve(_hwLedCount);
|
||||
_ledBuffer = priorityInfo.ledColors;
|
||||
|
||||
// Apply the correction and the transform to each led and color-channel
|
||||
// Avoid applying correction, the same task is performed by adjustment
|
||||
if (_transformEnabled) _raw2ledTransform->applyTransform(_ledBuffer);
|
||||
if (_adjustmentEnabled) _raw2ledAdjustment->applyAdjustment(_ledBuffer);
|
||||
if (_temperatureEnabled) _raw2ledTemperature->applyCorrection(_ledBuffer);
|
||||
if ( _transformEnabled && (!_colorTransformV4Lonly || priorityInfo.componentId == hyperion::COMP_V4L) )
|
||||
{
|
||||
_raw2ledTransform->applyTransform(_ledBuffer);
|
||||
}
|
||||
if ( _adjustmentEnabled && (!_colorAdjustmentV4Lonly || priorityInfo.componentId == hyperion::COMP_V4L) )
|
||||
{
|
||||
_raw2ledAdjustment->applyAdjustment(_ledBuffer);
|
||||
}
|
||||
|
||||
// init colororder vector, if empty
|
||||
if (_ledStringColorOrder.empty())
|
||||
|
@ -1,92 +0,0 @@
|
||||
|
||||
// STL includes
|
||||
#include <cassert>
|
||||
|
||||
// Hyperion includes
|
||||
#include <utils/Logger.h>
|
||||
#include "MultiColorCorrection.h"
|
||||
|
||||
MultiColorCorrection::MultiColorCorrection(const unsigned ledCnt) :
|
||||
_ledCorrections(ledCnt, nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
MultiColorCorrection::~MultiColorCorrection()
|
||||
{
|
||||
// Clean up all the correctinos
|
||||
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
|
||||
{
|
||||
for (unsigned iLed=0; iLed<_ledCorrections.size(); ++iLed)
|
||||
{
|
||||
if (_ledCorrections[iLed] == nullptr)
|
||||
{
|
||||
Warning(Logger::getInstance("ColorCorrect"), "No adjustment set for %d", iLed);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::vector<std::string> & MultiColorCorrection::getCorrectionIds()
|
||||
{
|
||||
return _correctionIds;
|
||||
}
|
||||
|
||||
ColorCorrection* MultiColorCorrection::getCorrection(const std::string& id)
|
||||
{
|
||||
// Iterate through the unique corrections until we find the one with the given id
|
||||
for (ColorCorrection * correction : _correction)
|
||||
{
|
||||
if (correction->_id == id)
|
||||
{
|
||||
return correction;
|
||||
}
|
||||
}
|
||||
|
||||
// The ColorCorrection was not found
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void MultiColorCorrection::applyCorrection(std::vector<ColorRgb>& ledColors)
|
||||
{
|
||||
const size_t itCnt = std::min(_ledCorrections.size(), ledColors.size());
|
||||
for (size_t i=0; i<itCnt; ++i)
|
||||
{
|
||||
ColorCorrection * correction = _ledCorrections[i];
|
||||
if (correction == nullptr)
|
||||
{
|
||||
// No correction set for this led (do nothing)
|
||||
continue;
|
||||
}
|
||||
ColorRgb& color = ledColors[i];
|
||||
|
||||
color.red = correction->_rgbCorrection.adjustmentR(color.red);
|
||||
color.green = correction->_rgbCorrection.adjustmentG(color.green);
|
||||
color.blue = correction->_rgbCorrection.adjustmentB(color.blue);
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// STL includes
|
||||
#include <vector>
|
||||
|
||||
// Utils includes
|
||||
#include <utils/ColorRgb.h>
|
||||
|
||||
// Hyperion includes
|
||||
#include <hyperion/ColorCorrection.h>
|
||||
|
||||
///
|
||||
/// 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
|
||||
{
|
||||
public:
|
||||
MultiColorCorrection(const unsigned ledCnt);
|
||||
~MultiColorCorrection();
|
||||
|
||||
/**
|
||||
* Adds a new ColorCorrection to this MultiColorCorrection
|
||||
*
|
||||
* @param Correction The new ColorCorrection (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 ColorCorrection
|
||||
///
|
||||
/// @return The list with unique id's of the ColorCorrections
|
||||
const std::vector<std::string> & getCorrectionIds();
|
||||
|
||||
///
|
||||
/// Returns the pointer to the ColorCorrection with the given id
|
||||
///
|
||||
/// @param id The identifier of the ColorCorrection
|
||||
///
|
||||
/// @return The ColorCorrection 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 ledColors The list with led colors
|
||||
///
|
||||
void applyCorrection(std::vector<ColorRgb>& ledColors);
|
||||
|
||||
private:
|
||||
/// List with Correction ids
|
||||
std::vector<std::string> _correctionIds;
|
||||
|
||||
/// List with unique ColorCorrections
|
||||
std::vector<ColorCorrection*> _correction;
|
||||
|
||||
/// List with a pointer to the ColorCorrection for each individual led
|
||||
std::vector<ColorCorrection*> _ledCorrections;
|
||||
};
|
@ -48,13 +48,13 @@ const PriorityMuxer::InputInfo& PriorityMuxer::getInputInfo(const int priority)
|
||||
return elemIt.value();
|
||||
}
|
||||
|
||||
void PriorityMuxer::setInput(const int priority, const std::vector<ColorRgb>& ledColors, const int64_t timeoutTime_ms)
|
||||
void PriorityMuxer::setInput(const int priority, const std::vector<ColorRgb>& ledColors, const int64_t timeoutTime_ms, hyperion::Components component)
|
||||
{
|
||||
InputInfo& input = _activeInputs[priority];
|
||||
input.priority = priority;
|
||||
input.timeoutTime_ms = timeoutTime_ms;
|
||||
input.ledColors = ledColors;
|
||||
|
||||
input.componentId = component;
|
||||
_currentPriority = std::min(_currentPriority, priority);
|
||||
}
|
||||
|
||||
|
@ -67,13 +67,20 @@
|
||||
"channelAdjustment_enable" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"default" : true,
|
||||
"propertyOrder" : 1
|
||||
},
|
||||
"channelAdjustment_v4l_only" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"default" : false,
|
||||
"propertyOrder" : 2
|
||||
},
|
||||
"channelAdjustment" :
|
||||
{
|
||||
"type" : "array",
|
||||
"required" : true,
|
||||
"propertyOrder" : 2,
|
||||
"propertyOrder" : 3,
|
||||
"items" :
|
||||
{
|
||||
"type" : "object",
|
||||
@ -184,74 +191,23 @@
|
||||
"additionalProperties" : false
|
||||
}
|
||||
},
|
||||
"temperature_enable" :
|
||||
{
|
||||
"type" : "boolean"
|
||||
},
|
||||
"temperature" :
|
||||
{
|
||||
"type" : "array",
|
||||
"required" : true,
|
||||
"items" :
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : true,
|
||||
"properties" :
|
||||
{
|
||||
"id" :
|
||||
{
|
||||
"type" : "string",
|
||||
"required" : true
|
||||
},
|
||||
"leds" :
|
||||
{
|
||||
"type" : "string",
|
||||
"required" : true
|
||||
},
|
||||
"correctionValues" :
|
||||
{
|
||||
"type":"object",
|
||||
"required" : true,
|
||||
"properties":
|
||||
{
|
||||
"red" :
|
||||
{
|
||||
"type": "integer",
|
||||
"required" : true,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"green" :
|
||||
{
|
||||
"type": "integer",
|
||||
"required" : true,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"blue" :
|
||||
{
|
||||
"type": "integer",
|
||||
"required" : true,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
}
|
||||
},
|
||||
"transform_enable" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"propertyOrder" : 3
|
||||
"default" : true,
|
||||
"propertyOrder" : 4
|
||||
},
|
||||
"transform_v4l_only" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"default" : false,
|
||||
"propertyOrder" : 5
|
||||
},
|
||||
"transform" :
|
||||
{
|
||||
"type" : "array",
|
||||
"required" : true,
|
||||
"propertyOrder" : 4,
|
||||
"propertyOrder" : 6,
|
||||
"items" :
|
||||
{
|
||||
"type" : "object",
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include <hyperion/ImageProcessor.h>
|
||||
#include <hyperion/MessageForwarder.h>
|
||||
#include <hyperion/ColorTransform.h>
|
||||
#include <hyperion/ColorCorrection.h>
|
||||
#include <hyperion/ColorAdjustment.h>
|
||||
#include <utils/ColorRgb.h>
|
||||
#include <leddevice/LedDevice.h>
|
||||
@ -291,8 +290,6 @@ void JsonClientConnection::handleMessage(const QString& messageString)
|
||||
handleClearallCommand(message, command, tan);
|
||||
else if (command == "transform")
|
||||
handleTransformCommand(message, command, tan);
|
||||
else if (command == "temperature")
|
||||
handleTemperatureCommand(message, command, tan);
|
||||
else if (command == "adjustment")
|
||||
handleAdjustmentCommand(message, command, tan);
|
||||
else if (command == "sourceselect")
|
||||
@ -492,34 +489,9 @@ void JsonClientConnection::handleServerInfoCommand(const QJsonObject&, const QSt
|
||||
item["owner"] = QString::fromStdString(entry.first);
|
||||
priorities.append(item);
|
||||
}
|
||||
|
||||
|
||||
info["priorities"] = priorities;
|
||||
|
||||
// collect temperature correction information
|
||||
QJsonArray temperatureArray;
|
||||
for (const std::string& tempId : _hyperion->getTemperatureIds())
|
||||
{
|
||||
const ColorCorrection * colorTemp = _hyperion->getTemperature(tempId);
|
||||
if (colorTemp == nullptr)
|
||||
{
|
||||
Error(_log, "Incorrect color temperature correction id: %s", tempId.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
QJsonObject temperature;
|
||||
temperature["id"] = QString::fromStdString(tempId);
|
||||
|
||||
QJsonArray tempValues;
|
||||
tempValues.append(colorTemp->_rgbCorrection.getAdjustmentR());
|
||||
tempValues.append(colorTemp->_rgbCorrection.getAdjustmentG());
|
||||
tempValues.append(colorTemp->_rgbCorrection.getAdjustmentB());
|
||||
temperature.insert("correctionValues", tempValues);
|
||||
temperatureArray.append(temperature);
|
||||
}
|
||||
|
||||
info["temperature"] = temperatureArray;
|
||||
|
||||
|
||||
// collect transform information
|
||||
QJsonArray transformArray;
|
||||
for (const std::string& transformId : _hyperion->getTransformIds())
|
||||
@ -849,32 +821,6 @@ void JsonClientConnection::handleTransformCommand(const QJsonObject& message, co
|
||||
}
|
||||
|
||||
|
||||
void JsonClientConnection::handleTemperatureCommand(const QJsonObject& message, const QString& command, const int tan)
|
||||
{
|
||||
const QJsonObject & temperature = message["temperature"].toObject();
|
||||
|
||||
const QString tempId = temperature["id"].toString(QString::fromStdString(_hyperion->getTemperatureIds().front()));
|
||||
ColorCorrection * colorTemperature = _hyperion->getTemperature(tempId.toStdString());
|
||||
if (colorTemperature == nullptr)
|
||||
{
|
||||
Warning(_log, "Incorrect temperature identifier: %s", tempId.toStdString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (temperature.contains("correctionValues"))
|
||||
{
|
||||
const QJsonArray & values = temperature["correctionValues"].toArray();
|
||||
colorTemperature->_rgbCorrection.setAdjustmentR(values[0u].toInt());
|
||||
colorTemperature->_rgbCorrection.setAdjustmentG(values[1u].toInt());
|
||||
colorTemperature->_rgbCorrection.setAdjustmentB(values[2u].toInt());
|
||||
}
|
||||
|
||||
// commit the changes
|
||||
_hyperion->temperaturesUpdated();
|
||||
|
||||
sendSuccessReply(command, tan);
|
||||
}
|
||||
|
||||
void JsonClientConnection::handleAdjustmentCommand(const QJsonObject& message, const QString& command, const int tan)
|
||||
{
|
||||
const QJsonObject & adjustment = message["adjustment"].toObject();
|
||||
|
@ -116,14 +116,7 @@ private:
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleTransformCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON Temperature message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleTemperatureCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON Adjustment message
|
||||
///
|
||||
|
@ -130,6 +130,6 @@ void UDPListener::processTheDatagram(const QByteArray * datagram)
|
||||
rgb.blue = datagram->at(ledIndex*3+2);
|
||||
}
|
||||
|
||||
_hyperion->setColors(_priority, _ledColors, _timeout, -1);
|
||||
_hyperion->setColors(_priority, _ledColors, _timeout, -1, hyperion::COMP_UDPLISTENER);
|
||||
|
||||
}
|
||||
|
@ -377,64 +377,6 @@ void JsonConnection::setTransform(const QString &transformId,
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::setCorrection(QString &correctionId, const QColor & correction)
|
||||
{
|
||||
std::cout << "Set color corrections" << std::endl;
|
||||
|
||||
// create command
|
||||
Json::Value command;
|
||||
command["command"] = "correction";
|
||||
Json::Value & correct = command["correction"];
|
||||
|
||||
if (!correctionId.isNull())
|
||||
{
|
||||
correct["id"] = correctionId.toStdString();
|
||||
}
|
||||
|
||||
if (correction.isValid())
|
||||
{
|
||||
Json::Value & v = correct["correctionValues"];
|
||||
v.append(correction.red());
|
||||
v.append(correction.green());
|
||||
v.append(correction.blue());
|
||||
}
|
||||
|
||||
// send command message
|
||||
Json::Value reply = sendMessage(command);
|
||||
|
||||
// parse reply message
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::setTemperature(const QString &temperatureId, const QColor & temperature)
|
||||
{
|
||||
std::cout << "Set color temperature corrections" << std::endl;
|
||||
|
||||
// create command
|
||||
Json::Value command;
|
||||
command["command"] = "temperature";
|
||||
Json::Value & temp = command["temperature"];
|
||||
|
||||
if (!temperatureId.isNull())
|
||||
{
|
||||
temp["id"] = temperatureId.toStdString();
|
||||
}
|
||||
|
||||
if (temperature.isValid())
|
||||
{
|
||||
Json::Value & v = temp["correctionValues"];
|
||||
v.append(temperature.red());
|
||||
v.append(temperature.green());
|
||||
v.append(temperature.blue());
|
||||
}
|
||||
|
||||
// send command message
|
||||
Json::Value reply = sendMessage(command);
|
||||
|
||||
// parse reply message
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::setAdjustment(const QString &adjustmentId,
|
||||
const QColor & redAdjustment,
|
||||
const QColor & greenAdjustment,
|
||||
|
@ -140,28 +140,6 @@ public:
|
||||
QColor gamma,
|
||||
QColor blacklevel,
|
||||
QColor 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 correction The correction values
|
||||
void setCorrection(
|
||||
QString &correctionId,
|
||||
const QColor & correction);
|
||||
|
||||
///
|
||||
/// 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 temperature The temperature correction values
|
||||
void setTemperature(
|
||||
const QString & temperatureId,
|
||||
const QColor & temperature);
|
||||
|
||||
///
|
||||
/// Set the color adjustment of the leds
|
||||
|
@ -79,10 +79,6 @@ int main(int argc, char * argv[])
|
||||
ColorOption & argWhitelevel = parser.add<ColorOption> ('w', "whitelevel", "!DEPRECATED! Will be removed soon! Set the whitelevel of the leds (requires colors in hex format as RRGGBB which are normally between 0.0 and 1.0)");
|
||||
BooleanOption & argPrint = parser.add<BooleanOption>(0x0, "print" , "Print the json input and output messages on stdout");
|
||||
BooleanOption & argHelp = parser.add<BooleanOption>('h', "help" , "Show this help message and exit");
|
||||
Option & argIdC = parser.add<Option> ('y', "qualifier-c" , "!DEPRECATED! Will be removed soon! Identifier(qualifier) of the correction to set");
|
||||
ColorOption & argCorrection = parser.add<ColorOption> ('Y', "correction" , "!DEPRECATED! Will be removed soon! Set the correction of the leds (requires colors in hex format as RRGGBB)");
|
||||
Option & argIdT = parser.add<Option> ('z', "qualifier-t" , "Identifier(qualifier) of the temperature correction to set");
|
||||
ColorOption & argTemperature = parser.add<ColorOption> ('Z', "temperature" , "Set the temperature correction of the leds (requires colors in hex format as RRGGBB)");
|
||||
Option & argIdA = parser.add<Option> ('j', "qualifier-a" , "Identifier(qualifier) of the adjustment to set");
|
||||
ColorOption & argRAdjust = parser.add<ColorOption> ('R', "redAdjustment" , "Set the adjustment of the red color (requires colors in hex format as RRGGBB)");
|
||||
ColorOption & argGAdjust = parser.add<ColorOption> ('G', "greenAdjustment", "Set the adjustment of the green color (requires colors in hex format as RRGGBB)");
|
||||
@ -106,7 +102,7 @@ int main(int argc, char * argv[])
|
||||
// check if at least one of the available color transforms is set
|
||||
bool colorTransform = parser.isSet(argSaturation) || parser.isSet(argValue) || parser.isSet(argSaturationL) || parser.isSet(argLuminance) || parser.isSet(argLuminanceMin) || parser.isSet(argThreshold) || parser.isSet(argGamma) || parser.isSet(argBlacklevel) || parser.isSet(argWhitelevel);
|
||||
bool colorAdjust = parser.isSet(argRAdjust) || parser.isSet(argGAdjust) || parser.isSet(argBAdjust);
|
||||
bool colorModding = colorTransform || colorAdjust || parser.isSet(argCorrection) || parser.isSet(argTemperature);
|
||||
bool colorModding = colorTransform || colorAdjust;
|
||||
|
||||
// check that exactly one command was given
|
||||
int commandCount = count({parser.isSet(argColor), parser.isSet(argImage), parser.isSet(argEffect), parser.isSet(argServerInfo), parser.isSet(argClear), parser.isSet(argClearAll), parser.isSet(argEnableComponent), parser.isSet(argDisableComponent), colorModding, parser.isSet(argSource), parser.isSet(argSourceAuto), parser.isSet(argSourceOff), parser.isSet(argConfigGet), parser.isSet(argSchemaGet), parser.isSet(argConfigSet)});
|
||||
@ -135,10 +131,6 @@ int main(int argc, char * argv[])
|
||||
showHelp(argGamma);
|
||||
showHelp(argBlacklevel);
|
||||
showHelp(argWhitelevel);
|
||||
showHelp(argIdC);
|
||||
showHelp(argCorrection);
|
||||
showHelp(argIdT);
|
||||
showHelp(argTemperature);
|
||||
showHelp(argIdA);
|
||||
showHelp(argRAdjust);
|
||||
showHelp(argGAdjust);
|
||||
@ -212,16 +204,6 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
else if (colorModding)
|
||||
{
|
||||
if (parser.isSet(argCorrection))
|
||||
{
|
||||
connection.setTemperature(argIdC.value(parser), argCorrection.getColor(parser));
|
||||
}
|
||||
|
||||
if (parser.isSet(argTemperature))
|
||||
{
|
||||
connection.setTemperature(argIdT.value(parser), argTemperature.getColor(parser));
|
||||
}
|
||||
|
||||
if (colorAdjust)
|
||||
{
|
||||
connection.setAdjustment(
|
||||
|
Loading…
Reference in New Issue
Block a user