Add support for power-on and system failure level snapshots in DaliDT8
This commit is contained in:
@@ -66,6 +66,17 @@ struct SceneColorReport {
|
|||||||
bool hasColorTemperature() const { return colorTemperature.has_value(); }
|
bool hasColorTemperature() const { return colorTemperature.has_value(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Dt8LevelColorReport {
|
||||||
|
int level = 0;
|
||||||
|
int colorTypeValue = 0;
|
||||||
|
std::vector<double> xy;
|
||||||
|
std::optional<int> colorTemperature;
|
||||||
|
|
||||||
|
ColorType colorType() const { return ColorType(colorTypeValue); }
|
||||||
|
bool hasXy() const { return xy.size() == 2; }
|
||||||
|
bool hasColorTemperature() const { return colorTemperature.has_value(); }
|
||||||
|
};
|
||||||
|
|
||||||
enum class Dt8SceneStoreColorMode {
|
enum class Dt8SceneStoreColorMode {
|
||||||
disabled,
|
disabled,
|
||||||
colorTemperature,
|
colorTemperature,
|
||||||
@@ -176,6 +187,10 @@ class DaliDT8 {
|
|||||||
bool storeSceneSnapshot(int address, int scene, int brightness,
|
bool storeSceneSnapshot(int address, int scene, int brightness,
|
||||||
Dt8SceneStoreColorMode colorMode = Dt8SceneStoreColorMode::disabled,
|
Dt8SceneStoreColorMode colorMode = Dt8SceneStoreColorMode::disabled,
|
||||||
int colorTemperature = 0, int red = 0, int green = 0, int blue = 0);
|
int colorTemperature = 0, int red = 0, int green = 0, int blue = 0);
|
||||||
|
bool storePowerOnLevelSnapshot(int address, int level);
|
||||||
|
bool storeSystemFailureLevelSnapshot(int address, int level);
|
||||||
|
std::optional<Dt8LevelColorReport> getPowerOnLevelColorReport(int a);
|
||||||
|
std::optional<Dt8LevelColorReport> getSystemFailureLevelColorReport(int a);
|
||||||
bool storeColourTempLimitRaw(int a, int limitType, int mirek);
|
bool storeColourTempLimitRaw(int a, int limitType, int mirek);
|
||||||
bool storeColourTempLimit(int a, int limitType, int kelvin);
|
bool storeColourTempLimit(int a, int limitType, int kelvin);
|
||||||
bool setGearAutoActivate(int a, bool enable);
|
bool setGearAutoActivate(int a, bool enable);
|
||||||
@@ -189,5 +204,7 @@ class DaliDT8 {
|
|||||||
std::optional<int> getExtendedVersion(int a);
|
std::optional<int> getExtendedVersion(int a);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::optional<Dt8LevelColorReport> buildLevelColorReport(int a, std::optional<int> level);
|
||||||
|
|
||||||
DaliBase& base_;
|
DaliBase& base_;
|
||||||
};
|
};
|
||||||
|
|||||||
+42
@@ -328,6 +328,19 @@ bool DaliDT8::storeSceneSnapshot(int address, int scene, int brightness,
|
|||||||
return base_.dtSelect(8) && base_.storeDTRAsSceneBright(address, sceneIndex);
|
return base_.dtSelect(8) && base_.storeDTRAsSceneBright(address, sceneIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DaliDT8::storePowerOnLevelSnapshot(int address, int level) {
|
||||||
|
const int storedLevel = std::clamp(level, 0, 254);
|
||||||
|
// DT SELECT is one-shot and SET DTR consumes any earlier selection.
|
||||||
|
return base_.setDTR(storedLevel) && base_.dtSelect(8) && base_.storeDTRAsPoweredBright(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DaliDT8::storeSystemFailureLevelSnapshot(int address, int level) {
|
||||||
|
const int storedLevel = std::clamp(level, 0, 254);
|
||||||
|
// DT SELECT is one-shot and SET DTR consumes any earlier selection.
|
||||||
|
return base_.setDTR(storedLevel) && base_.dtSelect(8) &&
|
||||||
|
base_.storeDTRAsSystemFailureLevel(address);
|
||||||
|
}
|
||||||
|
|
||||||
bool DaliDT8::activateTemporaryColour(int a) { return base_.dtSelect(8) && base_.activate(a); }
|
bool DaliDT8::activateTemporaryColour(int a) { return base_.dtSelect(8) && base_.activate(a); }
|
||||||
|
|
||||||
std::optional<int> DaliDT8::getPrimaryDimLevel(int a, int n) {
|
std::optional<int> DaliDT8::getPrimaryDimLevel(int a, int n) {
|
||||||
@@ -452,6 +465,35 @@ std::vector<double> DaliDT8::getSceneColor(int a, int sense) {
|
|||||||
return report->xy;
|
return report->xy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<Dt8LevelColorReport> DaliDT8::buildLevelColorReport(int a, std::optional<int> level) {
|
||||||
|
if (!level.has_value() || level.value() == 255) return std::nullopt;
|
||||||
|
|
||||||
|
Dt8LevelColorReport report;
|
||||||
|
report.level = level.value();
|
||||||
|
report.colorTypeValue = getReportColourType(a).value_or(0);
|
||||||
|
|
||||||
|
const ColorType colorType(report.colorTypeValue);
|
||||||
|
if (colorType.xy()) {
|
||||||
|
report.xy = getReportColour(a);
|
||||||
|
return report;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (colorType.ct()) {
|
||||||
|
report.colorTemperature = getReportColorTemperature(a);
|
||||||
|
return report;
|
||||||
|
}
|
||||||
|
|
||||||
|
return report;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<Dt8LevelColorReport> DaliDT8::getPowerOnLevelColorReport(int a) {
|
||||||
|
return buildLevelColorReport(a, base_.getPowerOnLevel(a));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<Dt8LevelColorReport> DaliDT8::getSystemFailureLevelColorReport(int a) {
|
||||||
|
return buildLevelColorReport(a, base_.getSystemFailureLevel(a));
|
||||||
|
}
|
||||||
|
|
||||||
bool DaliDT8::storePrimaryTy(int a, int n, int ty) {
|
bool DaliDT8::storePrimaryTy(int a, int n, int ty) {
|
||||||
int idx = std::clamp(n, 0, 5);
|
int idx = std::clamp(n, 0, 5);
|
||||||
int t = std::clamp(ty, 0, 65535);
|
int t = std::clamp(ty, 0, 65535);
|
||||||
|
|||||||
Reference in New Issue
Block a user