Add support for power-on and system failure level snapshots in DaliDT8
This commit is contained in:
+42
@@ -328,6 +328,19 @@ bool DaliDT8::storeSceneSnapshot(int address, int scene, int brightness,
|
||||
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); }
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
int idx = std::clamp(n, 0, 5);
|
||||
int t = std::clamp(ty, 0, 65535);
|
||||
|
||||
Reference in New Issue
Block a user