diff --git a/components/led/lightbulb_driver/CHANGELOG.md b/components/led/lightbulb_driver/CHANGELOG.md index e69fb2107..dbc6ddf1e 100644 --- a/components/led/lightbulb_driver/CHANGELOG.md +++ b/components/led/lightbulb_driver/CHANGELOG.md @@ -1,5 +1,12 @@ # ChangeLog +## v1.1.4 - 2024-05-07 + +### Bug Fixes: + +* Reconfigure KP18052 parameters +* When the IIC dimming gray scale data size is 0, skip sending the data and only send the address. + ## v1.1.3 - 2024-04-24 ### Bug Fixes: diff --git a/components/led/lightbulb_driver/drivers/common/iic/iic.c b/components/led/lightbulb_driver/drivers/common/iic/iic.c index ad77be9ab..e03a5926c 100644 --- a/components/led/lightbulb_driver/drivers/common/iic/iic.c +++ b/components/led/lightbulb_driver/drivers/common/iic/iic.c @@ -56,14 +56,18 @@ static iic_config_t *s_obj = NULL; static esp_err_t _write(uint8_t addr, uint8_t *data_wr, size_t size) { #if 0 + printf("--------start----------\r\n"); ESP_LOG_BUFFER_HEX_LEVEL(" _write addr:", &addr, 1, ESP_LOG_INFO); ESP_LOG_BUFFER_HEX_LEVEL(" _write data:", data_wr, size, ESP_LOG_INFO); - printf("--------------------\r\n"); + printf("--------stop----------\r\n"); #endif i2c_cmd_handle_t cmd = i2c_cmd_link_create(); i2c_master_start(cmd); i2c_master_write_byte(cmd, addr, ACK_CHECK_DIS); - i2c_master_write(cmd, data_wr, size, ACK_CHECK_DIS); + // AEG-1520 + if (size > 0) { + i2c_master_write(cmd, data_wr, size, ACK_CHECK_DIS); + } i2c_master_stop(cmd); s_obj->last_err = i2c_master_cmd_begin(s_obj->i2c_master_num, cmd, pdMS_TO_TICKS(10)); i2c_cmd_link_delete(cmd); @@ -134,7 +138,10 @@ esp_err_t iic_driver_write(uint8_t addr, uint8_t *data_wr, size_t size) i2c_send_data_t data = { 0 }; data.addr = addr; data.real_data_size = size; - memcpy(data.data, data_wr, size); + //AEG-1520 + if (size > 0) { + memcpy(data.data, data_wr, size); + } if (xQueueSend(s_obj->cmd_queue_handle, &data, 0) != pdTRUE) { ESP_LOGE(TAG, "queue send data fail"); ESP_LOG_BUFFER_HEX_LEVEL(TAG, data_wr, size, ESP_LOG_DEBUG); @@ -165,7 +172,6 @@ esp_err_t iic_driver_send_task_create(void) esp_err_t iic_driver_task_destroy(void) { - DRIVER_CHECK(s_obj->cmd_queue_handle || s_obj->send_task_handle, "handle is null", return ESP_ERR_INVALID_STATE); clean_up(); return ESP_OK; } diff --git a/components/led/lightbulb_driver/drivers/kp18058/kp18058.c b/components/led/lightbulb_driver/drivers/kp18058/kp18058.c index c98eda691..c35f560ed 100644 --- a/components/led/lightbulb_driver/drivers/kp18058/kp18058.c +++ b/components/led/lightbulb_driver/drivers/kp18058/kp18058.c @@ -161,13 +161,13 @@ esp_err_t kp18058_set_standby_mode(bool enable_standby) { DRIVER_CHECK(s_kp18058, "not init", return ESP_ERR_INVALID_STATE); - uint8_t addr = BASE_ADDR | BIT_STANDBY | BIT_NEXT_BYTE4; - uint8_t value[13] = { 0 }; - - if (!enable_standby) { - addr |= BIT_ALL_CHANNEL; + uint8_t addr = 0x00; + uint8_t value[10] = { 0 }; + if (enable_standby) { + addr = BASE_ADDR | BIT_STANDBY | BIT_NEXT_BYTE4; + } else { + addr = BASE_ADDR | BIT_ALL_CHANNEL | BIT_NEXT_BYTE4; } - memcpy(&value[0], s_kp18058->fixed_bit, 3); return _write(addr, value, sizeof(value)); } @@ -303,12 +303,12 @@ kp18058_compensation_t kp18058_compensation_mapping(int voltage_v) { DRIVER_CHECK((voltage_v >= 140) && (voltage_v <= 330), "The compensation value is incorrect and cannot be mapped.", return KP18058_COMPENSATION_VOLTAGE_INVALID); - int voltages[15] = { - 140, 145, 150, 155, 160, 165, 170, + int voltages[16] = { + 140, 145, 150, 155, 160, 165, 170, 175, 260, 270, 280, 290, 300, 310, 320, 330 }; - for (size_t i = 0; i < 15; ++i) { + for (size_t i = 0; i < 16; ++i) { if (voltage_v == voltages[i]) { return (kp18058_compensation_t)i; } @@ -336,9 +336,9 @@ kp18058_slope_t kp18058_slope_mapping(float slope) kp18058_chopping_freq_t kp18058_chopping_freq_mapping(int freq_hz) { - DRIVER_CHECK((freq_hz >= 250) && (freq_hz <= 2000), "The slope value is incorrect and cannot be mapped.", return KP18058_CHOPPING_INVALID); + DRIVER_CHECK((freq_hz >= 500) && (freq_hz <= 4000), "The slope value is incorrect and cannot be mapped.", return KP18058_CHOPPING_INVALID); - int freqs[4] = {2000, 1000, 500, 250}; + int freqs[4] = {4000, 2000, 1000, 500}; for (size_t i = 0; i < 4; ++i) { if (freq_hz == freqs[i]) { diff --git a/components/led/lightbulb_driver/drivers/kp18058/kp18058.h b/components/led/lightbulb_driver/drivers/kp18058/kp18058.h index fab6da03f..9e9d50413 100644 --- a/components/led/lightbulb_driver/drivers/kp18058/kp18058.h +++ b/components/led/lightbulb_driver/drivers/kp18058/kp18058.h @@ -20,6 +20,7 @@ typedef enum { KP18058_COMPENSATION_VOLTAGE_160V, KP18058_COMPENSATION_VOLTAGE_165V, KP18058_COMPENSATION_VOLTAGE_170V, + KP18058_COMPENSATION_VOLTAGE_175V, KP18058_COMPENSATION_VOLTAGE_260V, KP18058_COMPENSATION_VOLTAGE_270V, KP18058_COMPENSATION_VOLTAGE_280V, @@ -48,10 +49,10 @@ typedef enum { */ typedef enum { KP18058_CHOPPING_INVALID = -1, - KP18058_CHOPPING_2KHZ = 0, + KP18058_CHOPPING_4KHZ = 0, + KP18058_CHOPPING_2KHZ, KP18058_CHOPPING_1KHZ, KP18058_CHOPPING_500HZ, - KP18058_CHOPPING_250HZ, } kp18058_chopping_freq_t; /** diff --git a/components/led/lightbulb_driver/idf_component.yml b/components/led/lightbulb_driver/idf_component.yml index f2dbb1b3f..3238851c8 100644 --- a/components/led/lightbulb_driver/idf_component.yml +++ b/components/led/lightbulb_driver/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.1.3" +version: "1.1.4" 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: diff --git a/components/led/lightbulb_driver/test_apps/main/lightbulb_driver_test.c b/components/led/lightbulb_driver/test_apps/main/lightbulb_driver_test.c index 9e7d8a8e6..c9c3884c8 100644 --- a/components/led/lightbulb_driver/test_apps/main/lightbulb_driver_test.c +++ b/components/led/lightbulb_driver/test_apps/main/lightbulb_driver_test.c @@ -490,11 +490,11 @@ TEST_CASE("BP1658CJ", "[Underlying Driver]") vTaskDelay(pdMS_TO_TICKS(100)); TEST_ASSERT_EQUAL(ESP_OK, bp1658cj_set_rgbcw_channel(255, 0, 0, 0, 0)); vTaskDelay(pdMS_TO_TICKS(100)); - //bp1658cj_set_sleep_mode(true); AEG-1520 + bp1658cj_set_sleep_mode(true); vTaskDelay(pdMS_TO_TICKS(100)); TEST_ASSERT_EQUAL(ESP_OK, bp1658cj_set_rgbcw_channel(0, 255, 0, 0, 0)); vTaskDelay(pdMS_TO_TICKS(100)); - //bp1658cj_set_sleep_mode(true); AEG-1520 + bp1658cj_set_sleep_mode(true); vTaskDelay(pdMS_TO_TICKS(100)); TEST_ASSERT_EQUAL(ESP_OK, bp1658cj_set_rgbcw_channel(0, 0, 255, 0, 0)); vTaskDelay(pdMS_TO_TICKS(100)); @@ -568,8 +568,8 @@ TEST_CASE("SM2x35EGH", "[Underlying Driver]") driver_sm2x35egh_t conf = { .rgb_current = SM2235EGH_CW_CURRENT_10MA, .cw_current = SM2235EGH_CW_CURRENT_40MA, - .iic_clk = 5, - .iic_sda = 4, + .iic_clk = 4, + .iic_sda = 3, .freq_khz = 300, .enable_iic_queue = true }; @@ -673,8 +673,8 @@ TEST_CASE("SM2x35EGH", "[Application Layer]") .type = DRIVER_SM2x35EGH, .driver_conf.sm2x35egh.rgb_current = SM2235EGH_RGB_CURRENT_20MA, .driver_conf.sm2x35egh.cw_current = SM2235EGH_CW_CURRENT_40MA, - .driver_conf.sm2x35egh.iic_clk = 5, - .driver_conf.sm2x35egh.iic_sda = 4, + .driver_conf.sm2x35egh.iic_clk = 4, + .driver_conf.sm2x35egh.iic_sda = 3, .driver_conf.sm2x35egh.freq_khz = 400, .driver_conf.sm2x35egh.enable_iic_queue = true, .capability.enable_fade = true, @@ -750,10 +750,10 @@ TEST_CASE("WS2812", "[Application Layer]") TEST_CASE("KP18058", "[Underlying Driver]") { driver_kp18058_t kp18058 = { - .rgb_current_multiple = 10, + .rgb_current_multiple = 3, .cw_current_multiple = 10, - .iic_clk = 5, - .iic_sda = 4, + .iic_clk = 4, + .iic_sda = 3, .iic_freq_khz = 300, .enable_iic_queue = true, }; @@ -844,8 +844,8 @@ TEST_CASE("KP18058", "[Underlying Driver]") TEST_ASSERT_EQUAL(KP18058_SLOPE_7_5, kp18058_slope_mapping(7.5)); TEST_ASSERT_EQUAL(KP18058_SLOPE_15_0, kp18058_slope_mapping(15)); TEST_ASSERT_EQUAL(KP18058_CHOPPING_INVALID, kp18058_chopping_freq_mapping(0)); - TEST_ASSERT_EQUAL(KP18058_CHOPPING_2KHZ, kp18058_chopping_freq_mapping(2000)); - TEST_ASSERT_EQUAL(KP18058_CHOPPING_250HZ, kp18058_chopping_freq_mapping(250)); + TEST_ASSERT_EQUAL(KP18058_CHOPPING_4KHZ, kp18058_chopping_freq_mapping(4000)); + TEST_ASSERT_EQUAL(KP18058_CHOPPING_500HZ, kp18058_chopping_freq_mapping(500)); //7. Deinit TEST_ASSERT_EQUAL(ESP_OK, kp18058_set_shutdown()); @@ -858,10 +858,10 @@ TEST_CASE("KP18058", "[Application Layer]") { lightbulb_config_t config = { .type = DRIVER_KP18058, - .driver_conf.kp18058.rgb_current_multiple = 15, - .driver_conf.kp18058.cw_current_multiple = 20, - .driver_conf.kp18058.iic_clk = 5, - .driver_conf.kp18058.iic_sda = 4, + .driver_conf.kp18058.rgb_current_multiple = 3, + .driver_conf.kp18058.cw_current_multiple = 10, + .driver_conf.kp18058.iic_clk = 4, + .driver_conf.kp18058.iic_sda = 3, .driver_conf.kp18058.iic_freq_khz = 300, .driver_conf.kp18058.enable_iic_queue = true, .capability.enable_fade = true, @@ -887,6 +887,7 @@ TEST_CASE("KP18058", "[Application Layer]") TEST_ASSERT_EQUAL(ESP_OK, lightbulb_init(&config)); vTaskDelay(pdMS_TO_TICKS(1000)); lightbulb_lighting_output_test(LIGHTING_BASIC_FIVE, 1000); + vTaskDelay(pdMS_TO_TICKS(2000)); TEST_ASSERT_EQUAL(ESP_OK, lightbulb_deinit()); } #endif