Skip to content

Commit

Permalink
Merge pull request #293 from espressif/bsp/default_lvgl_version
Browse files Browse the repository at this point in the history
Bsp default lvgl version + runtime buffer size set
  • Loading branch information
espzav authored Feb 14, 2024
2 parents cfe3840 + 897f598 commit 7b2b2ce
Show file tree
Hide file tree
Showing 135 changed files with 2,833 additions and 4,569 deletions.
10 changes: 7 additions & 3 deletions .github/ci/bsp_noglib.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@ def remove_esp_lvgl_port(bsp_name):
manager = ManifestManager(bsp_path, 'bsp')
try:
del manager.manifest_tree["dependencies"]["espressif/esp_lvgl_port"]
manager.manifest_tree["description"] = manager.manifest_tree["description"] + ' with no graphical library'
manager.dump()
return 0
except KeyError:
print("{}: could not remove esp_lvgl_port".format(bsp_name))
return 1
try:
del manager.manifest_tree["dependencies"]["lvgl/lvgl"]
except KeyError:
print("{}: no lvgl dependency found".format(bsp_name))
manager.manifest_tree["description"] = manager.manifest_tree["description"] + ' with no graphical library'
manager.dump()
return 0


def add_notice_to_readme(bsp_name):
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
build:
strategy:
matrix:
idf_ver: ["release-v4.4", "release-v5.0", "release-v5.1", "release-v5.2", "latest"]
idf_ver: ["release-v4.3", "release-v4.4", "latest"]
idf_target: ["esp32", "esp32s2", "esp32c3", "esp32s3"]
exclude:
- idf_ver: "release-v4.3"
Expand All @@ -31,5 +31,4 @@ jobs:
export PEDANTIC_FLAGS="-DIDF_CI_BUILD -Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function"
export EXTRA_CFLAGS="${PEDANTIC_FLAGS} -Wstrict-prototypes"
export EXTRA_CXXFLAGS="${PEDANTIC_FLAGS}"
pip install idf-component-manager --upgrade
idf.py build
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
version: "1.0.1"
version: "1.0.2"
description: Board Support Package for WaveShare 7inch
url: https://github.com/espressif/esp-bsp/SquareLine/boards/custom_waveshare_7inch/components/ws_7inch

dependencies:
idf: ">=5.0"
esp_lcd_ra8875: "^1"
esp_lcd_touch_gt911: "^1"
lvgl/lvgl: "^8"

esp_lvgl_port:
version: ^1
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
* SPDX-FileCopyrightText: 2024 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 "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 */
#define BSP_LCD_COLOR_SPACE (ESP_LCD_COLOR_SPACE_BGR)
/* LCD definition */
#define BSP_LCD_H_RES (800)
#define BSP_LCD_V_RES (480)

#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);

/**
* @brief Set display's brightness
*
* Brightness is controlled with PWM signal to a pin controlling backlight.
* Display must be already initialized by calling bsp_display_new()
*
* @param[in] brightness_percent Brightness in [%]
* @return
* - ESP_OK On success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t bsp_display_brightness_set(int brightness_percent);

/**
* @brief Turn on display backlight
*
* Display must be already initialized by calling bsp_display_new()
*
* @return
* - ESP_OK On success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t bsp_display_backlight_on(void);

/**
* @brief Turn off display backlight
*
* Display must be already initialized by calling bsp_display_new()
*
* @return
* - ESP_OK On success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t bsp_display_backlight_off(void);

#ifdef __cplusplus
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @file
* @brief BSP Touchscreen
*
* This file offers API for basic touchscreen initialization.
* It is useful for users who want to use the touchscreen 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 "esp_lcd_touch.h"

#ifdef __cplusplus
extern "C" {
#endif

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

/**
* @brief Create new touchscreen
*
* If you want to free resources allocated by this function, you can use esp_lcd_touch API, ie.:
*
* \code{.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_err_t bsp_touch_new(const bsp_touch_config_t *config, esp_lcd_touch_handle_t *ret_touch);

#ifdef __cplusplus
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,22 @@
#include "sdkconfig.h"
#include "driver/gpio.h"
#include "driver/i2c.h"
#include "bsp/display.h"
#include "lvgl.h"
#include "esp_lvgl_port.h"

/**************************************************************************************************
* BSP Capabilities
**************************************************************************************************/

