Select one of the symbols to view example projects that use it.
 
Outline
#include <stdio.h>
#include <sys/lock.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "esp_timer.h"
#include "esp_err.h"
#include "esp_log.h"
#include "esp_lcd_panel_io.h"
#include "esp_lcd_panel_vendor.h"
#include "esp_lcd_panel_ops.h"
#include "esp_spiffs.h"
#include "driver/gpio.h"
#include "lvgl.h"
TAG
#define EXAMPLE_LCD_PIXEL_CLOCK_HZ
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL
#define EXAMPLE_PIN_NUM_DATA0
#define EXAMPLE_PIN_NUM_DATA1
#define EXAMPLE_PIN_NUM_DATA2
#define EXAMPLE_PIN_NUM_DATA3
#define EXAMPLE_PIN_NUM_DATA4
#define EXAMPLE_PIN_NUM_DATA5
#define EXAMPLE_PIN_NUM_DATA6
#define EXAMPLE_PIN_NUM_DATA7
#define EXAMPLE_PIN_NUM_DATA8
#define EXAMPLE_PIN_NUM_DATA9
#define EXAMPLE_PIN_NUM_DATA10
#define EXAMPLE_PIN_NUM_DATA11
#define EXAMPLE_PIN_NUM_DATA12
#define EXAMPLE_PIN_NUM_DATA13
#define EXAMPLE_PIN_NUM_DATA14
#define EXAMPLE_PIN_NUM_DATA15
#define EXAMPLE_PIN_NUM_PCLK
#define EXAMPLE_PIN_NUM_CS
#define EXAMPLE_PIN_NUM_DC
#define EXAMPLE_PIN_NUM_RST
#define EXAMPLE_PIN_NUM_BK_LIGHT
#define EXAMPLE_LCD_H_RES
#define EXAMPLE_LCD_V_RES
#define EXAMPLE_LCD_CMD_BITS
#define EXAMPLE_LCD_PARAM_BITS
#define EXAMPLE_LCD_CMD_BITS
#define EXAMPLE_LCD_PARAM_BITS
#define EXAMPLE_LCD_CMD_BITS
#define EXAMPLE_LCD_PARAM_BITS
#define EXAMPLE_LVGL_TICK_PERIOD_MS
#define EXAMPLE_LVGL_TASK_MAX_DELAY_MS
#define EXAMPLE_LVGL_TASK_MIN_DELAY_MS
#define EXAMPLE_LVGL_TASK_STACK_SIZE
#define EXAMPLE_LVGL_TASK_PRIORITY
#define EXAMPLE_LVGL_DRAW_BUF_LINES
#define EXAMPLE_DMA_BURST_SIZE
lvgl_api_lock
example_notify_lvgl_flush_ready(esp_lcd_panel_io_handle_t, esp_lcd_panel_io_event_data_t *, void *)
example_lvgl_flush_cb(lv_display_t *, const lv_area_t *, uint8_t *)
example_increase_lvgl_tick(void *)
example_lvgl_port_task(void *)
example_init_i80_bus(esp_lcd_panel_io_handle_t *)
example_init_lcd_panel(esp_lcd_panel_io_handle_t, esp_lcd_panel_handle_t *)
app_main()
Files
loading...
SourceVuESP-IDF Framework and Examplesi80_controller samplemain/i80_controller_example_main.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: CC0-1.0 *//* ... */ #include <stdio.h> #include <sys/lock.h> #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/semphr.h" #include "esp_timer.h" #include "esp_err.h" #include "esp_log.h" #include "esp_lcd_panel_io.h" #include "esp_lcd_panel_vendor.h" #include "esp_lcd_panel_ops.h" #include "esp_spiffs.h" #include "driver/gpio.h" #include "lvgl.h"14 includes static const char *TAG = "example"; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// Please update the following configuration according to your LCD spec ////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #define EXAMPLE_LCD_PIXEL_CLOCK_HZ CONFIG_EXAMPLE_LCD_PIXEL_CLOCK_HZ #define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL 1 #define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL #define EXAMPLE_PIN_NUM_DATA0 CONFIG_EXAMPLE_PIN_NUM_DATA0 #define EXAMPLE_PIN_NUM_DATA1 CONFIG_EXAMPLE_PIN_NUM_DATA1 #define EXAMPLE_PIN_NUM_DATA2 CONFIG_EXAMPLE_PIN_NUM_DATA2 #define EXAMPLE_PIN_NUM_DATA3 CONFIG_EXAMPLE_PIN_NUM_DATA3 #define EXAMPLE_PIN_NUM_DATA4 CONFIG_EXAMPLE_PIN_NUM_DATA4 #define EXAMPLE_PIN_NUM_DATA5 CONFIG_EXAMPLE_PIN_NUM_DATA5 #define EXAMPLE_PIN_NUM_DATA6 CONFIG_EXAMPLE_PIN_NUM_DATA6 #define EXAMPLE_PIN_NUM_DATA7 CONFIG_EXAMPLE_PIN_NUM_DATA711 defines #if CONFIG_EXAMPLE_LCD_I80_BUS_WIDTH > 8 #define EXAMPLE_PIN_NUM_DATA8 CONFIG_EXAMPLE_PIN_NUM_DATA8 #define EXAMPLE_PIN_NUM_DATA9 CONFIG_EXAMPLE_PIN_NUM_DATA9 #define EXAMPLE_PIN_NUM_DATA10 CONFIG_EXAMPLE_PIN_NUM_DATA10 #define EXAMPLE_PIN_NUM_DATA11 CONFIG_EXAMPLE_PIN_NUM_DATA11 #define EXAMPLE_PIN_NUM_DATA12 CONFIG_EXAMPLE_PIN_NUM_DATA12 #define EXAMPLE_PIN_NUM_DATA13 CONFIG_EXAMPLE_PIN_NUM_DATA13 #define EXAMPLE_PIN_NUM_DATA14 CONFIG_EXAMPLE_PIN_NUM_DATA14 #define EXAMPLE_PIN_NUM_DATA15 CONFIG_EXAMPLE_PIN_NUM_DATA15/* ... */ #endif #define EXAMPLE_PIN_NUM_PCLK CONFIG_EXAMPLE_PIN_NUM_PCLK #define EXAMPLE_PIN_NUM_CS CONFIG_EXAMPLE_PIN_NUM_CS #define EXAMPLE_PIN_NUM_DC CONFIG_EXAMPLE_PIN_NUM_DC #define EXAMPLE_PIN_NUM_RST CONFIG_EXAMPLE_PIN_NUM_RST #define EXAMPLE_PIN_NUM_BK_LIGHT CONFIG_EXAMPLE_PIN_NUM_BK_LIGHT // The pixel number in horizontal and vertical #define EXAMPLE_LCD_H_RES 240 #define EXAMPLE_LCD_V_RES 2807 defines // Bit number used to represent command and parameter #if CONFIG_EXAMPLE_LCD_I80_CONTROLLER_ST7789 #define EXAMPLE_LCD_CMD_BITS 8 #define EXAMPLE_LCD_PARAM_BITS 8/* ... */ #elif CONFIG_EXAMPLE_LCD_I80_CONTROLLER_NT35510 #define EXAMPLE_LCD_CMD_BITS 16 #define EXAMPLE_LCD_PARAM_BITS 16/* ... */ #elif CONFIG_EXAMPLE_LCD_I80_CONTROLLER_ILI9341 #define EXAMPLE_LCD_CMD_BITS 8 #define EXAMPLE_LCD_PARAM_BITS 8/* ... */ #endif #define EXAMPLE_LVGL_TICK_PERIOD_MS 2 #define EXAMPLE_LVGL_TASK_MAX_DELAY_MS 500 #define EXAMPLE_LVGL_TASK_MIN_DELAY_MS 1 #define EXAMPLE_LVGL_TASK_STACK_SIZE (4 * 1024) #define EXAMPLE_LVGL_TASK_PRIORITY 2 #define EXAMPLE_LVGL_DRAW_BUF_LINES 100 #define EXAMPLE_DMA_BURST_SIZE 64 // 16, 32, 64. Higher burst size can improve the performance when the DMA buffer comes from PSRAM7 defines // LVGL library is not thread-safe, this example will call LVGL APIs from different tasks, so use a mutex to protect it static _lock_t lvgl_api_lock; extern void example_lvgl_demo_ui(lv_disp_t *disp); static bool example_notify_lvgl_flush_ready(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_io_event_data_t *edata, void *user_ctx) { lv_display_t *display = (lv_display_t *)user_ctx; lv_display_flush_ready(display); return false; }{ ... } static void example_lvgl_flush_cb(lv_display_t *display, const lv_area_t *area, uint8_t *color_map) { esp_lcd_panel_handle_t panel_handle = lv_display_get_user_data(display); int offsetx1 = area->x1; int offsetx2 = area->x2; int offsety1 = area->y1; int offsety2 = area->y2; // because LCD is big-endian, we need to swap the RGB bytes order lv_draw_sw_rgb565_swap(color_map, (offsetx2 + 1 - offsetx1) * (offsety2 + 1 - offsety1)); // copy a buffer's content to a specific area of the display esp_lcd_panel_draw_bitmap(panel_handle, offsetx1, offsety1, offsetx2 + 1, offsety2 + 1, color_map); }{ ... } static void example_increase_lvgl_tick(void *arg) { /* Tell LVGL how many milliseconds has elapsed */ lv_tick_inc(EXAMPLE_LVGL_TICK_PERIOD_MS); }{ ... } static void example_lvgl_port_task(void *arg) { ESP_LOGI(TAG, "Starting LVGL task"); uint32_t time_till_next_ms = 0; while (1) { _lock_acquire(&lvgl_api_lock); time_till_next_ms = lv_timer_handler(); _lock_release(&lvgl_api_lock); if (time_till_next_ms > EXAMPLE_LVGL_TASK_MAX_DELAY_MS) { time_till_next_ms = EXAMPLE_LVGL_TASK_MAX_DELAY_MS; }{...} else if (time_till_next_ms < EXAMPLE_LVGL_TASK_MIN_DELAY_MS) { time_till_next_ms = EXAMPLE_LVGL_TASK_MIN_DELAY_MS; }{...} vTaskDelay(pdMS_TO_TICKS(time_till_next_ms)); }{...} }{ ... } #if CONFIG_EXAMPLE_LCD_IMAGE_FROM_FILE_SYSTEM void example_init_filesystem(void) { ESP_LOGI(TAG, "Initializing filesystem"); esp_vfs_spiffs_conf_t conf = { .base_path = "/spiffs", .partition_label = "storage", .max_files = 5, .format_if_mount_failed = true }{...}; // Use settings defined above to initialize and mount SPIFFS filesystem. // Note: esp_vfs_spiffs_register is an all-in-one convenience function. esp_err_t ret = esp_vfs_spiffs_register(&conf); if (ret != ESP_OK) { if (ret == ESP_FAIL) { ESP_LOGE(TAG, "Failed to mount or format filesystem"); }{...} else if (ret == ESP_ERR_NOT_FOUND) { ESP_LOGE(TAG, "Failed to find SPIFFS partition"); }{...} else { ESP_LOGE(TAG, "Failed to initialize SPIFFS (%s)", esp_err_to_name(ret)); }{...} return; }{...} size_t total = 0, used = 0; ret = esp_spiffs_info(conf.partition_label, &total, &used); if (ret != ESP_OK) { ESP_LOGE(TAG, "Failed to get SPIFFS partition information (%s). Formatting...", esp_err_to_name(ret)); esp_spiffs_format(conf.partition_label); return; }{...} else { ESP_LOGI(TAG, "Partition size: total: %zu, used: %zu", total, used); }{...} }{...} /* ... */#endif // CONFIG_EXAMPLE_LCD_IMAGE_FROM_FILE_SYSTEM void example_init_i80_bus(esp_lcd_panel_io_handle_t *io_handle) { ESP_LOGI(TAG, "Initialize Intel 8080 bus"); esp_lcd_i80_bus_handle_t i80_bus = NULL; esp_lcd_i80_bus_config_t bus_config = { .clk_src = LCD_CLK_SRC_DEFAULT, .dc_gpio_num = EXAMPLE_PIN_NUM_DC, .wr_gpio_num = EXAMPLE_PIN_NUM_PCLK, .data_gpio_nums = { EXAMPLE_PIN_NUM_DATA0, EXAMPLE_PIN_NUM_DATA1, EXAMPLE_PIN_NUM_DATA2, EXAMPLE_PIN_NUM_DATA3, EXAMPLE_PIN_NUM_DATA4, EXAMPLE_PIN_NUM_DATA5, EXAMPLE_PIN_NUM_DATA6, EXAMPLE_PIN_NUM_DATA7, #if CONFIG_EXAMPLE_LCD_I80_BUS_WIDTH > 8 EXAMPLE_PIN_NUM_DATA8, EXAMPLE_PIN_NUM_DATA9, EXAMPLE_PIN_NUM_DATA10, EXAMPLE_PIN_NUM_DATA11, EXAMPLE_PIN_NUM_DATA12, EXAMPLE_PIN_NUM_DATA13, EXAMPLE_PIN_NUM_DATA14, EXAMPLE_PIN_NUM_DATA15,/* ... */ #endif }{...}, .bus_width = CONFIG_EXAMPLE_LCD_I80_BUS_WIDTH, .max_transfer_bytes = EXAMPLE_LCD_H_RES * 100 * sizeof(uint16_t), .dma_burst_size = EXAMPLE_DMA_BURST_SIZE, }{...}; ESP_ERROR_CHECK(esp_lcd_new_i80_bus(&bus_config, &i80_bus)); esp_lcd_panel_io_i80_config_t io_config = { .cs_gpio_num = EXAMPLE_PIN_NUM_CS, .pclk_hz = EXAMPLE_LCD_PIXEL_CLOCK_HZ, .trans_queue_depth = 10, .dc_levels = { .dc_idle_level = 0, .dc_cmd_level = 0, .dc_dummy_level = 0, .dc_data_level = 1, }{...}, .lcd_cmd_bits = EXAMPLE_LCD_CMD_BITS, .lcd_param_bits = EXAMPLE_LCD_PARAM_BITS, }{...}; ESP_ERROR_CHECK(esp_lcd_new_panel_io_i80(i80_bus, &io_config, io_handle)); }{ ... } void example_init_lcd_panel(esp_lcd_panel_io_handle_t io_handle, esp_lcd_panel_handle_t *panel) { esp_lcd_panel_handle_t panel_handle = NULL; #if CONFIG_EXAMPLE_LCD_I80_CONTROLLER_ST7789 ESP_LOGI(TAG, "Install LCD driver of st7789"); esp_lcd_panel_dev_config_t panel_config = { .reset_gpio_num = EXAMPLE_PIN_NUM_RST, .rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB, .bits_per_pixel = 16, }{...}; ESP_ERROR_CHECK(esp_lcd_new_panel_st7789(io_handle, &panel_config, &panel_handle)); esp_lcd_panel_reset(panel_handle); esp_lcd_panel_init(panel_handle); // Set inversion, x/y coordinate order, x/y mirror according to your LCD module spec // the gap is LCD panel specific, even panels with the same driver IC, can have different gap value esp_lcd_panel_invert_color(panel_handle, true); esp_lcd_panel_set_gap(panel_handle, 0, 20);/* ... */ #elif CONFIG_EXAMPLE_LCD_I80_CONTROLLER_NT35510 ESP_LOGI(TAG, "Install LCD driver of nt35510"); esp_lcd_panel_dev_config_t panel_config = { .reset_gpio_num = EXAMPLE_PIN_NUM_RST, .rgb_ele_order = LCD_RGB_ELEMENT_ORDER_BGR, .bits_per_pixel = 16, }{...}; ESP_ERROR_CHECK(esp_lcd_new_panel_nt35510(io_handle, &panel_config, &panel_handle)); esp_lcd_panel_reset(panel_handle); esp_lcd_panel_init(panel_handle); // Set inversion, x/y coordinate order, x/y mirror according to your LCD module spec // the gap is LCD panel specific, even panels with the same driver IC, can have different gap value esp_lcd_panel_swap_xy(panel_handle, true); esp_lcd_panel_mirror(panel_handle, true, false);/* ... */ #elif CONFIG_EXAMPLE_LCD_I80_CONTROLLER_ILI9341 // ILI9341 is NOT a distinct driver, but a special case of ST7789 // (essential registers are identical). A few lines further down in this code, // it's shown how to issue additional device-specific commands. ESP_LOGI(TAG, "Install LCD driver of ili9341 (st7789 compatible)"); esp_lcd_panel_dev_config_t panel_config = { .reset_gpio_num = EXAMPLE_PIN_NUM_RST, .rgb_ele_order = LCD_RGB_ELEMENT_ORDER_BGR, .bits_per_pixel = 16, }{...}; ESP_ERROR_CHECK(esp_lcd_new_panel_st7789(io_handle, &panel_config, &panel_handle)); esp_lcd_panel_reset(panel_handle); esp_lcd_panel_init(panel_handle); // Set inversion, x/y coordinate order, x/y mirror according to your LCD module spec // the gap is LCD panel specific, even panels with the same driver IC, can have different gap value esp_lcd_panel_swap_xy(panel_handle, true); esp_lcd_panel_invert_color(panel_handle, false); // ILI9341 is very similar to ST7789 and shares the same driver. // Anything unconventional (such as this custom gamma table) can // be issued here in user code and need not modify the driver. esp_lcd_panel_io_tx_param(io_handle, 0xF2, (uint8_t[]) { 0 }{...}, 1); // 3Gamma function disable esp_lcd_panel_io_tx_param(io_handle, 0x26, (uint8_t[]) { 1 }{...}, 1); // Gamma curve 1 selected esp_lcd_panel_io_tx_param(io_handle, 0xE0, (uint8_t[]) { // Set positive gamma 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, 0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00 }{...}, 15); esp_lcd_panel_io_tx_param(io_handle, 0xE1, (uint8_t[]) { // Set negative gamma 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, 0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F }{...}, 15);/* ... */ #endif *panel = panel_handle; }{ ... } void app_main(void) { #if EXAMPLE_PIN_NUM_BK_LIGHT >= 0 ESP_LOGI(TAG, "Turn off LCD backlight"); gpio_config_t bk_gpio_config = { .mode = GPIO_MODE_OUTPUT, .pin_bit_mask = 1ULL << EXAMPLE_PIN_NUM_BK_LIGHT }{...}; ESP_ERROR_CHECK(gpio_config(&bk_gpio_config)); gpio_set_level(EXAMPLE_PIN_NUM_BK_LIGHT, EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL);/* ... */ #endif // EXAMPLE_PIN_NUM_BK_LIGHT >= 0 #if CONFIG_EXAMPLE_LCD_IMAGE_FROM_FILE_SYSTEM example_init_filesystem(); #endif // CONFIG_EXAMPLE_LCD_IMAGE_FROM_FILE_SYSTEM esp_lcd_panel_io_handle_t io_handle = NULL; example_init_i80_bus(&io_handle); esp_lcd_panel_handle_t panel_handle = NULL; example_init_lcd_panel(io_handle, &panel_handle); // Stub: user can flush pre-defined pattern to the screen before we turn on the screen or backlight ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true)); #if EXAMPLE_PIN_NUM_BK_LIGHT >= 0 ESP_LOGI(TAG, "Turn on LCD backlight"); gpio_set_level(EXAMPLE_PIN_NUM_BK_LIGHT, EXAMPLE_LCD_BK_LIGHT_ON_LEVEL);/* ... */ #endif // EXAMPLE_PIN_NUM_BK_LIGHT >= 0 ESP_LOGI(TAG, "Initialize LVGL library"); lv_init(); // create a lvgl display lv_display_t *display = lv_display_create(EXAMPLE_LCD_H_RES, EXAMPLE_LCD_V_RES); // it's recommended to choose the size of the draw buffer(s) to be at least 1/10 screen sized size_t draw_buffer_sz = EXAMPLE_LCD_H_RES * EXAMPLE_LVGL_DRAW_BUF_LINES * sizeof(lv_color16_t); // alloc draw buffers used by LVGL uint32_t draw_buf_alloc_caps = 0; #if CONFIG_EXAMPLE_LCD_I80_COLOR_IN_PSRAM draw_buf_alloc_caps |= MALLOC_CAP_SPIRAM; #endif void *buf1 = esp_lcd_i80_alloc_draw_buffer(io_handle, draw_buffer_sz, draw_buf_alloc_caps); void *buf2 = esp_lcd_i80_alloc_draw_buffer(io_handle, draw_buffer_sz, draw_buf_alloc_caps); assert(buf1); assert(buf2); ESP_LOGI(TAG, "buf1@%p, buf2@%p", buf1, buf2); // initialize LVGL draw buffers lv_display_set_buffers(display, buf1, buf2, draw_buffer_sz, LV_DISPLAY_RENDER_MODE_PARTIAL); // associate the mipi panel handle to the display lv_display_set_user_data(display, panel_handle); // set color depth lv_display_set_color_format(display, LV_COLOR_FORMAT_RGB565); // set the callback which can copy the rendered image to an area of the display lv_display_set_flush_cb(display, example_lvgl_flush_cb); ESP_LOGI(TAG, "Install LVGL tick timer"); // Tick interface for LVGL (using esp_timer to generate 2ms periodic event) const esp_timer_create_args_t lvgl_tick_timer_args = { .callback = &example_increase_lvgl_tick, .name = "lvgl_tick" }{...}; esp_timer_handle_t lvgl_tick_timer = NULL; ESP_ERROR_CHECK(esp_timer_create(&lvgl_tick_timer_args, &lvgl_tick_timer)); ESP_ERROR_CHECK(esp_timer_start_periodic(lvgl_tick_timer, EXAMPLE_LVGL_TICK_PERIOD_MS * 1000)); ESP_LOGI(TAG, "Register io panel event callback for LVGL flush ready notification"); const esp_lcd_panel_io_callbacks_t cbs = { .on_color_trans_done = example_notify_lvgl_flush_ready, }{...}; /* Register done callback */ ESP_ERROR_CHECK(esp_lcd_panel_io_register_event_callbacks(io_handle, &cbs, display)); ESP_LOGI(TAG, "Create LVGL task"); xTaskCreate(example_lvgl_port_task, "LVGL", EXAMPLE_LVGL_TASK_STACK_SIZE, NULL, EXAMPLE_LVGL_TASK_PRIORITY, NULL); ESP_LOGI(TAG, "Display LVGL animation"); // Lock the mutex due to the LVGL APIs are not thread-safe _lock_acquire(&lvgl_api_lock); example_lvgl_demo_ui(display); _lock_release(&lvgl_api_lock); }{ ... }
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.