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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user