diff --git a/bsp/esp32_c3_lcdkit/esp32_c3_lcdkit.c b/bsp/esp32_c3_lcdkit/esp32_c3_lcdkit.c index bfa1fc2b6..e74b5ba39 100644 --- a/bsp/esp32_c3_lcdkit/esp32_c3_lcdkit.c +++ b/bsp/esp32_c3_lcdkit/esp32_c3_lcdkit.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -23,6 +23,7 @@ #include "bsp_err_check.h" #include "esp_lcd_gc9a01.h" #include "iot_knob.h" +#include "button_gpio.h" #include "esp_lvgl_port.h" #include "esp_codec_dev_defaults.h" @@ -78,10 +79,9 @@ static const led_strip_rmt_config_t bsp_rmt_config = { .flags.with_dma = false, }; -static const button_config_t bsp_encoder_btn_config = { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.active_level = false, - .gpio_button_config.gpio_num = BSP_BTN_PRESS, +static const button_gpio_config_t bsp_encoder_btn_config = { + .gpio_num = BSP_BTN_PRESS, + .active_level = 0, }; static const knob_config_t bsp_encoder_a_b_config = { @@ -241,10 +241,15 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg) static lv_indev_t *bsp_display_indev_init(lv_display_t *disp) { + + const button_config_t btn_cfg = {0}; + button_handle_t encoder_btn = NULL; + BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &bsp_encoder_btn_config, &encoder_btn)); + const lvgl_port_encoder_cfg_t encoder = { .disp = disp, .encoder_a_b = &bsp_encoder_a_b_config, - .encoder_enter = &bsp_encoder_btn_config + .encoder_enter = encoder_btn }; return lvgl_port_add_encoder(&encoder); diff --git a/bsp/esp32_c3_lcdkit/idf_component.yml b/bsp/esp32_c3_lcdkit/idf_component.yml index a054411a3..2351b31cb 100644 --- a/bsp/esp32_c3_lcdkit/idf_component.yml +++ b/bsp/esp32_c3_lcdkit/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.1.0~1" +version: "1.2.0" description: Board Support Package (BSP) for esp32_c3_lcdkit url: https://github.com/espressif/esp-bsp/tree/master/bsp/esp32_c3_lcdkit @@ -26,7 +26,7 @@ dependencies: button: public: true - version: ">=2,<4.0" + version: ">=4,<5.0" knob: version: "^0.1.3" diff --git a/bsp/m5dial/README.md b/bsp/m5dial/README.md index 9037cb388..1ddf12a12 100644 --- a/bsp/m5dial/README.md +++ b/bsp/m5dial/README.md @@ -25,7 +25,7 @@ M5Dial provides versatile power supply options to cater to various needs. It acc | DISPLAY |:heavy_check_mark:| [espressif/esp_lcd_gc9a01](https://components.espressif.com/components/espressif/esp_lcd_gc9a01) | ^1 | | LVGL_PORT |:heavy_check_mark:| [espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port) | ^2 | | TOUCH |:heavy_check_mark:|[espressif/esp_lcd_touch_ft5x06](https://components.espressif.com/components/espressif/esp_lcd_touch_ft5x06)| ^1 | -| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=2,<4.0| +| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=4,<5.0| | KNOB |:heavy_check_mark:| [espressif/knob](https://components.espressif.com/components/espressif/knob) | ^0.1.3 | | AUDIO | :x: | | | |AUDIO_SPEAKER| :x: | | | diff --git a/bsp/m5dial/idf_component.yml b/bsp/m5dial/idf_component.yml index 5228b7752..183f47678 100644 --- a/bsp/m5dial/idf_component.yml +++ b/bsp/m5dial/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.0.0" +version: "1.1.0" description: Board Support Package (BSP) for M5Dial url: https://github.com/espressif/esp-bsp/tree/master/bsp/m5dial @@ -16,10 +16,11 @@ dependencies: espressif/esp_lvgl_port: version: "^2" public: true + override_path: "../../components/esp_lvgl_port" button: public: true - version: ">=2,<4.0" + version: ">=4,<5.0" knob: version: "^0.1.3" diff --git a/bsp/m5dial/m5dial.c b/bsp/m5dial/m5dial.c index fe4820ff5..4c878d17e 100644 --- a/bsp/m5dial/m5dial.c +++ b/bsp/m5dial/m5dial.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -21,6 +21,7 @@ #include "bsp/display.h" #include "bsp/touch.h" #include "iot_knob.h" +#include "button_gpio.h" #include "esp_lcd_gc9a01.h" #include "esp_lcd_touch_ft5x06.h" #include "esp_lvgl_port.h" @@ -37,10 +38,9 @@ static esp_lcd_touch_handle_t tp; // LCD touch handle static bool i2c_initialized = false; static bool spi_initialized = false; -static const button_config_t bsp_encoder_btn_config = { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.active_level = false, - .gpio_button_config.gpio_num = BSP_BTN_PRESS, +static const button_gpio_config_t bsp_encoder_btn_config = { + .gpio_num = BSP_BTN_PRESS, + .active_level = 0, }; static const knob_config_t bsp_encoder_a_b_config = { @@ -307,10 +307,15 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg) static lv_indev_t *bsp_display_indev_encoder_init(lv_display_t *disp) { + + const button_config_t btn_cfg = {0}; + button_handle_t encoder_btn = NULL; + BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &bsp_encoder_btn_config, &encoder_btn)); + const lvgl_port_encoder_cfg_t encoder = { .disp = disp, .encoder_a_b = &bsp_encoder_a_b_config, - .encoder_enter = &bsp_encoder_btn_config + .encoder_enter = encoder_btn }; return lvgl_port_add_encoder(&encoder); diff --git a/bsp/m5stack_core/README.md b/bsp/m5stack_core/README.md index 7383ae40e..19aa6abfe 100644 --- a/bsp/m5stack_core/README.md +++ b/bsp/m5stack_core/README.md @@ -30,15 +30,15 @@ M5Stack Core is a development board based on ESP32 microcontroller. It features: ### Capabilities and dependencies -| Capability | Available | Component |Version| -|-------------|------------------|--------------------------------------------------------------------------------------------------|-------| -| DISPLAY |:heavy_check_mark:|[espressif/esp_lcd_ili9341](https://components.espressif.com/components/espressif/esp_lcd_ili9341)| ^1 | -| LVGL_PORT |:heavy_check_mark:| [espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port) | ^2 | -| TOUCH | :x: | | | -| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | ^2.4 | -| AUDIO | :x: | | | -|AUDIO_SPEAKER|:heavy_check_mark:| | | -| AUDIO_MIC | :x: | | | -| SDCARD |:heavy_check_mark:| idf | >=5.2 | -| IMU | :x: | | | +| Capability | Available | Component | Version| +|-------------|------------------|--------------------------------------------------------------------------------------------------|--------| +| DISPLAY |:heavy_check_mark:|[espressif/esp_lcd_ili9341](https://components.espressif.com/components/espressif/esp_lcd_ili9341)| ^1 | +| LVGL_PORT |:heavy_check_mark:| [espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port) | ^2 | +| TOUCH | :x: | | | +| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=4,<5.0| +| AUDIO | :x: | | | +|AUDIO_SPEAKER|:heavy_check_mark:| | | +| AUDIO_MIC | :x: | | | +| SDCARD |:heavy_check_mark:| idf | >=5.2 | +| IMU | :x: | | | diff --git a/bsp/m5stack_core/idf_component.yml b/bsp/m5stack_core/idf_component.yml index d76f68411..8b0af339d 100644 --- a/bsp/m5stack_core/idf_component.yml +++ b/bsp/m5stack_core/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.0.0" +version: "1.1.0" description: Board Support Package (BSP) for M5Stack Core url: https://github.com/espressif/esp-bsp/tree/master/bsp/m5stack_core @@ -13,9 +13,10 @@ dependencies: esp_lcd_ili9341: "^1" button: - version: "^2.4" + version: ">=4,<5.0" public: true - + espressif/esp_lvgl_port: version: "^2" public: true + override_path: "../../components/esp_lvgl_port" diff --git a/bsp/m5stack_core/m5stack_core.c b/bsp/m5stack_core/m5stack_core.c index 3811e8f1a..d96d8db35 100644 --- a/bsp/m5stack_core/m5stack_core.c +++ b/bsp/m5stack_core/m5stack_core.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -25,6 +25,7 @@ #include "bsp/display.h" #include "esp_lcd_ili9341.h" #include "bsp_err_check.h" +#include "button_gpio.h" static const char *TAG = "M5Stack"; @@ -363,31 +364,36 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg) return lvgl_port_add_disp(&disp_cfg); } -static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { +static const button_gpio_config_t bsp_button_config[BSP_BUTTON_NUM] = { { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.active_level = false, - .gpio_button_config.gpio_num = BSP_BUTTON_LEFT, + .gpio_num = BSP_BUTTON_LEFT, + .active_level = 0, }, { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.active_level = false, - .gpio_button_config.gpio_num = BSP_BUTTON_MIDDLE, + .gpio_num = BSP_BUTTON_MIDDLE, + .active_level = 0, }, { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.active_level = false, - .gpio_button_config.gpio_num = BSP_BUTTON_RIGHT, + .gpio_num = BSP_BUTTON_RIGHT, + .active_level = 0, }, }; static lv_indev_t *bsp_display_indev_init(lv_display_t *disp) { + const button_config_t btn_cfg = {0}; + button_handle_t prev_btn = NULL; + button_handle_t next_btn = NULL; + button_handle_t enter_btn = NULL; + BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[BSP_BUTTON_PREV], &prev_btn)); + BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[BSP_BUTTON_NEXT], &next_btn)); + BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[BSP_BUTTON_ENTER], &enter_btn)); + const lvgl_port_nav_btns_cfg_t btns = { .disp = disp, - .button_prev = &bsp_button_config[BSP_BUTTON_PREV], - .button_next = &bsp_button_config[BSP_BUTTON_NEXT], - .button_enter = &bsp_button_config[BSP_BUTTON_ENTER] + .button_prev = prev_btn, + .button_next = next_btn, + .button_enter = enter_btn }; return lvgl_port_add_navigation_buttons(&btns); @@ -455,8 +461,9 @@ esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int b if (btn_cnt) { *btn_cnt = 0; } + const button_config_t btn_cfg = {0}; for (int i = 0; i < BSP_BUTTON_NUM; i++) { - btn_array[i] = iot_button_create(&bsp_button_config[i]); + ret |= iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[i], &btn_array[i]); if (btn_array[i] == NULL) { ret = ESP_FAIL; break; diff --git a/components/esp_lvgl_port/CHANGELOG.md b/components/esp_lvgl_port/CHANGELOG.md index ed3d600bc..2d3ed274e 100644 --- a/components/esp_lvgl_port/CHANGELOG.md +++ b/components/esp_lvgl_port/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 2.5.0 + +### Features (Breaking change) +- Updated LVGL port for using IoT button component v4 (LVGL port not anymore creating button, need to be created in app and included handle to LVGL port) + +### Fixes +- Fixed buffer size by selected color format + ## 2.4.4 ### Features diff --git a/components/esp_lvgl_port/CMakeLists.txt b/components/esp_lvgl_port/CMakeLists.txt index 4a84cbf01..6ca8eacd0 100644 --- a/components/esp_lvgl_port/CMakeLists.txt +++ b/components/esp_lvgl_port/CMakeLists.txt @@ -46,10 +46,14 @@ idf_build_get_property(build_components BUILD_COMPONENTS) if("espressif__button" IN_LIST build_components) list(APPEND ADD_SRCS "${PORT_PATH}/esp_lvgl_port_button.c") list(APPEND ADD_LIBS idf::espressif__button) + + idf_component_get_property(button_ver espressif__button COMPONENT_VERSION) # Get the version from esp-idf build system endif() if("button" IN_LIST build_components) list(APPEND ADD_SRCS "${PORT_PATH}/esp_lvgl_port_button.c") list(APPEND ADD_LIBS idf::button) + + idf_component_get_property(button_ver button COMPONENT_VERSION) # Get the version from esp-idf build system endif() if("espressif__esp_lcd_touch" IN_LIST build_components) list(APPEND ADD_SRCS "${PORT_PATH}/esp_lvgl_port_touch.c") @@ -76,6 +80,16 @@ if("usb_host_hid" IN_LIST build_components) list(APPEND ADD_LIBS idf::usb_host_hid) endif() +if (NOT button_ver) + message("IOT button version is not set or empty!") + set(button_ver "4.0.0") +endif() + +#Get component button major version +string(REPLACE "." ";" BUTTON_VERSION_LIST ${button_ver}) +list(GET BUTTON_VERSION_LIST 0 button_ver_major) +add_definitions( "-DCOMPONENT_BUTTON_VERSION_MAJOR=${button_ver_major}" ) + # Include SIMD assembly source code for rendering, only for (9.1.0 <= LVG_version < 9.2.0) and only for esp32 and esp32s3 if((lvgl_ver VERSION_GREATER_EQUAL "9.1.0") AND (lvgl_ver VERSION_LESS "9.2.0")) if(CONFIG_IDF_TARGET_ESP32 OR CONFIG_IDF_TARGET_ESP32S3) diff --git a/components/esp_lvgl_port/README.md b/components/esp_lvgl_port/README.md index c4a2b4baf..f51324ccd 100644 --- a/components/esp_lvgl_port/README.md +++ b/components/esp_lvgl_port/README.md @@ -113,35 +113,35 @@ Add touch input to the LVGL. It can be called more times for adding more touch i Add buttons input to the LVGL. It can be called more times for adding more buttons inputs for different displays. This feature is available only when the component `espressif/button` was added into the project. ``` c /* Buttons configuration structure */ - const button_config_t bsp_button_config[] = { + const button_gpio_config_t bsp_button_config[] = { { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_channel = ADC_CHANNEL_0, // ADC1 channel 0 is GPIO1 - .adc_button_config.button_index = 0, - .adc_button_config.min = 2310, // middle is 2410mV - .adc_button_config.max = 2510 + .gpio_num = GPIO_NUM_37, + .active_level = 0, }, { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_channel = ADC_CHANNEL_0, // ADC1 channel 0 is GPIO1 - .adc_button_config.button_index = 1, - .adc_button_config.min = 1880, // middle is 1980mV - .adc_button_config.max = 2080 + .gpio_num = GPIO_NUM_38, + .active_level = 0, }, { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_channel = ADC_CHANNEL_0, // ADC1 channel 0 is GPIO1 - .adc_button_config.button_index = 2, - .adc_button_config.min = 720, // middle is 820mV - .adc_button_config.max = 920 + .gpio_num = GPIO_NUM_39, + .active_level = 0, }, }; + + const button_config_t btn_cfg = {0}; + button_handle_t prev_btn_handle = NULL; + button_handle_t next_btn_handle = NULL; + button_handle_t enter_btn_handle = NULL; + iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[0], &prev_btn_handle); + iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[1], &next_btn_handle); + iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[2], &enter_btn_handle); + const lvgl_port_nav_btns_cfg_t btns = { .disp = disp_handle, - .button_prev = &bsp_button_config[0], - .button_next = &bsp_button_config[1], - .button_enter = &bsp_button_config[2] + .button_prev = prev_btn_handle, + .button_next = next_btn_handle, + .button_enter = enter_btn_handle }; /* Add buttons input (for selected screen) */ @@ -160,10 +160,9 @@ Add buttons input to the LVGL. It can be called more times for adding more butto Add encoder input to the LVGL. It can be called more times for adding more encoder inputs for different displays. This feature is available only when the component `espressif/knob` was added into the project. ``` c - const button_config_t encoder_btn_config = { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.active_level = false, - .gpio_button_config.gpio_num = GPIO_BTN_PRESS, + static const button_gpio_config_t encoder_btn_config = { + .gpio_num = GPIO_BTN_PRESS, + .active_level = 0, }; const knob_config_t encoder_a_b_config = { @@ -172,11 +171,15 @@ Add encoder input to the LVGL. It can be called more times for adding more encod .gpio_encoder_b = GPIO_ENCODER_B, }; + const button_config_t btn_cfg = {0}; + button_handle_t encoder_btn_handle = NULL; + BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &encoder_btn_config, &encoder_btn_handle)); + /* Encoder configuration structure */ const lvgl_port_encoder_cfg_t encoder = { .disp = disp_handle, .encoder_a_b = &encoder_a_b_config, - .encoder_enter = &encoder_btn_config + .encoder_enter = encoder_btn_handle }; /* Add encoder input (for selected screen) */ diff --git a/components/esp_lvgl_port/idf_component.yml b/components/esp_lvgl_port/idf_component.yml index aed2f92d7..2bf8d6ea0 100644 --- a/components/esp_lvgl_port/idf_component.yml +++ b/components/esp_lvgl_port/idf_component.yml @@ -1,4 +1,4 @@ -version: "2.4.4" +version: "2.5.0" description: ESP LVGL port url: https://github.com/espressif/esp-bsp/tree/master/components/esp_lvgl_port dependencies: diff --git a/components/esp_lvgl_port/include/esp_lvgl_port_button.h b/components/esp_lvgl_port/include/esp_lvgl_port_button.h index e7b275cb1..59b6251ac 100644 --- a/components/esp_lvgl_port/include/esp_lvgl_port_button.h +++ b/components/esp_lvgl_port/include/esp_lvgl_port_button.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -32,10 +32,10 @@ extern "C" { * @brief Configuration of the navigation buttons structure */ typedef struct { - lv_display_t *disp; /*!< LVGL display handle (returned from lvgl_port_add_disp) */ - const button_config_t *button_prev; /*!< Navigation button for previous */ - const button_config_t *button_next; /*!< Navigation button for next */ - const button_config_t *button_enter; /*!< Navigation button for enter */ + lv_display_t *disp; /*!< LVGL display handle (returned from lvgl_port_add_disp) */ + button_handle_t button_prev; /*!< Handle for navigation button for previous */ + button_handle_t button_next; /*!< Handle for navigation button for next */ + button_handle_t button_enter; /*!< Handle for navigation button for enter */ } lvgl_port_nav_btns_cfg_t; /** diff --git a/components/esp_lvgl_port/include/esp_lvgl_port_knob.h b/components/esp_lvgl_port/include/esp_lvgl_port_knob.h index 47b667fb6..f10fc71c3 100644 --- a/components/esp_lvgl_port/include/esp_lvgl_port_knob.h +++ b/components/esp_lvgl_port/include/esp_lvgl_port_knob.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -36,9 +36,9 @@ extern "C" { * @brief Configuration of the encoder structure */ typedef struct { - lv_display_t *disp; /*!< LVGL display handle (returned from lvgl_port_add_disp) */ - const knob_config_t *encoder_a_b; - const button_config_t *encoder_enter; /*!< Navigation button for enter */ + lv_display_t *disp; /*!< LVGL display handle (returned from lvgl_port_add_disp) */ + const knob_config_t *encoder_a_b; /*!< Encoder knob configuration */ + button_handle_t encoder_enter; /*!< Handle for enter button */ } lvgl_port_encoder_cfg_t; /** diff --git a/components/esp_lvgl_port/src/lvgl8/esp_lvgl_port_button.c b/components/esp_lvgl_port/src/lvgl8/esp_lvgl_port_button.c index 757824647..5af171a50 100644 --- a/components/esp_lvgl_port/src/lvgl8/esp_lvgl_port_button.c +++ b/components/esp_lvgl_port/src/lvgl8/esp_lvgl_port_button.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -56,28 +56,21 @@ lv_indev_t *lvgl_port_add_navigation_buttons(const lvgl_port_nav_btns_cfg_t *but return NULL; } - /* Previous button */ - if (buttons_cfg->button_prev != NULL) { - buttons_ctx->btn[LVGL_PORT_NAV_BTN_PREV] = iot_button_create(buttons_cfg->button_prev); - ESP_GOTO_ON_FALSE(buttons_ctx->btn[LVGL_PORT_NAV_BTN_PREV], ESP_ERR_NO_MEM, err, TAG, "Not enough memory for button create!"); - } - - /* Next button */ - if (buttons_cfg->button_next != NULL) { - buttons_ctx->btn[LVGL_PORT_NAV_BTN_NEXT] = iot_button_create(buttons_cfg->button_next); - ESP_GOTO_ON_FALSE(buttons_ctx->btn[LVGL_PORT_NAV_BTN_NEXT], ESP_ERR_NO_MEM, err, TAG, "Not enough memory for button create!"); - } + ESP_GOTO_ON_FALSE(buttons_cfg->button_prev && buttons_cfg->button_next && buttons_cfg->button_enter, ESP_ERR_INVALID_ARG, err, TAG, "Invalid some button handler!"); - /* Enter button */ - if (buttons_cfg->button_enter != NULL) { - buttons_ctx->btn[LVGL_PORT_NAV_BTN_ENTER] = iot_button_create(buttons_cfg->button_enter); - ESP_GOTO_ON_FALSE(buttons_ctx->btn[LVGL_PORT_NAV_BTN_ENTER], ESP_ERR_NO_MEM, err, TAG, "Not enough memory for button create!"); - } + buttons_ctx->btn[LVGL_PORT_NAV_BTN_PREV] = buttons_cfg->button_prev; + buttons_ctx->btn[LVGL_PORT_NAV_BTN_NEXT] = buttons_cfg->button_next; + buttons_ctx->btn[LVGL_PORT_NAV_BTN_ENTER] = buttons_cfg->button_enter; /* Button handlers */ for (int i = 0; i < LVGL_PORT_NAV_BTN_CNT; i++) { +#if COMPONENT_BUTTON_VERSION_MAJOR < 4 ESP_ERROR_CHECK(iot_button_register_cb(buttons_ctx->btn[i], BUTTON_PRESS_DOWN, lvgl_port_btn_down_handler, buttons_ctx)); ESP_ERROR_CHECK(iot_button_register_cb(buttons_ctx->btn[i], BUTTON_PRESS_UP, lvgl_port_btn_up_handler, buttons_ctx)); +#else + ESP_ERROR_CHECK(iot_button_register_cb(buttons_ctx->btn[i], BUTTON_PRESS_DOWN, NULL, lvgl_port_btn_down_handler, buttons_ctx)); + ESP_ERROR_CHECK(iot_button_register_cb(buttons_ctx->btn[i], BUTTON_PRESS_UP, NULL, lvgl_port_btn_up_handler, buttons_ctx)); +#endif } buttons_ctx->btn_prev = false; diff --git a/components/esp_lvgl_port/src/lvgl8/esp_lvgl_port_knob.c b/components/esp_lvgl_port/src/lvgl8/esp_lvgl_port_knob.c index dfbc9ecf8..20340d7f7 100644 --- a/components/esp_lvgl_port/src/lvgl8/esp_lvgl_port_knob.c +++ b/components/esp_lvgl_port/src/lvgl8/esp_lvgl_port_knob.c @@ -63,12 +63,17 @@ lv_indev_t *lvgl_port_add_encoder(const lvgl_port_encoder_cfg_t *encoder_cfg) /* Encoder Enter */ if (encoder_cfg->encoder_enter != NULL) { - encoder_ctx->btn_handle = iot_button_create(encoder_cfg->encoder_enter); - ESP_GOTO_ON_FALSE(encoder_ctx->btn_handle, ESP_ERR_NO_MEM, err, TAG, "Not enough memory for button create!"); + ESP_GOTO_ON_FALSE(encoder_cfg->encoder_enter, ESP_ERR_INVALID_ARG, err, TAG, "Invalid button handler!"); + encoder_ctx->btn_handle = encoder_cfg->encoder_enter; } +#if COMPONENT_BUTTON_VERSION_MAJOR < 4 ESP_ERROR_CHECK(iot_button_register_cb(encoder_ctx->btn_handle, BUTTON_PRESS_DOWN, lvgl_port_encoder_btn_down_handler, encoder_ctx)); ESP_ERROR_CHECK(iot_button_register_cb(encoder_ctx->btn_handle, BUTTON_PRESS_UP, lvgl_port_encoder_btn_up_handler, encoder_ctx)); +#else + ESP_ERROR_CHECK(iot_button_register_cb(encoder_ctx->btn_handle, BUTTON_PRESS_DOWN, NULL, lvgl_port_encoder_btn_down_handler, encoder_ctx)); + ESP_ERROR_CHECK(iot_button_register_cb(encoder_ctx->btn_handle, BUTTON_PRESS_UP, NULL, lvgl_port_encoder_btn_up_handler, encoder_ctx)); +#endif encoder_ctx->btn_enter = false; encoder_ctx->diff = 0; diff --git a/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_button.c b/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_button.c index 39f6967fc..5c8e2ff92 100644 --- a/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_button.c +++ b/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_button.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -56,28 +56,22 @@ lv_indev_t *lvgl_port_add_navigation_buttons(const lvgl_port_nav_btns_cfg_t *but return NULL; } - /* Previous button */ - if (buttons_cfg->button_prev != NULL) { - buttons_ctx->btn[LVGL_PORT_NAV_BTN_PREV] = iot_button_create(buttons_cfg->button_prev); - ESP_GOTO_ON_FALSE(buttons_ctx->btn[LVGL_PORT_NAV_BTN_PREV], ESP_ERR_NO_MEM, err, TAG, "Not enough memory for button create!"); - } + ESP_GOTO_ON_FALSE(buttons_cfg->button_prev && buttons_cfg->button_next && buttons_cfg->button_enter, ESP_ERR_INVALID_ARG, err, TAG, "Invalid some button handler!"); - /* Next button */ - if (buttons_cfg->button_next != NULL) { - buttons_ctx->btn[LVGL_PORT_NAV_BTN_NEXT] = iot_button_create(buttons_cfg->button_next); - ESP_GOTO_ON_FALSE(buttons_ctx->btn[LVGL_PORT_NAV_BTN_NEXT], ESP_ERR_NO_MEM, err, TAG, "Not enough memory for button create!"); - } - - /* Enter button */ - if (buttons_cfg->button_enter != NULL) { - buttons_ctx->btn[LVGL_PORT_NAV_BTN_ENTER] = iot_button_create(buttons_cfg->button_enter); - ESP_GOTO_ON_FALSE(buttons_ctx->btn[LVGL_PORT_NAV_BTN_ENTER], ESP_ERR_NO_MEM, err, TAG, "Not enough memory for button create!"); - } + buttons_ctx->btn[LVGL_PORT_NAV_BTN_PREV] = buttons_cfg->button_prev; + buttons_ctx->btn[LVGL_PORT_NAV_BTN_NEXT] = buttons_cfg->button_next; + buttons_ctx->btn[LVGL_PORT_NAV_BTN_ENTER] = buttons_cfg->button_enter; /* Button handlers */ for (int i = 0; i < LVGL_PORT_NAV_BTN_CNT; i++) { + +#if COMPONENT_BUTTON_VERSION_MAJOR < 4 ESP_ERROR_CHECK(iot_button_register_cb(buttons_ctx->btn[i], BUTTON_PRESS_DOWN, lvgl_port_btn_down_handler, buttons_ctx)); ESP_ERROR_CHECK(iot_button_register_cb(buttons_ctx->btn[i], BUTTON_PRESS_UP, lvgl_port_btn_up_handler, buttons_ctx)); +#else + ESP_ERROR_CHECK(iot_button_register_cb(buttons_ctx->btn[i], BUTTON_PRESS_DOWN, NULL, lvgl_port_btn_down_handler, buttons_ctx)); + ESP_ERROR_CHECK(iot_button_register_cb(buttons_ctx->btn[i], BUTTON_PRESS_UP, NULL, lvgl_port_btn_up_handler, buttons_ctx)); +#endif } buttons_ctx->btn_prev = false; diff --git a/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_knob.c b/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_knob.c index db05992ce..69a7b675a 100644 --- a/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_knob.c +++ b/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_knob.c @@ -28,8 +28,8 @@ typedef struct { *******************************************************************************/ static void lvgl_port_encoder_read(lv_indev_t *indev_drv, lv_indev_data_t *data); -static void lvgl_port_encoder_btn_down_handler(void *arg, void *arg2); -static void lvgl_port_encoder_btn_up_handler(void *arg, void *arg2); +static void lvgl_port_encoder_btn_down_handler(void *button_handle, void *usr_data); +static void lvgl_port_encoder_btn_up_handler(void *button_handle, void *usr_data); static void lvgl_port_encoder_left_handler(void *arg, void *arg2); static void lvgl_port_encoder_right_handler(void *arg, void *arg2); static int32_t lvgl_port_calculate_diff(knob_handle_t knob, knob_event_t event); @@ -63,12 +63,17 @@ lv_indev_t *lvgl_port_add_encoder(const lvgl_port_encoder_cfg_t *encoder_cfg) /* Encoder Enter */ if (encoder_cfg->encoder_enter != NULL) { - encoder_ctx->btn_handle = iot_button_create(encoder_cfg->encoder_enter); - ESP_GOTO_ON_FALSE(encoder_ctx->btn_handle, ESP_ERR_NO_MEM, err, TAG, "Not enough memory for button create!"); + ESP_GOTO_ON_FALSE(encoder_cfg->encoder_enter, ESP_ERR_INVALID_ARG, err, TAG, "Invalid button handler!"); + encoder_ctx->btn_handle = encoder_cfg->encoder_enter; } +#if COMPONENT_BUTTON_VERSION_MAJOR < 4 ESP_ERROR_CHECK(iot_button_register_cb(encoder_ctx->btn_handle, BUTTON_PRESS_DOWN, lvgl_port_encoder_btn_down_handler, encoder_ctx)); ESP_ERROR_CHECK(iot_button_register_cb(encoder_ctx->btn_handle, BUTTON_PRESS_UP, lvgl_port_encoder_btn_up_handler, encoder_ctx)); +#else + ESP_ERROR_CHECK(iot_button_register_cb(encoder_ctx->btn_handle, BUTTON_PRESS_DOWN, NULL, lvgl_port_encoder_btn_down_handler, encoder_ctx)); + ESP_ERROR_CHECK(iot_button_register_cb(encoder_ctx->btn_handle, BUTTON_PRESS_UP, NULL, lvgl_port_encoder_btn_up_handler, encoder_ctx)); +#endif encoder_ctx->btn_enter = false; encoder_ctx->diff = 0; @@ -143,10 +148,10 @@ static void lvgl_port_encoder_read(lv_indev_t *indev_drv, lv_indev_data_t *data) ctx->diff = 0; } -static void lvgl_port_encoder_btn_down_handler(void *arg, void *arg2) +static void lvgl_port_encoder_btn_down_handler(void *button_handle, void *usr_data) { - lvgl_port_encoder_ctx_t *ctx = (lvgl_port_encoder_ctx_t *) arg2; - button_handle_t button = (button_handle_t)arg; + lvgl_port_encoder_ctx_t *ctx = (lvgl_port_encoder_ctx_t *) usr_data; + button_handle_t button = (button_handle_t)button_handle; if (ctx && button) { /* ENTER */ if (button == ctx->btn_handle) { @@ -158,10 +163,10 @@ static void lvgl_port_encoder_btn_down_handler(void *arg, void *arg2) lvgl_port_task_wake(LVGL_PORT_EVENT_TOUCH, ctx->indev); } -static void lvgl_port_encoder_btn_up_handler(void *arg, void *arg2) +static void lvgl_port_encoder_btn_up_handler(void *button_handle, void *usr_data) { - lvgl_port_encoder_ctx_t *ctx = (lvgl_port_encoder_ctx_t *) arg2; - button_handle_t button = (button_handle_t)arg; + lvgl_port_encoder_ctx_t *ctx = (lvgl_port_encoder_ctx_t *) usr_data; + button_handle_t button = (button_handle_t)button_handle; if (ctx && button) { /* ENTER */ if (button == ctx->btn_handle) { diff --git a/examples/display_rotation/sdkconfig.bsp.m5stack_core b/examples/display_rotation/sdkconfig.bsp.m5stack_core new file mode 100644 index 000000000..636599d69 --- /dev/null +++ b/examples/display_rotation/sdkconfig.bsp.m5stack_core @@ -0,0 +1,25 @@ +# This file was generated using idf.py save-defconfig. It can be edited manually. +# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration +# +CONFIG_IDF_TARGET="esp32" +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESP_DEFAULT_CPU_FREQ_240=y + +## LVGL8 ## +CONFIG_LV_USE_PERF_MONITOR=y +CONFIG_LV_COLOR_16_SWAP=y +CONFIG_LV_MEM_CUSTOM=y +CONFIG_LV_MEMCPY_MEMSET_STD=y + +## LVGL9 ## +CONFIG_LV_CONF_SKIP=y + +#CLIB default +CONFIG_LV_USE_CLIB_MALLOC=y +CONFIG_LV_USE_CLIB_SPRINTF=y +CONFIG_LV_USE_CLIB_STRING=y + +# Performance monitor +CONFIG_LV_USE_OBSERVER=y +CONFIG_LV_USE_SYSMON=y +CONFIG_LV_USE_PERF_MONITOR=y