I have been having problems getting LVGL to work with my display ILI9341
on ESP-IDF. For the past two days, I had been struggling with even making the code to compile without error, and I had to go back to version 7.11.0 and at last made it to compile. The problem is that the widget is freezing on being called, here is my code:
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "lvgl.h"
#include "lvgl_helpers.h"
void button_event_handler(lv_event_t* e);
void app_main(void) {
lv_init();
lvgl_driver_init();
// // Create a screen
lv_obj_t* screen = lv_disp_get_scr_act(NULL);
printf("Screen created\n");
lv_obj_t* label1 = lv_label_create(lv_scr_act(), NULL);
lv_label_set_long_mode(label1, LV_LABEL_LONG_BREAK); /*Break the long lines*/
lv_label_set_recolor(label1,
true); /*Enable re-coloring by commands in the text*/
lv_label_set_align(label1, LV_LABEL_ALIGN_CENTER); /*Center aligned lines*/
lv_label_set_text(label1,
"#0000ff Re-color# #ff00ff words# #ff0000 of a# label "
"and wrap long text automatically.");
lv_obj_set_width(label1, 150);
lv_obj_align(label1, NULL, LV_ALIGN_CENTER, 0, -30);
printf("Widget initialization complete\n");
int elapsedSeconds = 0;
while (1) {
lv_task_handler();
vTaskDelay(50 / portTICK_PERIOD_MS);
}
}
void button_event_handler(lv_event_t* e) { printf("Button clicked\n"); }
Here is my monitor output:
/home/george/.espressif/python_env/idf5.1_py3.11_env/bin/python /home/george/esp/esp-idf/tools/idf_monitor.py -p /dev/ttyUSB0 -b 115200 --toolchain-prefix xtensa-esp32-elf- --target esp32 /my-files/Creations/ESP-IDF/LVGL-V7/build/LVGL-V7.elf
--- idf_monitor on /dev/ttyUSB0 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:7088
load:0x40078000,len:15576
load:0x40080400,len:4
0x40080400: _init at ??:?
ho 8 tail 4 room 4
load:0x40080404,len:3876
entry 0x4008064c
I (30) boot: ESP-IDF v5.1-rc2-dirty 2nd stage bootloader
I (30) boot: compile time Sep 1 2023 19:07:49
I (30) boot: Multicore bootloader
I (35) boot: chip revision: v1.0
I (39) boot.esp32: SPI Speed : 40MHz
I (44) boot.esp32: SPI Mode : DIO
I (48) boot.esp32: SPI Flash Size : 2MB
I (53) boot: Enabling RNG early entropy source...
I (58) boot: Partition Table:
I (62) boot: ## Label Usage Type ST Offset Length
I (69) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (76) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (84) boot: 2 factory factory app 00 00 00010000 00100000
I (91) boot: End of partition table
I (96) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=11818h ( 71704) map
I (130) esp_image: segment 1: paddr=00021840 vaddr=3ffb0000 size=022e8h ( 8936) load
I (134) esp_image: segment 2: paddr=00023b30 vaddr=40080000 size=0c4e8h ( 50408) load
I (157) esp_image: segment 3: paddr=00030020 vaddr=400d0020 size=30b84h (199556) map
I (229) esp_image: segment 4: paddr=00060bac vaddr=4008c4e8 size=019ach ( 6572) load
I (239) boot: Loaded app from partition at offset 0x10000
I (239) boot: Disabling RNG early entropy source...
I (251) cpu_start: Multicore app
I (252) cpu_start: Pro cpu up.
I (252) cpu_start: Starting app cpu, entry point is 0x40081298
0x40081298: call_start_cpu1 at /home/george/esp/esp-idf/components/esp_system/port/cpu_start.c:154
I (0) cpu_start: App cpu up.
I (272) cpu_start: Pro cpu start user code
I (272) cpu_start: cpu freq: 160000000 Hz
I (272) cpu_start: Application information:
I (277) cpu_start: Project name: LVGL-V7
I (282) cpu_start: App version: 1
I (286) cpu_start: Compile time: Sep 1 2023 19:25:42
I (292) cpu_start: ELF file SHA256: dd526cbce71c78f5...
I (298) cpu_start: ESP-IDF: v5.1-rc2-dirty
I (304) cpu_start: Min chip rev: v0.0
I (308) cpu_start: Max chip rev: v3.99
I (313) cpu_start: Chip rev: v1.0
I (318) heap_init: Initializing. RAM available for dynamic allocation:
I (325) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (331) heap_init: At 3FFC3190 len 0001CE70 (115 KiB): DRAM
I (337) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (344) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (350) heap_init: At 4008DE94 len 0001216C (72 KiB): IRAM
I (358) spi_flash: detected chip: generic
I (361) spi_flash: flash io: dio
W (365) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (379) app_start: Starting scheduler on CPU0
I (383) app_start: Starting scheduler on CPU1
I (383) main_task: Started on CPU0
I (393) main_task: Calling app_main()
I (403) lvgl_helpers: Display hor size: 320, ver size: 240
I (403) lvgl_helpers: Display buffer size: 12800
I (403) lvgl_helpers: Initializing SPI master for display
I (413) lvgl_helpers: Configuring SPI host SPI2_HOST
I (413) lvgl_helpers: MISO pin: -1, MOSI pin: 4, SCLK pin: 16, IO2/WP pin: -1, IO3/HD pin: -1
I (423) lvgl_helpers: Max transfer size: 25600 (bytes)
I (433) lvgl_helpers: Initializing SPI bus...
I (433) disp_spi: Adding SPI device
I (443) disp_spi: Clock speed: 4000000Hz, mode: 0, CS pin: 17
I (653) ILI9341: Initialization.
I (853) ILI9341: Display orientation: PORTRAIT
I (853) ILI9341: 0x36 command value: 0x48
W (853) disp_backlight: Invalid GPIO number
I (853) lvgl_helpers: Initializing SPI master for touch
I (853) lvgl_helpers: Configuring SPI host SPI3_HOST
I (863) lvgl_helpers: MISO pin: 22, MOSI pin: 23, SCLK pin: 19, IO2/WP pin: -1, IO3/HD pin: -1
I (873) lvgl_helpers: Max transfer size: 0 (bytes)
I (873) lvgl_helpers: Initializing SPI bus...
I (883) XPT2046: XPT2046 Initialization
I (883) gpio: GPIO[15]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
Screen created
E (5833) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:
E (5833) task_wdt: - IDLE (CPU 0)
E (5833) task_wdt: Tasks currently running:
E (5833) task_wdt: CPU 0: main
E (5833) task_wdt: CPU 1: IDLE
E (5833) task_wdt: Print CPU 0 (current core) backtrace
Backtrace: 0x400F1F2B:0x3FFB0E00 0x400F20B2:0x3FFB0E20 0x40082B75:0x3FFB0E40 0x400EB3E2:0x3FFC5400 0x400D5CD9:0x3FFC5420 0x401003AB:0x3FFC5440 0x40088FE1:0x3FFC5470
0x400f1f2b: task_wdt_timeout_handling at /home/george/esp/esp-idf/components/esp_system/task_wdt/task_wdt.c:461 (discriminator 3)
0x400f20b2: task_wdt_isr at /home/george/esp/esp-idf/components/esp_system/task_wdt/task_wdt.c:585
0x40082b75: _xt_lowint1 at /home/george/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/xtensa_vectors.S:1226
0x400eb3e2: lv_label_create at /my-files/Creations/ESP-IDF/LVGL-V7/managed_components/lvgl__lvgl/src/lv_widgets/lv_label.c:82 (discriminator 1)
0x400d5cd9: app_main at /my-files/Creations/ESP-IDF/LVGL-V7/main/main.c:18
0x401003ab: main_task at /home/george/esp/esp-idf/components/freertos/app_startup.c:208 (discriminator 13)
0x40088fe1: vPortTaskWrapper at /home/george/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162
E (10833) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:
E (10833) task_wdt: - IDLE (CPU 0)
E (10833) task_wdt: Tasks currently running:
E (10833) task_wdt: CPU 0: main
E (10833) task_wdt: CPU 1: IDLE
E (10833) task_wdt: Print CPU 0 (current core) backtrace
I am using ESP-IDF v5.1
I tried creating the label on a predefined screen object and also tried creating the label without the screen and nothing displays until I noticed that the code execution does not get passed the widget create function.