feat: Enhance DALI Gateway with RGBW and RGBCW support

- Added support for RGBW and RGBCW color modes in the DALI Gateway.
- Updated JSON color mode parsing to handle new color types.
- Extended the StoreDt8SceneSnapshot function to include white, amber, and free color parameters.
- Introduced new methods in DaliGatewayBridge for setting RGBW, RGBCW, and RGBWAF colors.
- Modified KnxDaliChannel to send RGBW and RGBCW colors based on the color type.
- Updated parameter types and definitions in the KNX product XML files to accommodate new color modes.
- Enhanced README with migration details and validation instructions.

Signed-off-by: Tony <tonylu@tony-cloud.com>
This commit is contained in:
Tony
2026-05-29 11:32:10 +08:00
parent f39ae6f0c6
commit c60ef2ccde
19 changed files with 554 additions and 18 deletions
@@ -82,6 +82,8 @@ enum class DaliDt8SceneColorMode {
kDisabled,
kColorTemperature,
kRgb,
kRgbw,
kRgbcw,
};
struct DaliDomainSnapshot {
@@ -158,7 +160,8 @@ class DaliDomainService {
bool storeDt8SceneSnapshot(uint8_t gateway_id, int short_address, int scene, int brightness,
DaliDt8SceneColorMode color_mode = DaliDt8SceneColorMode::kDisabled,
int color_temperature = 0, int red = 0, int green = 0,
int blue = 0) const;
int blue = 0, int white = 0, int amber = 0,
int freecolour = 255, int rgbwaf_control = -1) const;
bool storeDt8PowerOnLevelSnapshot(uint8_t gateway_id, int short_address, int level) const;
bool storeDt8SystemFailureLevelSnapshot(uint8_t gateway_id, int short_address, int level) const;
bool setBright(uint8_t gateway_id, int short_address, int brightness) const;
@@ -166,6 +169,11 @@ class DaliDomainService {
bool setColTemp(uint8_t gateway_id, int short_address, int kelvin) const;
bool setColourRaw(uint8_t gateway_id, int raw_addr, int x, int y) const;
bool setColourRGB(uint8_t gateway_id, int short_address, int r, int g, int b) const;
bool setColourRGBW(uint8_t gateway_id, int short_address, int r, int g, int b, int w) const;
bool setColourRGBCW(uint8_t gateway_id, int short_address, int r, int g, int b,
int cool_white, int warm_white) const;
bool setColourRGBWAF(uint8_t gateway_id, int short_address, int r, int g, int b, int w,
int amber, int freecolour, int control = -1) const;
bool on(uint8_t gateway_id, int short_address) const;
bool off(uint8_t gateway_id, int short_address) const;
bool off(int short_address) const;
+57 -2
View File
@@ -107,12 +107,30 @@ void PutOptionalNumber(DaliDomainSnapshot& snapshot, const char* name,
}
}
template <typename Report>
void PutRgbwafReport(DaliDomainSnapshot& snapshot, const Report& report) {
if (!report.hasRgbwaf()) {
return;
}
snapshot.int_arrays["rgbwaf"] = report.rgbwaf;
snapshot.int_arrays["rgbw"] = {report.rgbwaf[0], report.rgbwaf[1], report.rgbwaf[2], report.rgbwaf[3]};
snapshot.int_arrays["rgbcw"] = {report.rgbwaf[0], report.rgbwaf[1], report.rgbwaf[2],
report.rgbwaf[3], report.rgbwaf[4]};
if (report.rgbwafControl.has_value()) {
snapshot.ints["rgbwafControl"] = report.rgbwafControl.value();
}
}
Dt8SceneStoreColorMode ToDaliCppColorMode(DaliDt8SceneColorMode color_mode) {
switch (color_mode) {
case DaliDt8SceneColorMode::kColorTemperature:
return Dt8SceneStoreColorMode::colorTemperature;
case DaliDt8SceneColorMode::kRgb:
return Dt8SceneStoreColorMode::rgb;
case DaliDt8SceneColorMode::kRgbw:
return Dt8SceneStoreColorMode::rgbw;
case DaliDt8SceneColorMode::kRgbcw:
return Dt8SceneStoreColorMode::rgbcw;
case DaliDt8SceneColorMode::kDisabled:
default:
return Dt8SceneStoreColorMode::disabled;
@@ -1099,6 +1117,7 @@ std::optional<DaliDomainSnapshot> DaliDomainService::dt8SceneColorReport(
if (report->hasXy()) {
snapshot.number_arrays["xy"] = report->xy;
}
PutRgbwafReport(snapshot, report.value());
return snapshot;
}
@@ -1122,6 +1141,7 @@ std::optional<DaliDomainSnapshot> DaliDomainService::dt8PowerOnLevelColorReport(
if (report->hasXy()) {
snapshot.number_arrays["xy"] = report->xy;
}
PutRgbwafReport(snapshot, report.value());
return snapshot;
}
@@ -1145,6 +1165,7 @@ std::optional<DaliDomainSnapshot> DaliDomainService::dt8SystemFailureLevelColorR
if (report->hasXy()) {
snapshot.number_arrays["xy"] = report->xy;
}
PutRgbwafReport(snapshot, report.value());
return snapshot;
}
@@ -1152,7 +1173,8 @@ bool DaliDomainService::storeDt8SceneSnapshot(uint8_t gateway_id, int short_addr
int brightness,
DaliDt8SceneColorMode color_mode,
int color_temperature, int red, int green,
int blue) const {
int blue, int white, int amber, int freecolour,
int rgbwaf_control) const {
const auto* channel = findChannelByGateway(gateway_id);
if (channel == nullptr || channel->dali == nullptr) {
return false;
@@ -1160,7 +1182,8 @@ bool DaliDomainService::storeDt8SceneSnapshot(uint8_t gateway_id, int short_addr
markBusActivity(gateway_id);
return channel->dali->dt8.storeSceneSnapshot(short_address, scene, brightness,
ToDaliCppColorMode(color_mode), color_temperature,
red, green, blue);
red, green, blue, white, amber, freecolour,
rgbwaf_control);
}
bool DaliDomainService::storeDt8PowerOnLevelSnapshot(uint8_t gateway_id, int short_address,
@@ -1229,6 +1252,38 @@ bool DaliDomainService::setColourRGB(uint8_t gateway_id, int short_address, int
return channel->dali->dt8.setColourRGB(short_address, r, g, b);
}
bool DaliDomainService::setColourRGBW(uint8_t gateway_id, int short_address, int r, int g,
int b, int w) const {
const auto* channel = findChannelByGateway(gateway_id);
if (channel == nullptr || channel->dali == nullptr) {
return false;
}
markBusActivity(gateway_id);
return channel->dali->dt8.setColourRGBW(short_address, r, g, b, w);
}
bool DaliDomainService::setColourRGBCW(uint8_t gateway_id, int short_address, int r, int g,
int b, int cool_white, int warm_white) const {
const auto* channel = findChannelByGateway(gateway_id);
if (channel == nullptr || channel->dali == nullptr) {
return false;
}
markBusActivity(gateway_id);
return channel->dali->dt8.setColourRGBCW(short_address, r, g, b, cool_white, warm_white);
}
bool DaliDomainService::setColourRGBWAF(uint8_t gateway_id, int short_address, int r, int g,
int b, int w, int amber, int freecolour,
int control) const {
const auto* channel = findChannelByGateway(gateway_id);
if (channel == nullptr || channel->dali == nullptr) {
return false;
}
markBusActivity(gateway_id);
return channel->dali->dt8.setColourRGBWAF(short_address, r, g, b, w, amber, freecolour,
control);
}
bool DaliDomainService::on(uint8_t gateway_id, int short_address) const {
const auto* channel = findChannelByGateway(gateway_id);
if (channel == nullptr || channel->dali == nullptr) {