Add physical mirek limits to DaliDt8State and implement color temperature limit methods in DaliDT8
This commit is contained in:
@@ -55,6 +55,8 @@ struct DaliDt8State {
|
||||
std::optional<int> mirek;
|
||||
std::optional<int> mirekMin;
|
||||
std::optional<int> mirekMax;
|
||||
std::optional<int> physicalMirekMin;
|
||||
std::optional<int> physicalMirekMax;
|
||||
std::optional<std::vector<int>> rgbwaf;
|
||||
std::optional<std::vector<int>> primaryN;
|
||||
|
||||
|
||||
@@ -99,6 +99,8 @@ class DaliDT8 {
|
||||
std::optional<int> getMaxColorTemperature(int a);
|
||||
std::optional<int> getPhysicalMinColorTemperature(int a);
|
||||
std::optional<int> getPhysicalMaxColorTemperature(int a);
|
||||
std::optional<int> getColourTempLimitRaw(int address, int limitType);
|
||||
std::optional<int> getColourTempLimit(int address, int limitType);
|
||||
|
||||
bool setColourRaw(int addr, int x1, int y1);
|
||||
|
||||
|
||||
@@ -145,6 +145,8 @@ DaliDt8State DaliDt8State::fromJson(const DaliValue::Object* json) {
|
||||
s.mirek = getObjectInt(*json, "mirek");
|
||||
s.mirekMin = getObjectInt(*json, "mirekMin");
|
||||
s.mirekMax = getObjectInt(*json, "mirekMax");
|
||||
s.physicalMirekMin = getObjectInt(*json, "physicalMirekMin");
|
||||
s.physicalMirekMax = getObjectInt(*json, "physicalMirekMax");
|
||||
s.rgbwaf = asIntList(getObjectValue(*json, "rgbwaf"));
|
||||
s.primaryN = asIntList(getObjectValue(*json, "primaryN"));
|
||||
return s;
|
||||
@@ -174,6 +176,8 @@ DaliValue::Object DaliDt8State::toJson() const {
|
||||
if (mirek.has_value()) out["mirek"] = mirek.value();
|
||||
if (mirekMin.has_value()) out["mirekMin"] = mirekMin.value();
|
||||
if (mirekMax.has_value()) out["mirekMax"] = mirekMax.value();
|
||||
if (physicalMirekMin.has_value()) out["physicalMirekMin"] = physicalMirekMin.value();
|
||||
if (physicalMirekMax.has_value()) out["physicalMirekMax"] = physicalMirekMax.value();
|
||||
if (rgbwaf.has_value()) out["rgbwaf"] = toIntArray(rgbwaf);
|
||||
if (primaryN.has_value()) out["primaryN"] = toIntArray(primaryN);
|
||||
return out;
|
||||
|
||||
+30
@@ -5,6 +5,28 @@
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
namespace {
|
||||
int colourTempLimitQuerySelector(int limitType) {
|
||||
switch (limitType & 0xFF) {
|
||||
case 0:
|
||||
return 128;
|
||||
case 1:
|
||||
return 130;
|
||||
case 2:
|
||||
return 129;
|
||||
case 3:
|
||||
return 131;
|
||||
default:
|
||||
return (limitType & 0x01) == 0 ? 128 : 130;
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<int> kelvinFromMirek(std::optional<int> mirek) {
|
||||
if (!mirek.has_value() || mirek.value() == 0) return std::nullopt;
|
||||
return static_cast<int>(std::floor(1000000.0 / static_cast<double>(mirek.value())));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
DaliDT8::DaliDT8(DaliBase& base) : base_(base) {}
|
||||
|
||||
bool DaliDT8::enableDT8() { return base_.dtSelect(8); }
|
||||
@@ -104,6 +126,14 @@ std::optional<int> DaliDT8::getPhysicalMaxColorTemperature(int a) {
|
||||
return static_cast<int>(std::floor(1000000.0 / static_cast<double>(mirek.value())));
|
||||
}
|
||||
|
||||
std::optional<int> DaliDT8::getColourTempLimitRaw(int address, int limitType) {
|
||||
return getColourRaw(address, colourTempLimitQuerySelector(limitType));
|
||||
}
|
||||
|
||||
std::optional<int> DaliDT8::getColourTempLimit(int address, int limitType) {
|
||||
return kelvinFromMirek(getColourTempLimitRaw(address, limitType));
|
||||
}
|
||||
|
||||
bool DaliDT8::setColourRaw(int addr, int x1, int y1) {
|
||||
const int x1L = x1 & 0xFF;
|
||||
const int y1L = y1 & 0xFF;
|
||||
|
||||
Reference in New Issue
Block a user