Skip to content

Commit 584c1c0

Browse files
committed
Update LVGL example to remove Kconfig.projbuild
Fixes #18
1 parent d2a98f1 commit 584c1c0

File tree

9 files changed

+65
-78
lines changed

9 files changed

+65
-78
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ examples/**/build
22
examples/**/sdkconfig
33
examples/**/dependencies.lock
44
examples/**/managed_components
5+
.vscode

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Change log for esp_lcd_ili9488
22

3+
4+
## v1.0.11 - Updates to LVGL examples
5+
6+
* Removed Kconfig.projbuild from the LVGL example as it introduced complexity
7+
that wasn't needed.
8+
* Restrict LVGL example to LVGL 8.x as it will require rework for LVGL 9.x.
9+
* Updated LVGL example for ESP-IDF v5.4
10+
311
## v1.0.10 - Bug fixes and 16-bit mode for i8080 example
412

513
* Ensure the color_buffer is freed upon delete (@nebkat)

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
#
2+
# SPDX-FileCopyrightText: 2022 atanisoft (github.com/atanisoft)
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20)
18

29
idf_component_register(SRCS "esp_lcd_ili9488.c"
310
INCLUDE_DIRS "include"

examples/lvgl/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
#
2+
# SPDX-FileCopyrightText: 2022 atanisoft (github.com/atanisoft)
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
17
# The following lines of boilerplate have to be in your project's CMakeLists
28
# in this exact order for cmake to work correctly
3-
cmake_minimum_required(VERSION 3.5)
9+
cmake_minimum_required(VERSION 3.20)
410

511
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
612
project(EspIli9488Lvgl)

examples/lvgl/main/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#
2+
# SPDX-FileCopyrightText: 2022 atanisoft (github.com/atanisoft)
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
16

27
idf_component_register(SRCS main.c
38
REQUIRES driver freertos esp_lcd esp_timer)

examples/lvgl/main/Kconfig.projbuild

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dependencies:
22
idf: ">=4.4.2"
3-
lvgl/lvgl: ">=8.0.0"
3+
lvgl/lvgl: "<9.0.0"
44
esp_lcd_ili9488:
55
version: "~1.0.0"
66
override_path: "../../.."

examples/lvgl/main/main.c

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,27 @@ static const unsigned int DISPLAY_REFRESH_HZ = 40000000;
3535
static const int DISPLAY_SPI_QUEUE_LEN = 10;
3636
static const int SPI_MAX_TRANSFER_SIZE = 32768;
3737

38+
#if CONFIG_IDF_TARGET_ESP32S3
39+
static const gpio_num_t SPI_CLOCK = GPIO_NUM_11;
40+
static const gpio_num_t SPI_MOSI = GPIO_NUM_10;
41+
static const gpio_num_t SPI_MISO = GPIO_NUM_13;
42+
static const gpio_num_t TFT_CS = GPIO_NUM_3;
43+
static const gpio_num_t TFT_RESET = GPIO_NUM_46;
44+
static const gpio_num_t TFT_DC = GPIO_NUM_9;
45+
static const gpio_num_t TFT_BACKLIGHT = GPIO_NUM_12;
46+
#elif CONFIG_IDF_TARGET_ESP32
47+
static const gpio_num_t SPI_CLOCK = GPIO_NUM_14;
48+
static const gpio_num_t SPI_MOSI = GPIO_NUM_15;
49+
static const gpio_num_t SPI_MISO = GPIO_NUM_2;
50+
static const gpio_num_t TFT_CS = GPIO_NUM_16;
51+
static const gpio_num_t TFT_RESET = GPIO_NUM_NC;
52+
static const gpio_num_t TFT_DC = GPIO_NUM_17;
53+
static const gpio_num_t TFT_BACKLIGHT = GPIO_NUM_18;
54+
#else
55+
#error Unsure which GPIO to use for SPI/TFT, please update code accordingly.
56+
#endif
57+
static const lcd_rgb_element_order_t TFT_COLOR_MODE = COLOR_RGB_ELEMENT_ORDER_BGR;
58+
3859
// Default to 25 lines of color data
3960
static const size_t LV_BUFFER_SIZE = DISPLAY_HORIZONTAL_PIXELS * 25;
4061
static const int LVGL_UPDATE_PERIOD_MS = 5;
@@ -88,7 +109,7 @@ static void display_brightness_init(void)
88109
{
89110
const ledc_channel_config_t LCD_backlight_channel =
90111
{
91-
.gpio_num = (gpio_num_t)CONFIG_TFT_BACKLIGHT_PIN,
112+
.gpio_num = TFT_BACKLIGHT,
92113
.speed_mode = BACKLIGHT_LEDC_MODE,
93114
.channel = BACKLIGHT_LEDC_CHANNEL,
94115
.intr_type = LEDC_INTR_DISABLE,
@@ -108,7 +129,7 @@ static void display_brightness_init(void)
108129
.freq_hz = BACKLIGHT_LEDC_FRQUENCY,
109130
.clk_cfg = LEDC_AUTO_CLK
110131
};
111-
ESP_LOGI(TAG, "Initializing LEDC for backlight pin: %d", CONFIG_TFT_BACKLIGHT_PIN);
132+
ESP_LOGI(TAG, "Initializing LEDC for backlight pin: %d", TFT_BACKLIGHT);
112133

113134
ESP_ERROR_CHECK(ledc_timer_config(&LCD_backlight_timer));
114135
ESP_ERROR_CHECK(ledc_channel_config(&LCD_backlight_channel));
@@ -135,12 +156,12 @@ void display_brightness_set(int brightness_percentage)
135156
void initialize_spi()
136157
{
137158
ESP_LOGI(TAG, "Initializing SPI bus (MOSI:%d, MISO:%d, CLK:%d)",
138-
CONFIG_SPI_MOSI, CONFIG_SPI_MISO, CONFIG_SPI_CLOCK);
159+
SPI_MOSI, SPI_MISO, SPI_CLOCK);
139160
spi_bus_config_t bus =
140161
{
141-
.mosi_io_num = CONFIG_SPI_MOSI,
142-
.miso_io_num = CONFIG_SPI_MISO,
143-
.sclk_io_num = CONFIG_SPI_CLOCK,
162+
.mosi_io_num = SPI_MOSI,
163+
.miso_io_num = SPI_MISO,
164+
.sclk_io_num = SPI_CLOCK,
144165
.quadwp_io_num = GPIO_NUM_NC,
145166
.quadhd_io_num = GPIO_NUM_NC,
146167
.data4_io_num = GPIO_NUM_NC,
@@ -160,15 +181,19 @@ void initialize_display()
160181
{
161182
const esp_lcd_panel_io_spi_config_t io_config =
162183
{
163-
.cs_gpio_num = CONFIG_TFT_CS_PIN,
164-
.dc_gpio_num = CONFIG_TFT_DC_PIN,
184+
.cs_gpio_num = TFT_CS,
185+
.dc_gpio_num = TFT_DC,
165186
.spi_mode = 0,
166187
.pclk_hz = DISPLAY_REFRESH_HZ,
167188
.trans_queue_depth = DISPLAY_SPI_QUEUE_LEN,
168189
.on_color_trans_done = notify_lvgl_flush_ready,
169190
.user_ctx = &lv_disp_drv,
170191
.lcd_cmd_bits = DISPLAY_COMMAND_BITS,
171192
.lcd_param_bits = DISPLAY_PARAMETER_BITS,
193+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5,4,0)
194+
.cs_ena_pretrans = 0,
195+
.cs_ena_posttrans = 0,
196+
#endif
172197
.flags =
173198
{
174199
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
@@ -188,8 +213,8 @@ void initialize_display()
188213

189214
const esp_lcd_panel_dev_config_t lcd_config =
190215
{
191-
.reset_gpio_num = CONFIG_TFT_RESET_PIN,
192-
.color_space = CONFIG_DISPLAY_COLOR_MODE,
216+
.reset_gpio_num = TFT_RESET,
217+
.color_space = TFT_COLOR_MODE,
193218
.bits_per_pixel = 18,
194219
.flags =
195220
{

examples/lvgl_for_i8080/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.5)
1+
cmake_minimum_required(VERSION 3.20)
22

33
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
44
project(lcd_lvgl)

0 commit comments

Comments
 (0)