Description
I’ve setup LVGL 9 in a small test project.
I’ve a label, that shows no text at the beginning.
Connected is a tact switch. When ever I press the switch, I want to toggle between two texts and styles.
This is working, but when I press the switch too fast, it either panics or results in this message [Error] (4.177, +4177) _lv_inv_area: Asserted at expression: !disp->rendering_in_progress (Invalidate area is not allowed during rendering.) lv_refr.c:257
I can’t recover from that state. A switch press won’t change anything now …
What MCU/Processor/Board and compiler are you using?
ESP32 S3 Dev Kit C with PlatformIO and Arduino Framework
What LVGL version are you using?
LVGL 9 and OneButton lib
What I tried
I tried adding the lv_mutex_t
, but I think it’s not running on two cores currently.
The problem is still the same with mutex …
Code to reproduce
OneButton upperRight = OneButton(UPPER_RIGHT_PIN, false);
void pressed()
{
nhd.change();
}
void setup()
{
Serial.begin(9600);
nhd.begin();
upperRight.attachClick(pressed);
}
NHD.cpp
void NHD::begin()
{
lv_init();
display = lv_display_create(TFT_HOR_RES, TFT_VER_RES);
TFT_eSPI *tft = new TFT_eSPI(TFT_HOR_RES, TFT_VER_RES);
tft->begin(); /* TFT init */
tft->setRotation(1); /* Landscape orientation, flipped */
tft->initDMA();
lv_display_set_driver_data(display, (void *)tft);
lv_display_set_flush_cb(display, flush_cb);
lv_display_set_buffers(display, (void *)draw_buf, NULL, sizeof(draw_buf), LV_DISPLAY_RENDER_MODE_PARTIAL);
label = lv_label_create(lv_scr_act());
lv_label_set_text(label, "");
xTaskCreate(tick, "tick", 3000, NULL, 1, NULL);
xTaskCreate(timer, "handle", 4000, NULL, 1, NULL);
}
uint i = 0;
void NHD::change()
{
lv_mutex_lock(&lvgl_mutex);
if (i++ == 0)
{
lv_label_set_text(label, "This is a extremely long text, that needs scrolling to be visible at all");
lv_obj_remove_style_all(label);
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
lv_obj_align(label, LV_ALIGN_LEFT_MID, 5, 0);
lv_obj_set_width(label, 100);
}
else
{
lv_label_set_text_fmt(label, "%d%%", 70);
lv_obj_align(label, LV_ALIGN_LEFT_MID, 5, 0);
lv_obj_set_style_border_color(label, lv_palette_main(LV_PALETTE_BLUE), LV_PART_MAIN);
lv_obj_set_style_border_width(label, 5, LV_PART_MAIN);
i = 0;
}
lv_mutex_unlock(&lvgl_mutex);
}