Add support for scene snapshot storage with color mode handling in DaliDT8
This commit is contained in:
+41
@@ -192,6 +192,15 @@ bool DaliDT8::setTemporaryRGBWAFControl(int a, int control) {
|
||||
base_.sendExtCmd(addr, DALI_CMD_DT8_SET_TEMPORARY_RGBWAF_CONTROL);
|
||||
}
|
||||
|
||||
bool DaliDT8::setTemporaryColourMask(int a) {
|
||||
if (setTemporaryRGBDimLevels(a, 255, 255, 255)) return true;
|
||||
if (base_.setDTR(0xFF) && base_.setDTR1(0xFF) && base_.dtSelect(8) && base_.setDTRAsColourTemp(a)) {
|
||||
return true;
|
||||
}
|
||||
const int addr = DaliComm::toCmdAddr(a);
|
||||
return setTemporaryColourXRaw(addr, 0xFFFF) && setTemporaryColourYRaw(addr, 0xFFFF);
|
||||
}
|
||||
|
||||
bool DaliDT8::copyReportToTemporary(int a) { return base_.dtSelect(8) && base_.copyReportColourToTemp(a); }
|
||||
|
||||
bool DaliDT8::stepXUp(int a) {
|
||||
@@ -287,6 +296,38 @@ std::vector<int> DaliDT8::getColourRGB(int a) {
|
||||
return {rgb[0], rgb[1], rgb[2]};
|
||||
}
|
||||
|
||||
bool DaliDT8::storeSceneSnapshot(int address, int scene, int brightness,
|
||||
Dt8SceneStoreColorMode colorMode, int colorTemperature, int red,
|
||||
int green, int blue) {
|
||||
const int sceneBrightness = std::clamp(brightness, 0, 255);
|
||||
const int sceneIndex = std::clamp(scene, 0, 15);
|
||||
|
||||
if (sceneBrightness != 255) {
|
||||
switch (colorMode) {
|
||||
case Dt8SceneStoreColorMode::colorTemperature:
|
||||
if (!setTemporaryColourTemperature(address, colorTemperature)) return false;
|
||||
break;
|
||||
case Dt8SceneStoreColorMode::rgb: {
|
||||
const int r = std::clamp(red, 0, 255);
|
||||
const int g = std::clamp(green, 0, 255);
|
||||
const int b = std::clamp(blue, 0, 255);
|
||||
const auto xy = DaliColor::rgb2xy(static_cast<double>(r) / 255.0,
|
||||
static_cast<double>(g) / 255.0,
|
||||
static_cast<double>(b) / 255.0);
|
||||
if (!setTemporaryColourXY(address, xy[0], xy[1])) return false;
|
||||
break;
|
||||
}
|
||||
case Dt8SceneStoreColorMode::disabled:
|
||||
if (!setTemporaryColourMask(address)) return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!base_.setDTR(sceneBrightness)) return false;
|
||||
// DT SELECT is one-shot and SET DTR consumes any earlier selection.
|
||||
return base_.dtSelect(8) && base_.storeDTRAsSceneBright(address, sceneIndex);
|
||||
}
|
||||
|
||||
bool DaliDT8::activateTemporaryColour(int a) { return base_.dtSelect(8) && base_.activate(a); }
|
||||
|
||||
std::optional<int> DaliDT8::getPrimaryDimLevel(int a, int n) {
|
||||
|
||||
Reference in New Issue
Block a user