Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bsp: Add display and touch support to gerenic BSP. #255

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
365 changes: 346 additions & 19 deletions bsp/esp_bsp_generic/Kconfig

Large diffs are not rendered by default.

79 changes: 78 additions & 1 deletion bsp/esp_bsp_generic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ For button handling is used component [iot_button](https://components.espressif.
- `BSP_LEDS_NUM` (max 5)

2. Set type for all LEDs in `menuconfig`
- `BSP_LED_TYPE` (GPIO / Adressable LED)
- `BSP_LED_TYPE` (GPIO / Adressable RGB LED / Classic RGB)

3. For GPIO LEDs set pin and level for each LED in `menuconfig`
- `BSP_LED_x_GPIO`
Expand All @@ -123,6 +123,12 @@ For button handling is used component [iot_button](https://components.espressif.
- `BSP_LED_RGB_GPIO`
- `BSP_LED_RGB_BACKEND`

3. For classic RBG LEDs set pins for all colors and level in `menuconfig`
- `BSP_LED_RGB_RED_GPIO`
- `BSP_LED_RGB_GREEN_GPIO`
- `BSP_LED_RGB_BLUE_GPIO`
- `BSP_LED_RGB_CLASSIC_LEVEL`

Example code:
```
/* Initialize all LEDs */
Expand All @@ -137,5 +143,76 @@ Example code:
```
For LEDs handling is used component [led_indicator](https://components.espressif.com/components/espressif/led_indicator) with [led_strip](https://components.espressif.com/components/espressif/led_strip) component. For more information, please look into guides for these components.

## LCD Display

1. Enable display in `menuconfig`
- `BSP_DISPLAY_ENABLED`

2. Select communication interface in `menuconfig`
- `BSP_DISPLAY_INTERFACE_` (only SPI is supported)

3. Set communication pins in `menuconfig`
- `BSP_DISPLAY_SCLK_GPIO`
- `BSP_DISPLAY_MOSI_GPIO`
- `BSP_DISPLAY_MISO_GPIO`
- `BSP_DISPLAY_CS_GPIO`
- `BSP_DISPLAY_DC_GPIO`
- `BSP_DISPLAY_RST_GPIO`
- `BSP_DISPLAY_BACKLIGHT_GPIO`

4. Select display driver in `menuconfig` (one of these)
- `BSP_DISPLAY_DRIVER_ST7789`
- `BSP_DISPLAY_DRIVER_ILI9341`
- `BSP_DISPLAY_DRIVER_GC9A01`

5. Set right rotation of the screen in `menuconfig`
- `BSP_DISPLAY_ROTATION_SWAP_XY`
- `BSP_DISPLAY_ROTATION_MIRROR_X`
- `BSP_DISPLAY_ROTATION_MIRROR_Y`

6. Set other display params in `menuconfig`
- `BSP_DISPLAY_CMD_BITS`
- `BSP_DISPLAY_PARAM_BITS`
- `BSP_DISPLAY_PIXEL_CLOCK`
- `BSP_DISPLAY_WIDTH`
- `BSP_DISPLAY_HEIGHT`
- `BSP_DISPLAY_BRIGHTNESS_LEDC_CH`
- `BSP_LCD_DRAW_BUF_HEIGHT`
- `BSP_LCD_DRAW_BUF_DOUBLE`

## LCD Touch

1. Enable display touch in `menuconfig`
- `BSP_TOUCH_ENABLED`

2. Select communication interface in `menuconfig`
- `BSP_TOUCH_INTERFACE_` (only I2C is supported)

3. Set communication pins in `menuconfig`
- `BSP_TOUCH_RST_GPIO`
- `BSP_TOUCH_INT_GPIO`

4. Select display driver in `menuconfig` (one of these)
- `BSP_TOUCH_DRIVER_TT21100`
- `BSP_TOUCH_DRIVER_GT1151`
- `BSP_TOUCH_DRIVER_GT911`
- `BSP_TOUCH_DRIVER_CST816S`
- `BSP_TOUCH_DRIVER_FT5X06`

5. Set right rotation of the screen in `menuconfig`
- `BSP_TOUCH_ROTATION_SWAP_XY`
- `BSP_TOUCH_ROTATION_MIRROR_X`
- `BSP_TOUCH_ROTATION_MIRROR_Y`

Example code:
```
/* Initialize display, touch and LVGL */
bsp_display_start();

/* Set display brightness to 100% */
bsp_display_backlight_on();

bsp_display_lock(0);
/* === Your LVGL code here === */
bsp_display_unlock();
```
16 changes: 14 additions & 2 deletions bsp/esp_bsp_generic/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@

version: "1.0.0~1"
version: "1.1.0"
description: Generig Board Support Package
url: https://github.com/espressif/esp-bsp/tree/master/bsp/esp_bsp_generic

dependencies:
idf: ">=4.4.2"
esp_lcd_touch_tt21100: "^1"
esp_lcd_touch_gt1151: "^1"
esp_lcd_touch_gt911: "^1"
esp_lcd_touch_cst816s: "^1"
esp_lcd_touch_ft5x06: "^1"

esp_lcd_ili9341: "^1"
esp_lcd_gc9a01: "^1"

button:
version: ">=2.5,<4.0"
public: true

led_indicator:
version: ">=0.7,<=0.8"
version: "^0.9"
public: true

esp_lvgl_port:
version: "^1"
public: true

examples:
Expand Down
77 changes: 77 additions & 0 deletions bsp/esp_bsp_generic/include/bsp/display.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @file
* @brief BSP LCD
*
* This file offers API for basic LCD control.
* It is useful for users who want to use the LCD without the default Graphical Library LVGL.
*
* For standard LCD initialization with LVGL graphical library, you can call all-in-one function bsp_display_start().
*/

#pragma once
#include "sdkconfig.h"
#include "esp_lcd_types.h"

/* LCD color formats */
#define ESP_LCD_COLOR_FORMAT_RGB565 (1)
#define ESP_LCD_COLOR_FORMAT_RGB888 (2)

/* LCD display color format */
#define BSP_LCD_COLOR_FORMAT (ESP_LCD_COLOR_FORMAT_RGB565)
/* LCD display color bytes endianess */
#define BSP_LCD_BIGENDIAN (1)
/* LCD display color bits */
#define BSP_LCD_BITS_PER_PIXEL (16)
/* LCD display color space */
#if defined(CONFIG_BSP_DISPLAY_COLOR_SPACE_RGB)
#define BSP_LCD_COLOR_SPACE (ESP_LCD_COLOR_SPACE_RGB)
#elif defined(CONFIG_BSP_DISPLAY_COLOR_SPACE_BGR)
#define BSP_LCD_COLOR_SPACE (ESP_LCD_COLOR_SPACE_BGR)
espzav marked this conversation as resolved.
Show resolved Hide resolved
#endif

#ifdef __cplusplus
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
*
* For maximum flexibility, this function performs only reset and initialization of the display.
* You must turn on the display explicitly by calling esp_lcd_panel_disp_on_off().
* The display's backlight is not turned on either. You can use bsp_display_backlight_on/off(),
* bsp_display_brightness_set() (on supported boards) or implement your own backlight control.
*
* If you want to free resources allocated by this function, you can use esp_lcd API, ie.:
*
* \code{.c}
* esp_lcd_panel_del(panel);
* esp_lcd_panel_io_del(io);
* 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_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
}
#endif
Loading
Loading