diff --git a/include/api/JsonAPI.h b/include/api/JsonAPI.h index 35d7e2043..a7b0dd583 100644 --- a/include/api/JsonAPI.h +++ b/include/api/JsonAPI.h @@ -281,6 +281,7 @@ private slots: void applyColorAdjustments(const QJsonObject &adjustment, ColorAdjustment *colorAdjustment); void applyColorAdjustment(const QString &colorName, const QJsonObject &adjustment, RgbChannelAdjustment &rgbAdjustment); void applyGammaTransform(const QString &transformName, const QJsonObject &adjustment, RgbTransform &rgbTransform, char channel); + void applyTemperatureAdjustment(const QJsonObject &adjustment, ColorCorrection *colorCorrection); void applyTransforms(const QJsonObject &adjustment, ColorAdjustment *colorAdjustment); template diff --git a/libsrc/api/JsonAPI.cpp b/libsrc/api/JsonAPI.cpp index 5c1a7ded0..0a0e158db 100644 --- a/libsrc/api/JsonAPI.cpp +++ b/libsrc/api/JsonAPI.cpp @@ -598,8 +598,16 @@ void JsonAPI::handleAdjustmentCommand(const QJsonObject &message, const JsonApiC return; } + ColorCorrection *temperatureColorCorrection = _hyperion->getTemperature(adjustmentId); + if (temperatureColorCorrection == nullptr) { + Warning(_log, "Incorrect temperature adjustment identifier: %s", adjustmentId.toStdString().c_str()); + return; + } + + applyColorAdjustments(adjustment, colorAdjustment); applyTransforms(adjustment, colorAdjustment); + applyTemperatureAdjustment(adjustment, temperatureColorCorrection); _hyperion->adjustmentsUpdated(); sendSuccessReply(cmd); } @@ -673,6 +681,19 @@ void JsonAPI::applyTransform(const QString &transformName, const QJsonObject &ad } } +void JsonAPI::applyTemperatureAdjustment(const QJsonObject &adjustment, ColorCorrection *colorCorrection) +{ + if (adjustment.contains("temperature")) + { + int temperature = adjustment["temperature"].toInt(6500); + ColorRgb rgb = getRgbFromTemperature(temperature); + + colorCorrection->_rgbCorrection.setcorrectionR(rgb.red); + colorCorrection->_rgbCorrection.setcorrectionG(rgb.green); + colorCorrection->_rgbCorrection.setcorrectionB(rgb.blue); + } +} + void JsonAPI::handleSourceSelectCommand(const QJsonObject &message, const JsonApiCommand& cmd) { if (message.contains("auto")) diff --git a/libsrc/api/JsonInfo.cpp b/libsrc/api/JsonInfo.cpp index e2a73ffe1..8c74579e1 100644 --- a/libsrc/api/JsonInfo.cpp +++ b/libsrc/api/JsonInfo.cpp @@ -83,6 +83,16 @@ QJsonArray JsonInfo::getAdjustmentInfo(const Hyperion* hyperion, Logger* log) adjustment["saturationGain"] = colorAdjustment->_okhsvTransform.getSaturationGain(); adjustment["brightnessGain"] = colorAdjustment->_okhsvTransform.getBrightnessGain(); + + ColorCorrection *temperatureColorCorrection = hyperion->getTemperature(adjustmentId); + if (temperatureColorCorrection == nullptr) { + Error(log, "Incorrect temperature adjustment id: %s", QSTRING_CSTR(adjustmentId)); + continue; + } + + // TODO: Return current Temperature in Kelvin + adjustment["temperature"] = 6600; + adjustmentArray.append(adjustment); } return adjustmentArray;