#define BSP_CAPS_DISPLAY 1
#define BSP_CAPS_TOUCH 1
#define BSP_CAPS_BUTTONS 0
#define BSP_CAPS_AUDIO 0
#define BSP_CAPS_AUDIO_SPEAKER 0
#define BSP_CAPS_AUDIO_MIC 0
#define BSP_CAPS_SDCARD 0
#define BSP_CAPS_IMU 0

/**************************************************************************************************
* ESP-BOX pinout
Expand Down Expand Up @@ -49,6 +64,20 @@
extern "C" {
#endif

/**
* @brief BSP display configuration structure
*
*/
typedef struct {
lvgl_port_cfg_t lvgl_port_cfg; /*!< LVGL port configuration */
uint32_t buffer_size; /*!< Size of the buffer for the screen in pixels */
bool double_buffer; /*!< True, if should be allocated two buffers */
struct {
unsigned int buff_dma: 1; /*!< Allocated LVGL buffer will be DMA capable */
unsigned int buff_spiram: 1; /*!< Allocated LVGL buffer will be in PSRAM */
} flags;
} bsp_display_cfg_t;

/**************************************************************************************************
*
* I2C interface
Expand Down Expand Up @@ -84,8 +113,6 @@ esp_err_t bsp_i2c_deinit(void);
*
* Display's backlight must be enabled explicitly by calling bsp_display_backlight_on()
**************************************************************************************************/
#define BSP_LCD_H_RES (800)
#define BSP_LCD_V_RES (480)
#define BSP_LCD_PIXEL_CLOCK_HZ (20 * 1000 * 1000)

/**
Expand All @@ -99,53 +126,40 @@ esp_err_t bsp_i2c_deinit(void);
lv_disp_t *bsp_display_start(void);

/**
* @brief Take LVGL mutex
* @brief Initialize display
*
* @param timeout_ms Timeout in [ms]. 0 will block indefinitely.
* @return true Mutex was taken
* @return false Mutex was NOT taken
*/
bool bsp_display_lock(uint32_t timeout_ms);

/**
* @brief Give LVGL mutex
* This function initializes SPI, display controller and starts LVGL handling task.
* LCD backlight must be enabled separately by calling bsp_display_brightness_set()
*
* @param cfg display configuration
*
* @return Pointer to LVGL display or NULL when error occurred
*/
void bsp_display_unlock(void);
lv_disp_t *bsp_display_start_with_config(const bsp_display_cfg_t *cfg);

/**
* @brief Set display's brightness
* @brief Get pointer to input device (touch, buttons, ...)
*
* Brightness is controlled with PWM signal to a pin controling backlight.
* @note The LVGL input device is initialized in bsp_display_start() function.
*
* @param[in] brightness_percent Brightness in [%]
* @return
* - ESP_OK On success
* - ESP_ERR_INVALID_ARG Parameter error
* @return Pointer to LVGL input device or NULL when not initialized
*/
esp_err_t bsp_display_brightness_set(int brightness_percent);
lv_indev_t *bsp_display_get_input_dev(void);

/**
* @brief Turn on display backlight
*
* Display must be already initialized by calling bsp_display_start()
* @brief Take LVGL mutex
*
* @return
* - ESP_OK On success
* - ESP_ERR_INVALID_ARG Parameter error
* @param timeout_ms Timeout in [ms]. 0 will block indefinitely.
* @return true Mutex was taken
* @return false Mutex was NOT taken
*/
esp_err_t bsp_display_backlight_on(void);
bool bsp_display_lock(uint32_t timeout_ms);

/**
* @brief Turn off display backlight
*
* Display must be already initialized by calling bsp_display_start()
* @brief Give LVGL mutex
*
* @return
* - ESP_OK On success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t bsp_display_backlight_off(void);
void bsp_display_unlock(void);

/**
* @brief Rotate screen
Expand Down
Loading

0 comments on commit 7b2b2ce

Please sign in to comment.