Skip to content

Commit

Permalink
bsp: Add API for change the display transfer size.
Browse files Browse the repository at this point in the history
  • Loading branch information
espzav committed Mar 28, 2023
1 parent c8c2ecd commit cab1741
Show file tree
Hide file tree
Showing 20 changed files with 151 additions and 52 deletions.
14 changes: 9 additions & 5 deletions esp-box/esp-box.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,10 @@ esp_err_t bsp_display_backlight_on(void)
return bsp_display_brightness_set(100);
}

esp_err_t bsp_display_new(esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io)
esp_err_t bsp_display_new(const bsp_display_config_t *config, esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io)
{
esp_err_t ret = ESP_OK;
assert(config != NULL && config->max_transfer_sz > 0);

ESP_RETURN_ON_ERROR(bsp_display_brightness_init(), TAG, "Brightness init failed");

Expand All @@ -201,7 +202,7 @@ esp_err_t bsp_display_new(esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_ha
.miso_io_num = GPIO_NUM_NC,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.max_transfer_sz = BSP_LCD_DRAW_BUFF_SIZE * sizeof(uint16_t),
.max_transfer_sz = config->max_transfer_sz,
};
ESP_RETURN_ON_ERROR(spi_bus_initialize(BSP_LCD_SPI_NUM, &buscfg, SPI_DMA_CH_AUTO), TAG, "SPI init failed");

Expand Down Expand Up @@ -245,7 +246,10 @@ static lv_disp_t *bsp_display_lcd_init(void)
{
esp_lcd_panel_io_handle_t io_handle = NULL;
esp_lcd_panel_handle_t panel_handle = NULL;
BSP_ERROR_CHECK_RETURN_NULL(bsp_display_new(&panel_handle, &io_handle));
const bsp_display_config_t bsp_disp_cfg = {
.max_transfer_sz = BSP_LCD_DRAW_BUFF_SIZE * sizeof(uint16_t),
};
BSP_ERROR_CHECK_RETURN_NULL(bsp_display_new(&bsp_disp_cfg, &panel_handle, &io_handle));

esp_lcd_panel_disp_on_off(panel_handle, true);

Expand Down Expand Up @@ -273,7 +277,7 @@ static lv_disp_t *bsp_display_lcd_init(void)
return lvgl_port_add_disp(&disp_cfg);
}

esp_err_t bsp_touch_new(esp_lcd_touch_handle_t *ret_touch)
esp_err_t bsp_touch_new(const bsp_touch_config_t *config, esp_lcd_touch_handle_t *ret_touch)
{
/* Initialize touch */
const esp_lcd_touch_config_t tp_cfg = {
Expand All @@ -299,7 +303,7 @@ esp_err_t bsp_touch_new(esp_lcd_touch_handle_t *ret_touch)

static lv_indev_t *bsp_display_indev_init(lv_disp_t *disp)
{
BSP_ERROR_CHECK_RETURN_NULL(bsp_touch_new(&tp));
BSP_ERROR_CHECK_RETURN_NULL(bsp_touch_new(NULL, &tp));
assert(tp);

/* Add touch input (for selected screen) */
Expand Down
2 changes: 1 addition & 1 deletion esp-box/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "2.3.2"
version: "2.3.3"
description: Board Support Package for ESP-BOX
url: https://github.com/espressif/esp-bsp/tree/master/esp-box

Expand Down
15 changes: 12 additions & 3 deletions esp-box/include/bsp/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
extern "C" {
#endif

/**
* @brief BSP display configuration structure
*
*/
typedef struct {
int max_transfer_sz; /*!< Maximum transfer size, in bytes. */
} bsp_display_config_t;

/**
* @brief Create new display panel
*
Expand All @@ -50,13 +58,14 @@ extern "C" {
* spi_bus_free(spi_num_from_configuration);
* \endcode
*
* @param[in] config display configuration
* @param[out] ret_panel esp_lcd panel handle
* @param[out] ret_io esp_lcd IO handle
* @return
* - ESP_OK On success
* - Else esp_lcd failure
* - ESP_OK On success
* - Else esp_lcd failure
*/
esp_err_t bsp_display_new(esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io);
esp_err_t bsp_display_new(const bsp_display_config_t *config, esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io);

#ifdef __cplusplus
}
Expand Down
15 changes: 12 additions & 3 deletions esp-box/include/bsp/touch.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
extern "C" {
#endif

/**
* @brief BSP touch configuration structure
*
*/
typedef struct {
void *dummy; /*!< Prepared for future use. */
} bsp_touch_config_t;

/**
* @brief Create new touchscreen
*
Expand All @@ -30,12 +38,13 @@ extern "C" {
* esp_lcd_touch_del(tp);
* \endcode
*
* @param[in] config touch configuration
* @param[out] ret_touch esp_lcd_touch touchscreen handle
* @return
* - ESP_OK On success
* - Else esp_lcd_touch failure
* - ESP_OK On success
* - Else esp_lcd_touch failure
*/
esp_err_t bsp_touch_new(esp_lcd_touch_handle_t *ret_touch);
esp_err_t bsp_touch_new(const bsp_touch_config_t *config, esp_lcd_touch_handle_t *ret_touch);

#ifdef __cplusplus
}
Expand Down
11 changes: 8 additions & 3 deletions esp32_s2_kaluga_kit/esp32_s2_kaluga_kit.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,19 @@ esp_err_t bsp_touchpad_calibrate(bsp_touchpad_button_t tch_pad, float tch_thresh
#define LCD_CMD_BITS (8)
#define LCD_PARAM_BITS (8)

esp_err_t bsp_display_new(esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io)
esp_err_t bsp_display_new(const bsp_display_config_t *config, esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io)
{
esp_err_t ret = ESP_OK;
assert(config != NULL && config->max_transfer_sz > 0);

ESP_LOGD(TAG, "Initialize SPI bus");
const spi_bus_config_t buscfg = {
.sclk_io_num = BSP_LCD_SPI_CLK,
.mosi_io_num = BSP_LCD_SPI_MOSI,
.miso_io_num = GPIO_NUM_NC,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.max_transfer_sz = BSP_LCD_DRAW_BUFF_SIZE * sizeof(lv_color_t),
.max_transfer_sz = config->max_transfer_sz,
};
ESP_RETURN_ON_ERROR(spi_bus_initialize(BSP_LCD_SPI_NUM, &buscfg, SPI_DMA_CH_AUTO), TAG, "SPI init failed");

Expand Down Expand Up @@ -263,7 +265,10 @@ static lv_disp_t *bsp_display_lcd_init(void)
{
esp_lcd_panel_io_handle_t io_handle = NULL;
esp_lcd_panel_handle_t panel_handle = NULL;
BSP_ERROR_CHECK_RETURN_NULL(bsp_display_new(&panel_handle, &io_handle));
const bsp_display_config_t bsp_disp_cfg = {
.max_transfer_sz = BSP_LCD_DRAW_BUFF_SIZE * sizeof(uint16_t),
};
BSP_ERROR_CHECK_RETURN_NULL(bsp_display_new(&bsp_disp_cfg, &panel_handle, &io_handle));

esp_lcd_panel_disp_on_off(panel_handle, true);

Expand Down
2 changes: 1 addition & 1 deletion esp32_s2_kaluga_kit/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "2.2.1"
version: "2.2.2"
description: Board Support Package for ESP32-S2-Kaluga kit
url: https://github.com/espressif/esp-bsp/tree/master/esp32_s2_kaluga_kit

Expand Down
15 changes: 12 additions & 3 deletions esp32_s2_kaluga_kit/include/bsp/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
extern "C" {
#endif

/**
* @brief BSP display configuration structure
*
*/
typedef struct {
int max_transfer_sz; /*!< Maximum transfer size, in bytes. */
} bsp_display_config_t;

/**
* @brief Create new display panel
*
Expand All @@ -50,13 +58,14 @@ extern "C" {
* spi_bus_free(spi_num_from_configuration);
* \endcode
*
* @param[in] config display configuration
* @param[out] ret_panel esp_lcd panel handle
* @param[out] ret_io esp_lcd IO handle
* @return
* - ESP_OK On success
* - Else esp_lcd failure
* - ESP_OK On success
* - Else esp_lcd failure
*/
esp_err_t bsp_display_new(esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io);
esp_err_t bsp_display_new(const bsp_display_config_t *config, esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io);

#ifdef __cplusplus
}
Expand Down
10 changes: 7 additions & 3 deletions esp32_s3_eye/esp32_s3_eye.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,10 @@ esp_err_t bsp_display_backlight_on(void)
return bsp_display_brightness_set(100);
}

esp_err_t bsp_display_new(esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io)
esp_err_t bsp_display_new(const bsp_display_config_t *config, esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io)
{
esp_err_t ret = ESP_OK;
assert(config != NULL && config->max_transfer_sz > 0);

ESP_RETURN_ON_ERROR(bsp_display_brightness_init(), TAG, "Brightness init failed");

Expand All @@ -192,7 +193,7 @@ esp_err_t bsp_display_new(esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_ha
.miso_io_num = GPIO_NUM_NC,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.max_transfer_sz = BSP_LCD_DRAW_BUFF_SIZE * sizeof(lv_color_t),
.max_transfer_sz = config->max_transfer_sz,
};
ESP_RETURN_ON_ERROR(spi_bus_initialize(BSP_LCD_SPI_NUM, &buscfg, SPI_DMA_CH_AUTO), TAG, "SPI init failed");

Expand Down Expand Up @@ -237,7 +238,10 @@ static lv_disp_t *bsp_display_lcd_init(void)
{
esp_lcd_panel_io_handle_t io_handle = NULL;
esp_lcd_panel_handle_t panel_handle = NULL;
BSP_ERROR_CHECK_RETURN_NULL(bsp_display_new(&panel_handle, &io_handle));
const bsp_display_config_t bsp_disp_cfg = {
.max_transfer_sz = BSP_LCD_DRAW_BUFF_SIZE * sizeof(uint16_t),
};
BSP_ERROR_CHECK_RETURN_NULL(bsp_display_new(&bsp_disp_cfg, &panel_handle, &io_handle));

#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
esp_lcd_panel_disp_off(panel_handle, false);
Expand Down
2 changes: 1 addition & 1 deletion esp32_s3_eye/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "2.1.1"
version: "2.1.2"
description: Board Support Package for ESP32-S3-EYE
url: https://github.com/espressif/esp-bsp/tree/master/esp32_s3_eye

Expand Down
15 changes: 12 additions & 3 deletions esp32_s3_eye/include/bsp/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
extern "C" {
#endif

/**
* @brief BSP display configuration structure
*
*/
typedef struct {
int max_transfer_sz; /*!< Maximum transfer size, in bytes. */
} bsp_display_config_t;

/**
* @brief Create new display panel
*
Expand All @@ -50,13 +58,14 @@ extern "C" {
* spi_bus_free(spi_num_from_configuration);
* \endcode
*
* @param[in] config display configuration
* @param[out] ret_panel esp_lcd panel handle
* @param[out] ret_io esp_lcd IO handle
* @return
* - ESP_OK On success
* - Else esp_lcd failure
* - ESP_OK On success
* - Else esp_lcd failure
*/
esp_err_t bsp_display_new(esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io);
esp_err_t bsp_display_new(const bsp_display_config_t *config, esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io);

#ifdef __cplusplus
}
Expand Down
15 changes: 10 additions & 5 deletions esp32_s3_korvo_2/esp32_s3_korvo_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,19 @@ esp_io_expander_handle_t bsp_io_expander_init(void)
#define LCD_CMD_BITS 8
#define LCD_PARAM_BITS 8

esp_err_t bsp_display_new(esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io)
esp_err_t bsp_display_new(const bsp_display_config_t *config, esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io)
{
esp_err_t ret = ESP_OK;
assert(config != NULL && config->max_transfer_sz > 0);

ESP_LOGD(TAG, "Initialize SPI bus");
const spi_bus_config_t buscfg = {
.sclk_io_num = BSP_LCD_PCLK,
.mosi_io_num = BSP_LCD_DATA0,
.miso_io_num = GPIO_NUM_NC,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.max_transfer_sz = BSP_LCD_DRAW_BUFF_SIZE * sizeof(uint16_t),
.max_transfer_sz = config->max_transfer_sz,
};
ESP_RETURN_ON_ERROR(spi_bus_initialize(BSP_LCD_SPI_NUM, &buscfg, SPI_DMA_CH_AUTO), TAG, "SPI init failed");

Expand Down Expand Up @@ -271,7 +273,10 @@ static lv_disp_t *bsp_display_lcd_init(void)
{
esp_lcd_panel_io_handle_t io_handle = NULL;
esp_lcd_panel_handle_t panel_handle = NULL;
BSP_ERROR_CHECK_RETURN_NULL(bsp_display_new(&panel_handle, &io_handle));
const bsp_display_config_t bsp_disp_cfg = {
.max_transfer_sz = BSP_LCD_DRAW_BUFF_SIZE * sizeof(uint16_t),
};
BSP_ERROR_CHECK_RETURN_NULL(bsp_display_new(&bsp_disp_cfg, &panel_handle, &io_handle));

esp_lcd_panel_disp_on_off(panel_handle, true);

Expand Down Expand Up @@ -299,7 +304,7 @@ static lv_disp_t *bsp_display_lcd_init(void)
return lvgl_port_add_disp(&disp_cfg);
}

esp_err_t bsp_touch_new(esp_lcd_touch_handle_t *ret_touch)
esp_err_t bsp_touch_new(const bsp_touch_config_t *config, esp_lcd_touch_handle_t *ret_touch)
{
/* Initialize touch */
const esp_lcd_touch_config_t tp_cfg = {
Expand All @@ -325,7 +330,7 @@ esp_err_t bsp_touch_new(esp_lcd_touch_handle_t *ret_touch)

static lv_indev_t *bsp_display_indev_init(lv_disp_t *disp)
{
BSP_ERROR_CHECK_RETURN_NULL(bsp_touch_new(&tp));
BSP_ERROR_CHECK_RETURN_NULL(bsp_touch_new(NULL, &tp));
assert(tp);

/* Add touch input (for selected screen) */
Expand Down
2 changes: 1 addition & 1 deletion esp32_s3_korvo_2/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "1.1.2"
version: "1.1.3"
description: Board Support Package for ESP32-S3-Korvo-2
url: https://github.com/espressif/esp-bsp/tree/master/esp32_s3_korvo_2

Expand Down
15 changes: 12 additions & 3 deletions esp32_s3_korvo_2/include/bsp/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
extern "C" {
#endif

/**
* @brief BSP display configuration structure
*
*/
typedef struct {
int max_transfer_sz; /*!< Maximum transfer size, in bytes. */
} bsp_display_config_t;

/**
* @brief Create new display panel
*
Expand All @@ -50,13 +58,14 @@ extern "C" {
* spi_bus_free(spi_num_from_configuration);
* \endcode
*
* @param[in] config display configuration
* @param[out] ret_panel esp_lcd panel handle
* @param[out] ret_io esp_lcd IO handle
* @return
* - ESP_OK On success
* - Else esp_lcd failure
* - ESP_OK On success
* - Else esp_lcd failure
*/
esp_err_t bsp_display_new(esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io);
esp_err_t bsp_display_new(const bsp_display_config_t *config, esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io);

#ifdef __cplusplus
}
Expand Down
15 changes: 12 additions & 3 deletions esp32_s3_korvo_2/include/bsp/touch.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
extern "C" {
#endif

/**
* @brief BSP touch configuration structure
*
*/
typedef struct {
void *dummy; /*!< Prepared for future use. */
} bsp_touch_config_t;

/**
* @brief Create new touchscreen
*
Expand All @@ -30,12 +38,13 @@ extern "C" {
* esp_lcd_touch_del(tp);
* \endcode
*
* @param[in] config touch configuration
* @param[out] ret_touch esp_lcd_touch touchscreen handle
* @return
* - ESP_OK On success
* - Else esp_lcd_touch failure
* - ESP_OK On success
* - Else esp_lcd_touch failure
*/
esp_err_t bsp_touch_new(esp_lcd_touch_handle_t *ret_touch);
esp_err_t bsp_touch_new(const bsp_touch_config_t *config, esp_lcd_touch_handle_t *ret_touch);

#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit cab1741

Please sign in to comment.