Skip to content

Commit

Permalink
Merge branch 'fix/lightbulb_power' into 'master'
Browse files Browse the repository at this point in the history
fix(lightbulb): Fixed the issue of low power output in CCT mode

See merge request ae_group/esp-iot-solution!1130
  • Loading branch information
Yuan Ming Fu committed Nov 15, 2024
2 parents 23c164e + 0f802cd commit db24130
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
6 changes: 6 additions & 0 deletions components/led/lightbulb_driver/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# ChangeLog

## v1.3.3 - 2024-11-07

### Bug Fixes:

* Fixed the issue of low power output in CCT mode.

## v1.3.2 - 2024-09-19

### Enhancements:
Expand Down
2 changes: 1 addition & 1 deletion components/led/lightbulb_driver/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "1.3.2"
version: "1.3.3"
description: Provide multiple dimming driver solutions to easily build lightbulb applications
url: https://github.com/espressif/esp-iot-solution/tree/master/components/led/lightbulb_driver
dependencies:
Expand Down
20 changes: 10 additions & 10 deletions components/led/lightbulb_driver/src/lightbulb.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,43 +300,43 @@ static uint8_t precise_kelvin_convert_to_percentage(uint16_t kelvin)
*/
static void cct_and_brightness_convert_and_power_limit(lightbulb_led_beads_comb_t led_beads, float multiple, uint8_t cct, uint8_t brightness, uint16_t white_value[])
{
uint16_t max_value = 0;
hal_get_driver_feature(QUERY_MAX_INPUT_VALUE, &max_value);

if (led_beads == LED_BEADS_1CH_C || led_beads == LED_BEADS_4CH_RGBC || led_beads == LED_BEADS_4CH_RGBCC) {
uint16_t value = brightness * 255 / 100;
uint16_t value = brightness / 100.0 * max_value;
hal_get_linear_table_value((uint8_t)value, &white_value[3]);
if (led_beads == LED_BEADS_4CH_RGBCC) {
hal_get_linear_table_value((uint8_t)value, &white_value[4]);
}
} else if (led_beads == LED_BEADS_1CH_W || led_beads == LED_BEADS_4CH_RGBW || led_beads == LED_BEADS_4CH_RGBWW) {
uint16_t value = brightness * 255 / 100;
hal_get_linear_table_value((uint8_t)value, &white_value[4]);
uint16_t value = brightness / 100.0 * max_value;
hal_get_linear_table_value(value, &white_value[4]);

if (led_beads == LED_BEADS_4CH_RGBWW) {
hal_get_linear_table_value((uint8_t)value, &white_value[3]);
}
} else if ((led_beads == LED_BEADS_2CH_CW || led_beads == LED_BEADS_5CH_RGBCW) && IS_WHITE_OUTPUT_HARDWARE_MIXED()) {
uint16_t value1 = cct * 255 / 100;
uint16_t value2 = brightness * 255 / 100;
uint16_t value1 = cct / 100.0 * max_value;
uint16_t value2 = brightness / 100.0 * max_value;
hal_get_linear_table_value((uint8_t)value1, &white_value[3]);
hal_get_linear_table_value((uint8_t)value2, &white_value[4]);
} else if (led_beads == LED_BEADS_2CH_CW || ((led_beads == LED_BEADS_5CH_RGBCW) && (s_lb_obj->cap.enable_precise_cct_control == false))) {
uint16_t max_value;
float max_power;
float _c = cct / 100.0;
float _w = (100 - cct) / 100.0;

hal_get_driver_feature(QUERY_MAX_INPUT_VALUE, &max_value);
float baseline = MAX(_c, _w);

max_power = MIN(max_value * multiple, max_value / baseline);
_c = max_power * _c * (brightness / 100.0);
_w = max_power * _w * (brightness / 100.0);
hal_get_linear_table_value((uint16_t)_c, &white_value[3]);
hal_get_linear_table_value((uint16_t)_w, &white_value[4]);
} else {
uint16_t max_value;
float max_power;
lightbulb_cct_mapping_data_t data = search_mapping_cct_data(cct);
ESP_LOGD(TAG, "%f, %f, %f, %f, %f", data.rgbcw[0], data.rgbcw[1], data.rgbcw[2], data.rgbcw[3], data.rgbcw[4]);

hal_get_driver_feature(QUERY_MAX_INPUT_VALUE, &max_value);
float baseline = MAX(data.rgbcw[0], data.rgbcw[1]);
baseline = MAX(baseline, data.rgbcw[2]);
baseline = MAX(baseline, data.rgbcw[3]);
Expand Down
14 changes: 4 additions & 10 deletions examples/lighting/lightbulb/main/lightbulb_example_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
const char *TAG = "lightbulb demo";

//Based on PWM test 5ch (rgbcw)
#define TEST_PWM_RGBCW_LIGHTBULB 1
#define PWM_C_GPIO 5
#define PWM_W_GPIO 4

//Based on BP5758D test 5ch (rgbww)
#define TEST_IIC_RGBWW_LIGHTBULB 1
#define MIX_TABLE_SIZE 15
lightbulb_cct_mapping_data_t table[MIX_TABLE_SIZE] = {
{.cct_kelvin = 2200, .cct_percentage = 0, .rgbcw = {0.547, 0.0, 0.0, 0.0, 0.453}},
Expand Down Expand Up @@ -102,8 +100,8 @@ void app_main(void)
.type = DRIVER_BP57x8D,
.driver_conf.bp57x8d.freq_khz = 300,
.driver_conf.bp57x8d.enable_iic_queue = true,
.driver_conf.bp57x8d.iic_clk = 3,
.driver_conf.bp57x8d.iic_sda = 7,
.driver_conf.bp57x8d.iic_clk = CONFIG_BP5758D_IIC_CLK_GPIO,
.driver_conf.bp57x8d.iic_sda = CONFIG_BP5758D_IIC_SDA_GPIO,
.driver_conf.bp57x8d.current = {10, 10, 10, 30, 30},
#endif
// 2. Configure the drive capability
Expand All @@ -114,11 +112,7 @@ void app_main(void)
#if CONFIG_LIGHTBULB_DEMO_DRIVER_SELECT_WS2812
.capability.led_beads = LED_BEADS_3CH_RGB,
#elif CONFIG_LIGHTBULB_DEMO_DRIVER_SELECT_BP5758D
#if TEST_IIC_RGBWW_LIGHTBULB
.capability.led_beads = LED_BEADS_5CH_RGBCW,
#else
.capability.led_beads = LED_BEADS_5CH_RGBCW,
#endif
#elif CONFIG_LIGHTBULB_DEMO_DRIVER_SELECT_PWM && TEST_PWM_RGBCW_LIGHTBULB
.capability.led_beads = LED_BEADS_5CH_RGBCW,
#else
Expand All @@ -135,8 +129,8 @@ void app_main(void)
.io_conf.pwm_io.warm_brightness = PWM_W_GPIO,
#endif
#ifdef CONFIG_LIGHTBULB_DEMO_DRIVER_SELECT_BP5758D
.io_conf.iic_io.red = OUT1,
.io_conf.iic_io.green = OUT2,
.io_conf.iic_io.red = OUT2,
.io_conf.iic_io.green = OUT1,
.io_conf.iic_io.blue = OUT3,
.io_conf.iic_io.cold_white = OUT5,
.io_conf.iic_io.warm_yellow = OUT4,
Expand Down

0 comments on commit db24130

Please sign in to comment.