I am trying to display an image on an ILI9341 display using the LittlevGL library and an ESP32 board. I have connected the display and XPT2046 touch screen according to the pinout specified in my code, and I have correctly configured the display and touch screen drivers in the platformio.ini file. However, when I run the code, I get the following error message: D (1272) intr_alloc: Connected src 16 to int 12 (cpu 0)␛[0m 'Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.'
I have checked the pinout and the driver configurations, but I am still unable to get the image to display on the screen. Can someone please help me troubleshoot this issue? Here is my code:
#include "lvgl/lvgl.h"
#include "lvgl_esp32_drivers/lvgl_helpers.h"
#include "lvgl/examples/lv_examples.h"
#include "ili9341.h"
#include "xpt2046.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#define LCD_WIDTH 320
#define LCD_HEIGHT 240
static void btn_event_cb(lv_event_t * e)
{
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t * btn = lv_event_get_target(e);
if(code == LV_EVENT_CLICKED) {
static uint8_t cnt = 0;
cnt++;
/*Get the first child of the button which is the label and change its text*/
lv_obj_t * label = lv_obj_get_child(btn, 0);
lv_label_set_text_fmt(label, "Button: %d", cnt);
}
}
void lv_example_get_started_1(void)
{
lv_obj_t * btn = lv_btn_create(lv_scr_act()); /*Add a button the current screen*/
lv_obj_set_pos(btn, 10, 10); /*Set its position*/
lv_obj_set_size(btn, 120, 50); /*Set its size*/
lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_ALL, NULL); /*Assign a callback to the button*/
lv_obj_t * label = lv_label_create(btn); /*Add a label to the button*/
lv_label_set_text(label, "Button"); /*Set the labels text*/
lv_obj_center(label);
}
static void display_task(void *arg)
{
// Initialize the display
lv_init();
lv_example_get_started_1();
// Update the display continuously
while (1) {
lv_tick_inc(portTICK_PERIOD_MS);
lv_task_handler();
vTaskDelay(portTICK_PERIOD_MS);
}
}
void configure_drivers()
{
lvgl_driver_init();
static lv_disp_draw_buf_t draw_buf;
static lv_color_t buf1[LCD_WIDTH * LCD_HEIGHT / 10]; /*Declare a buffer for 1/10 screen size*/
lv_disp_draw_buf_init(&draw_buf, buf1, NULL, LCD_WIDTH * LCD_HEIGHT / 10); /*Initialize the display buffer.*/
// Set the display and touch screen drivers in LVGL
lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
disp_drv.flush_cb = ili9341_flush;
disp_drv.draw_buf = &draw_buf; /*Assign the buffer to the display*/
disp_drv.hor_res = LCD_WIDTH; /*Set the horizontal resolution of the display*/
disp_drv.ver_res = LCD_HEIGHT; /*Set the vertical resolution of the display*/
lv_disp_drv_register(&disp_drv);
/*
lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = xpt2046_read;
lv_indev_drv_register(&indev_drv);
*/
}
extern "C" void app_main()
{
// Create a task to handle the display
xTaskCreate(display_task, "display", 8192, NULL, 5, NULL);
}
Thank you in advance for any help or suggestions!