|
1 | 1 | /*
|
2 |
| - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD |
| 2 | + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD |
3 | 3 | *
|
4 | 4 | * SPDX-License-Identifier: Apache-2.0
|
5 | 5 | */
|
|
25 | 25 | #include "bsp/display.h"
|
26 | 26 | #include "esp_lcd_ili9341.h"
|
27 | 27 | #include "bsp_err_check.h"
|
| 28 | +#include "button_gpio.h" |
28 | 29 |
|
29 | 30 | static const char *TAG = "M5Stack";
|
30 | 31 |
|
@@ -363,31 +364,36 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg)
|
363 | 364 | return lvgl_port_add_disp(&disp_cfg);
|
364 | 365 | }
|
365 | 366 |
|
366 |
| -static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { |
| 367 | +static const button_gpio_config_t bsp_button_config[BSP_BUTTON_NUM] = { |
367 | 368 | {
|
368 |
| - .type = BUTTON_TYPE_GPIO, |
369 |
| - .gpio_button_config.active_level = false, |
370 |
| - .gpio_button_config.gpio_num = BSP_BUTTON_LEFT, |
| 369 | + .gpio_num = BSP_BUTTON_LEFT, |
| 370 | + .active_level = 0, |
371 | 371 | },
|
372 | 372 | {
|
373 |
| - .type = BUTTON_TYPE_GPIO, |
374 |
| - .gpio_button_config.active_level = false, |
375 |
| - .gpio_button_config.gpio_num = BSP_BUTTON_MIDDLE, |
| 373 | + .gpio_num = BSP_BUTTON_MIDDLE, |
| 374 | + .active_level = 0, |
376 | 375 | },
|
377 | 376 | {
|
378 |
| - .type = BUTTON_TYPE_GPIO, |
379 |
| - .gpio_button_config.active_level = false, |
380 |
| - .gpio_button_config.gpio_num = BSP_BUTTON_RIGHT, |
| 377 | + .gpio_num = BSP_BUTTON_RIGHT, |
| 378 | + .active_level = 0, |
381 | 379 | },
|
382 | 380 | };
|
383 | 381 |
|
384 | 382 | static lv_indev_t *bsp_display_indev_init(lv_display_t *disp)
|
385 | 383 | {
|
| 384 | + const button_config_t btn_cfg = {0}; |
| 385 | + button_handle_t prev_btn = NULL; |
| 386 | + button_handle_t next_btn = NULL; |
| 387 | + button_handle_t enter_btn = NULL; |
| 388 | + BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[BSP_BUTTON_PREV], &prev_btn)); |
| 389 | + BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[BSP_BUTTON_NEXT], &next_btn)); |
| 390 | + BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[BSP_BUTTON_ENTER], &enter_btn)); |
| 391 | + |
386 | 392 | const lvgl_port_nav_btns_cfg_t btns = {
|
387 | 393 | .disp = disp,
|
388 |
| - .button_prev = &bsp_button_config[BSP_BUTTON_PREV], |
389 |
| - .button_next = &bsp_button_config[BSP_BUTTON_NEXT], |
390 |
| - .button_enter = &bsp_button_config[BSP_BUTTON_ENTER] |
| 394 | + .button_prev = prev_btn, |
| 395 | + .button_next = next_btn, |
| 396 | + .button_enter = enter_btn |
391 | 397 | };
|
392 | 398 |
|
393 | 399 | 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
|
455 | 461 | if (btn_cnt) {
|
456 | 462 | *btn_cnt = 0;
|
457 | 463 | }
|
| 464 | + const button_config_t btn_cfg = {0}; |
458 | 465 | for (int i = 0; i < BSP_BUTTON_NUM; i++) {
|
459 |
| - btn_array[i] = iot_button_create(&bsp_button_config[i]); |
| 466 | + ret |= iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[i], &btn_array[i]); |
460 | 467 | if (btn_array[i] == NULL) {
|
461 | 468 | ret = ESP_FAIL;
|
462 | 469 | break;
|
|
0 commit comments