mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
Feature: Add NumberOfPrimaries, PrimarynX, PrimarynY and PrimarynIntensity attributes in ColorControl cluster
This commit is contained in:
@@ -1005,6 +1005,111 @@ attribute_t *create_color_loop_stored_enhanced_hue(cluster_t *cluster, uint16_t
|
||||
ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value));
|
||||
}
|
||||
|
||||
attribute_t *create_number_of_primaries(cluster_t *cluster, uint8_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::NumberOfPrimaries::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint8(value));
|
||||
}
|
||||
|
||||
attribute_t *create_primary_n_x(cluster_t * cluster, uint16_t value, uint8_t index)
|
||||
{
|
||||
switch (index) {
|
||||
case 1:
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::Primary1X::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint16(value));
|
||||
break;
|
||||
case 2:
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::Primary2X::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint16(value));
|
||||
break;
|
||||
case 3:
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::Primary3X::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint16(value));
|
||||
break;
|
||||
case 4:
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::Primary4X::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint16(value));
|
||||
break;
|
||||
case 5:
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::Primary5X::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint16(value));
|
||||
break;
|
||||
case 6:
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::Primary6X::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint16(value));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
attribute_t *create_primary_n_y(cluster_t * cluster, uint16_t value, uint8_t index)
|
||||
{
|
||||
switch (index) {
|
||||
case 1:
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::Primary1Y::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint16(value));
|
||||
break;
|
||||
case 2:
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::Primary2Y::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint16(value));
|
||||
break;
|
||||
case 3:
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::Primary3Y::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint16(value));
|
||||
break;
|
||||
case 4:
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::Primary4Y::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint16(value));
|
||||
break;
|
||||
case 5:
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::Primary5Y::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint16(value));
|
||||
break;
|
||||
case 6:
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::Primary6Y::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint16(value));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
attribute_t *create_primary_n_intensity(cluster_t * cluster, uint8_t value, uint8_t index)
|
||||
{
|
||||
switch (index) {
|
||||
case 1:
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::Primary1Intensity::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint8(value));
|
||||
break;
|
||||
case 2:
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::Primary2Intensity::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint8(value));
|
||||
break;
|
||||
case 3:
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::Primary3Intensity::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint8(value));
|
||||
break;
|
||||
case 4:
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::Primary4Intensity::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint8(value));
|
||||
break;
|
||||
case 5:
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::Primary5Intensity::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint8(value));
|
||||
break;
|
||||
case 6:
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::Primary6Intensity::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint8(value));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
} /* attribute */
|
||||
} /* color_control */
|
||||
|
||||
|
||||
@@ -265,6 +265,10 @@ attribute_t *create_color_loop_direction(cluster_t *cluster, uint8_t value);
|
||||
attribute_t *create_color_loop_time(cluster_t *cluster, uint16_t value);
|
||||
attribute_t *create_color_loop_start_enhanced_hue(cluster_t *cluster, uint16_t value);
|
||||
attribute_t *create_color_loop_stored_enhanced_hue(cluster_t *cluster, uint16_t value);
|
||||
attribute_t *create_number_of_primaries(cluster_t *cluster, uint8_t value);
|
||||
attribute_t *create_primary_n_x(cluster_t * cluster, uint16_t value, uint8_t index);
|
||||
attribute_t *create_primary_n_y(cluster_t * cluster, uint16_t value, uint8_t index);
|
||||
attribute_t *create_primary_n_intensity(cluster_t * cluster, uint8_t value, uint8_t index);
|
||||
} /* attribute */
|
||||
} /* color_control */
|
||||
|
||||
|
||||
@@ -1007,12 +1007,18 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
|
||||
attribute::create_color_control_options(cluster, config->color_control_options);
|
||||
attribute::create_enhanced_color_mode(cluster, config->enhanced_color_mode);
|
||||
attribute::create_color_capabilities(cluster, config->color_capabilities);
|
||||
attribute::create_number_of_primaries(cluster, config->number_of_primaries);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes.");
|
||||
}
|
||||
|
||||
/* Attributes managed internally */
|
||||
attribute::create_remaining_time(cluster, 0);
|
||||
for (uint8_t idx = 1; idx <= config->number_of_primaries; ++idx) {
|
||||
attribute::create_primary_n_x(cluster, 0, idx);
|
||||
attribute::create_primary_n_y(cluster, 0, idx);
|
||||
attribute::create_primary_n_intensity(cluster, 0, idx);
|
||||
}
|
||||
}
|
||||
|
||||
/* Features */
|
||||
|
||||
@@ -223,13 +223,14 @@ typedef struct config {
|
||||
uint8_t color_control_options;
|
||||
uint8_t enhanced_color_mode;
|
||||
uint16_t color_capabilities;
|
||||
uint8_t number_of_primaries;
|
||||
feature::hue_saturation::config_t hue_saturation;
|
||||
feature::color_temperature::config_t color_temperature;
|
||||
feature::xy::config_t xy;
|
||||
feature::enhanced_hue::config_t enhanced_hue;
|
||||
feature::color_loop::config_t color_loop;
|
||||
config() : cluster_revision(5), color_mode(1), color_control_options(0), enhanced_color_mode(1),
|
||||
color_capabilities(0) {}
|
||||
color_capabilities(0), number_of_primaries(0) {}
|
||||
} config_t;
|
||||
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features);
|
||||
|
||||
Reference in New Issue
Block a user