Description
I have posted and deleted bugs over the last few days because I thought there was something else i could try.
I am trying to something really simple but cannot seem to do it and now I think it might be a bug.
I am showing a simplified example that allows me to illustrate the issue.
In the example:
- I take a serial input being sent to the esp32, which alternates between a single character and is sent each second.
- I create three led objects in my setup and then change their appearance based on the serial result.
Problem:
when I execute the code described as above the ESP32 either stops responding in the case of the LED and when I have used it on other examples where I setup the object first in setup and then change its background property the ESP32 crashed with " Guru Meditation Error: Core 1 panic’ed (LoadProhibited). Exception was unhandled
".
The only way I can get it to work is how it is shown in the example, where you create the led each time, but I know that you don’t have to create the objects each time and lo and behold it freezes after about 20 updates.
The work I have done for the last week has been on the lv_printer_example() and I have simplified it to this code to reproduce. I hope its not just the esp32 that is the issue :(.
sorry if I am doing something silly, but I really want to keep using this platform for my dev work but cant get past this basic hurdle.
If my implementation is wrong then please show me an example that would flash the alternate LEDs by updating the object state after it has been created.
What MCU/Processor/Board and compiler are you using?
ESP32-WROOM-32D connected via SPI bus to ILI9488 Screen
What LVGL version are you using?
7.8
What do you want to achieve?
What have you tried so far?
I have tried changing:
set in lv_conf.h
> #define LV_USE_ASSERT_MEM_INTEGRITY 1
> #define LV_USE_ASSERT_OBJ 1
> #define LV_USE_ASSERT_STYLE 1
Tried creating a task that scans the change and updates but this also crashes with same result.
Code to reproduce
Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.
The code block(s) should be formatted like:
#include <lvgl.h>
#include <TFT_eSPI.h>
#include <SPI.h>
#include <Ticker.h>
#define RXD2 12
#define TXD2 14
int counter = 0;
static String LoRaData;
static lv_obj_t * led1;
static lv_obj_t * led2;
static lv_obj_t * led3;
#define screenWidth 480
#define screenHeight 320
#define LVGL_TICK_PERIOD 20
TFT_eSPI tft = TFT_eSPI(); /* TFT instance */
static lv_disp_buf_t disp_buf;
static lv_color_t buf[LV_HOR_RES_MAX * 10];
Ticker lvgl_tick; /* timer for lvgl */
static lv_obj_t* add_title(const char* txt);
#if LV_USE_LOG != 0
/* Serial debugging */
void my_print(lv_log_level_t level, const char * file, uint32_t line, const char * fn_name, const char * dsc)
{
Serial.printf("%s@%d->%s\r\n", file, line, dsc);
Serial.flush();
}
#endif
/* Display flushing */
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{
uint32_t w = (area->x2 - area->x1 + 1);
uint32_t h = (area->y2 - area->y1 + 1);
tft.startWrite();
tft.setAddrWindow(area->x1, area->y1, w, h);
tft.pushColors(&color_p->full, w * h, true);
tft.endWrite();
lv_disp_flush_ready(disp);
}
/*Read the touchpad*/
bool my_touchpad_read(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
{
uint16_t touchX, touchY;
bool touched = tft.getTouch(&touchX, &touchY, 600);
if (!touched)
{
data->state = LV_INDEV_STATE_REL;
return false;
}
else
{
data->state = LV_INDEV_STATE_PR;
}
if (touchX > screenWidth || touchY > screenHeight)
{
Serial.println("Y or y outside of expected parameters..");
Serial.print("y:");
Serial.print(touchX);
Serial.print(" x:");
Serial.print(touchY);
}
else
{
/*Set the coordinates*/
if (3 == tft.getRotation()) {
//Shift coordinates
data->point.x = 480 - touchX;
data->point.y = 320 - touchY;
} else if (1 == tft.getRotation()) {
data->point.x = touchX;
data->point.y = touchY;
}
Serial.print("Data x");
Serial.println(touchX);
Serial.print("Data y");
Serial.println(touchY);
}
return false; /*Return `false` because we are not buffering and no more data to read*/
}
void lv_tick_handler() {
lv_tick_inc(LVGL_TICK_PERIOD);
}
void setup()
{
Serial.begin(115200); /* prepare for possible serial debug */
Serial1.begin(115200, SERIAL_8N1, RXD2, TXD2);
Serial.println("Serial Txd is on pin: "+String(TX));
Serial.println("Serial Rxd is on pin: "+String(RX));
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
lv_init();
#if LV_USE_LOG != 0
lv_log_register_print_cb(my_print); /* register print function for debugging */
#endif
tft.begin(); /* TFT init */
tft.setRotation(1); /* Landscape orientation */
// uint16_t calData[5] = { 305, 3542, 245, 3529, 3 };
uint16_t calData[5] = { 270, 3639, 250, 3556, 7 };
tft.setTouch(calData);
lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10);
/*Initialize the display*/
lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
disp_drv.hor_res = 480;
disp_drv.ver_res = 320;
disp_drv.flush_cb = my_disp_flush;
disp_drv.buffer = &disp_buf;
lv_disp_drv_register(&disp_drv);
/*Initialize the (dummy) input device driver*/
lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = my_touchpad_read;
lv_indev_drv_register(&indev_drv);
lvgl_tick.attach_ms(LVGL_TICK_PERIOD, lv_tick_handler);
}
}
void loop()
{
// Serial.println(char(Serial1.read()));
lv_task_handler(); /* let the GUI do its work */
delay(5);
while (Serial1.available()) {
// Serial.print(char(Serial1.read()));
LoRaData = (char(Serial1.read()));
Serial.println(LoRaData);
if(LoRaData=="L"){
lv_obj_t * led1 = lv_led_create(lv_scr_act(), NULL);
lv_obj_align(led1, NULL, LV_ALIGN_CENTER, -80, 0);
lv_obj_t * led2 = lv_led_create(lv_scr_act(), led1);
lv_obj_align(led2, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_t * led3 = lv_led_create(lv_scr_act(), led1);
lv_obj_align(led3, NULL, LV_ALIGN_CENTER, 80, 0);
lv_led_off(led1);
lv_led_set_bright(led2, 190);
lv_led_on(led3);
yield();
delay(5);
}
else if(LoRaData=="O"){
lv_obj_t * led1 = lv_led_create(lv_scr_act(), NULL);
lv_obj_align(led1, NULL, LV_ALIGN_CENTER, -80, 0);
lv_obj_t * led2 = lv_led_create(lv_scr_act(), led1);
lv_obj_align(led2, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_t * led3 = lv_led_create(lv_scr_act(), led1);
lv_obj_align(led3, NULL, LV_ALIGN_CENTER, 80, 0);
lv_led_on(led1);
lv_led_set_bright(led2, 190);
lv_led_off(led3);
yield();
delay(5);
}
else{
Serial.println("CONDISTION NOT MET");
}
}
}
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.