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
@@ -207,6 +207,25 @@ bool DaliGatewayBridge::setColourRGB(int short_address, uint8_t r, uint8_t g,
return dali_.setColourRGB(gateway_id_, short_address, r, g, b);
}
bool DaliGatewayBridge::setColourRGBW(int short_address, uint8_t r, uint8_t g,
uint8_t b, uint8_t w) const {
return dali_.setColourRGBW(gateway_id_, short_address, r, g, b, w);
}
bool DaliGatewayBridge::setColourRGBCW(int short_address, uint8_t r, uint8_t g,
uint8_t b, uint8_t cool_white,
uint8_t warm_white) const {
return dali_.setColourRGBCW(gateway_id_, short_address, r, g, b, cool_white,
warm_white);
}
bool DaliGatewayBridge::setColourRGBWAF(int short_address, uint8_t r, uint8_t g,
uint8_t b, uint8_t w, uint8_t amber,
uint8_t freecolour, uint8_t control) const {
return dali_.setColourRGBWAF(gateway_id_, short_address, r, g, b, w, amber,
freecolour, control);
}
std::optional<DaliDomainSnapshot> DaliGatewayBridge::dt8StatusSnapshot(
int short_address) const {
return dali_.dt8StatusSnapshot(gateway_id_, short_address);
@@ -132,8 +132,25 @@ void KnxDaliChannel::setDimmState(uint8_t value, bool, bool) {
void KnxDaliChannel::sendColor() {
if (dali_ == nullptr) return;
dali_->setColourRGB(static_cast<int>(index_), current_color_[0],
current_color_[1], current_color_[2]);
const auto color_type = is_group_ ? ParamGRP_colorType(index_) : ParamADR_colorType(index_);
switch (color_type) {
case PT_ColorType::PT_colorType_RGBW:
dali_->setColourRGBW(static_cast<int>(index_), current_color_[0], current_color_[1],
current_color_[2], current_color_[3]);
break;
case PT_ColorType::PT_colorType_RGBCW:
dali_->setColourRGBCW(static_cast<int>(index_), current_color_[0], current_color_[1],
current_color_[2], current_color_[3], current_color_[4]);
break;
case PT_ColorType::PT_colorType_RGB:
case PT_ColorType::PT_colorType_HSV:
case PT_ColorType::PT_colorType_XYY:
case PT_ColorType::PT_colorType_TW:
default:
dali_->setColourRGB(static_cast<int>(index_), current_color_[0], current_color_[1],
current_color_[2]);
break;
}
}
// ---- KO Handlers ----
@@ -172,12 +189,21 @@ void KnxDaliChannel::koHandleLock(GroupObject& ko) {
}
void KnxDaliChannel::koHandleColor(GroupObject& ko) {
KNXValue val = ko.value();
if (true) {
// RGB packed in float or raw bytes
// Simplified: store and send
sendColor();
const auto color_type = is_group_ ? ParamGRP_colorType(index_) : ParamADR_colorType(index_);
uint8_t* data = ko.valueRef();
if (data != nullptr) {
current_color_[0] = data[0];
current_color_[1] = data[1];
current_color_[2] = data[2];
if (color_type == PT_ColorType::PT_colorType_RGBW ||
color_type == PT_ColorType::PT_colorType_RGBCW) {
current_color_[3] = data[3];
}
if (color_type == PT_ColorType::PT_colorType_RGBCW) {
current_color_[4] = data[4];
}
}
sendColor();
}
} // namespace knx_dali_gw
@@ -77,7 +77,7 @@ class KnxDaliChannel {
bool current_state_{false};
uint8_t current_step_{0};
bool current_is_locked_{false};
uint8_t current_color_[4]{};
uint8_t current_color_[6]{};
// HCL
uint8_t hcl_curve_{255};
+9 -3
View File
@@ -21,21 +21,27 @@ constexpr const char* kTag = "knx_dali_gw";
#define CONFIG_GATEWAY_KNX_OEM_APPLICATION_NUMBER 0x0001
#endif
#ifndef CONFIG_GATEWAY_KNX_OEM_HARDWARE_ID
#define CONFIG_GATEWAY_KNX_OEM_HARDWARE_ID 0xA401
#endif
#ifndef CONFIG_GATEWAY_KNX_OEM_APPLICATION_VERSION
#define CONFIG_GATEWAY_KNX_OEM_APPLICATION_VERSION 0x08
#define CONFIG_GATEWAY_KNX_OEM_APPLICATION_VERSION 0x09
#endif
constexpr uint16_t kKnxOemManufacturerId =
static_cast<uint16_t>(CONFIG_GATEWAY_KNX_OEM_MANUFACTURER_ID);
constexpr uint16_t kKnxOemApplicationNumber =
static_cast<uint16_t>(CONFIG_GATEWAY_KNX_OEM_APPLICATION_NUMBER);
constexpr uint16_t kKnxOemHardwareId =
static_cast<uint16_t>(CONFIG_GATEWAY_KNX_OEM_HARDWARE_ID);
constexpr uint8_t kKnxOemApplicationVersion =
static_cast<uint8_t>(CONFIG_GATEWAY_KNX_OEM_APPLICATION_VERSION);
constexpr uint8_t kKnxOemHardwareType[6] = {
0x00,
0x00,
static_cast<uint8_t>(kKnxOemManufacturerId & 0xff),
static_cast<uint8_t>(kKnxOemApplicationNumber & 0xff),
static_cast<uint8_t>((kKnxOemHardwareId >> 8) & 0xff),
static_cast<uint8_t>(kKnxOemHardwareId & 0xff),
kKnxOemApplicationVersion,
0x00};
constexpr uint8_t kKnxOemProgramVersion[5] = {