Add physical mirek limits to DaliDt8State and implement color temperature limit methods in DaliDT8
This commit is contained in:
+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