Reapply temperature on JSONAPI

This commit is contained in:
LordGrey 2024-05-25 19:53:48 +02:00
parent 2f128e766f
commit 07dfce68f6
3 changed files with 32 additions and 0 deletions

View File

@ -281,6 +281,7 @@ private:
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<typename T>

View File

@ -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"))

View File

@ -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;