Enhance DaliDT8: add RGBWAF control modes and methods for temporary color scene storage
Signed-off-by: Tony <tonylu@tony-cloud.com>
This commit is contained in:
@@ -96,6 +96,12 @@ enum class Dt8PreferredColorType {
|
||||
rgbwaf,
|
||||
};
|
||||
|
||||
enum class Dt8RgbwafControlMode {
|
||||
channelControl = 0,
|
||||
colorControl = 1,
|
||||
standardizedColorControl = 2,
|
||||
};
|
||||
|
||||
class DaliDT8 {
|
||||
public:
|
||||
explicit DaliDT8(DaliBase& base);
|
||||
@@ -125,7 +131,14 @@ class DaliDT8 {
|
||||
bool setTemporaryPrimaryDimLevel(int a, int n, double level);
|
||||
bool setTemporaryRGBDimLevels(int a, int r, int g, int b);
|
||||
bool setTemporaryWAFDimLevels(int a, int w, int amber, int freecolour);
|
||||
static int rgbwafControlValue(bool red = false, bool green = false, bool blue = false,
|
||||
bool white = false, bool amber = false, bool freecolour = false,
|
||||
Dt8RgbwafControlMode mode = Dt8RgbwafControlMode::channelControl);
|
||||
bool setTemporaryRGBWAFControl(int a, int control);
|
||||
bool setTemporaryRGBWAFChannelControl(int a, bool red = false, bool green = false,
|
||||
bool blue = false, bool white = false, bool amber = false,
|
||||
bool freecolour = false,
|
||||
Dt8RgbwafControlMode mode = Dt8RgbwafControlMode::channelControl);
|
||||
bool setTemporaryRGBWAFDimLevels(int a, int r, int g, int b, int w, int amber,
|
||||
int freecolour, int control);
|
||||
bool setTemporaryColourMask(int a);
|
||||
@@ -215,6 +228,7 @@ class DaliDT8 {
|
||||
int white = 0, int amber = 0, int freecolour = 254,
|
||||
int rgbwafControl = -1,
|
||||
int gateway = -1);
|
||||
bool storeCurrentTemporaryColourAsScene(int address, int scene, int brightness);
|
||||
bool storePowerOnLevelSnapshot(int address, int level);
|
||||
bool storePowerOnLevelColorSnapshot(int address, int level, int r, int g, int b,
|
||||
Dt8PreferredColorType preferredColorType = Dt8PreferredColorType::xy);
|
||||
|
||||
+27
@@ -240,6 +240,18 @@ bool DaliDT8::setTemporaryWAFDimLevels(int a, int w, int amber, int freecolour)
|
||||
base_.dtSelect(8) && base_.sendExtCmd(addr, DALI_CMD_DT8_SET_TEMPORARY_WAF_DIM_LEVELS);
|
||||
}
|
||||
|
||||
int DaliDT8::rgbwafControlValue(bool red, bool green, bool blue, bool white, bool amber,
|
||||
bool freecolour, Dt8RgbwafControlMode mode) {
|
||||
int value = static_cast<int>(mode) << 6;
|
||||
if (red) value |= 0x01;
|
||||
if (green) value |= 0x02;
|
||||
if (blue) value |= 0x04;
|
||||
if (white) value |= 0x08;
|
||||
if (amber) value |= 0x10;
|
||||
if (freecolour) value |= 0x20;
|
||||
return value & 0xFF;
|
||||
}
|
||||
|
||||
bool DaliDT8::setTemporaryRGBWAFControl(int a, int control) {
|
||||
const int storedControl = std::clamp(control, 0, 254);
|
||||
const int addr = a * 2 + 1;
|
||||
@@ -247,6 +259,13 @@ bool DaliDT8::setTemporaryRGBWAFControl(int a, int control) {
|
||||
base_.sendExtCmd(addr, DALI_CMD_DT8_SET_TEMPORARY_RGBWAF_CONTROL);
|
||||
}
|
||||
|
||||
bool DaliDT8::setTemporaryRGBWAFChannelControl(int a, bool red, bool green, bool blue,
|
||||
bool white, bool amber, bool freecolour,
|
||||
Dt8RgbwafControlMode mode) {
|
||||
return setTemporaryRGBWAFControl(
|
||||
a, rgbwafControlValue(red, green, blue, white, amber, freecolour, mode));
|
||||
}
|
||||
|
||||
bool DaliDT8::setTemporaryRGBWAFDimLevels(int a, int r, int g, int b, int w, int amber,
|
||||
int freecolour, int control) {
|
||||
return setTemporaryRGBDimLevels(a, r, g, b) && setTemporaryWAFDimLevels(a, w, amber, freecolour) &&
|
||||
@@ -456,6 +475,14 @@ bool DaliDT8::storeSceneSnapshot(int address, int scene, int brightness,
|
||||
return base_.dtSelect(8) && base_.storeDTRAsSceneBright(address, sceneIndex);
|
||||
}
|
||||
|
||||
bool DaliDT8::storeCurrentTemporaryColourAsScene(int address, int scene, int brightness) {
|
||||
const int sceneBrightness = std::clamp(brightness, 0, 255);
|
||||
const int sceneIndex = std::clamp(scene, 0, 15);
|
||||
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::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.
|
||||
|
||||
Reference in New Issue
Block a user