Skip to content

Commit

Permalink
Reapply temperature on JSONAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
Lord-Grey committed May 25, 2024
1 parent 2f128e7 commit 07dfce6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/api/JsonAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename T>
Expand Down
21 changes: 21 additions & 0 deletions libsrc/api/JsonAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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"))
Expand Down
10 changes: 10 additions & 0 deletions libsrc/api/JsonInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 07dfce6

Please sign in to comment.